Peter's Blog

Just commenting on things that interest me

Author: adminPeter (page 2 of 16)

Things I love about John Wick

In 2014 a movie came out which changed the face of action movies. It was “John Wick” starring Keanu Reeves.

The movie was  directed by Chad Stahelski and David Leitch and written by Derek Kolstad.

I had seen a trailer in advance so I was looking forward to the movie coming out. The premise (an assassin goes looking for revenge when some bad guys kill his dog and steal his car) seemed so very, very promising!

And the movie did not disappoint. It had some of the best action sequences (unarmed combat, guns and weapons) I had ever seen.

Here are some of the things I love about the John Wick movies:

Action

The action and fight scenes are top notch.

Chad and David are martial artists and stuntmen who formed a company together called 89Eleven in 1997. The company website says this:

Action design is an art form all its own. At 87eleven, our team has what it takes to create innovative stunts for studio films

So when they got the chance to direct the first John Wick movie, they made the movie of their dreams. And the action and  fight scenes raised the bar!

IMDB says that John Wick kills 77 people in the movie. In an interview, Chad said that the real number is higher!

The movie features “gun fu”. Although Chad is a master of many martial arts, he said that John Wick uses a combination of ” Japanese jiu-jitsu, Brazilian jiu-jitsu, tactical 3-gun, and standing Judo”.

World

The movie creates a whole world of assassins.  They have their own code and rules. Their own way of getting contracts. Their own currency. And their own chain of hotels (the Continentals) where they can feel safe (no “business” can be conducted on the hotel grounds).

This world adds a lot of depth to the stories.

Shibumi

The book Shibumi by Trevanian is my favourite book.  It makes an appearance in the first movie in two ways:

  • Nicholai Hel (the main character in Shibumi) is an assassin and a master of “naked/kill” (the art of killing people with everyday objects). Nicholai’s life takes a sharp turn when he is forced to kill someone with a pencil. We are old in the movie that John Wich has killed three men with a pencil.
  • A security guard is seen reading the book at one point

Sequels

It is very hard to make sequels which are as good as the original. John Wick is an exception. The first movie scored 7.4 on IMDB. The two sequels each score 7.5! In Rotten Tomatoes the scores are 87%, 89% and 90%.

Quite an achievement.

And “Chapter 4” is due out in 2022. I can’t wait!

Interviews

As well as making great movies, the guys are great to listen to when they are discussing the movies.

Here is a video of Chad and David discussing the move while watching the “Honest Trailer”

The Fry Model Railway

Dublin engineer and draughtsman Cyril Fry built a superb collection of more than 300 model trains over a 40 year period from the 1920s. Cyril passed away on 1972 and the collection was subsequently acquired from his widow by Dublin Tourism.

The collection reappeared in 1988 in Malahide Castle. A team lead by retired CIÉ craftsman Thomas (Tom) Tighe had spent 8 years constructing a fabulous O gauge display to complement Cyril Fry’s models which were displayed in static exhibits for their own protection and preservation. The model railway had stations from all over Ireland, including Malahide station. So people (like me) going to see the Fry Model Railway were able to see and admire both of these things in Malahide Castle. The model railway was dismantled in 2010 and  put into storage.

I mentioned in a previous blog that I was excited to hear that a local farmer, Micheál Gaffney (sometime referred to as Patrick Michael Gaffney) who passed away in 2012, had left €1.5M in his will to Fingal County Council for the renovation of Casino House provided it was used to house the Fry Model Railway. The House was built around 1750 by the Talbot family. What a fantastic idea that was – to reserve the model railway and the cottage and to keep them available for visitors to Malahide.

So the new exhibition (called the Model Railway Museum) finally opened in January of this year, I did not manage to get in to see if before it was closed for COVID, but I did get in to see it with my whole family last weekend. Here is where the bad news begins.

The lady who welcomed us realised that we had seen the railway in its old location. So she started to set our expectations by saying that:

  • Casino did not have enough space to show the old model railway
  • The model railway did not cope well with being dismantled and stored

So the bad news is:

  • There is nothing left to see of Tom Tighe’s work
  • The new working model is very very poor. It uses a very small number of smaller trains (OO gauge) and they have only made models of four different locations. The models themselves are very poor. The model of Malahide is confusing, for example, with parts that look current, parts that look older, and parts that do not represent the actual geography.
  • The restoration of Casino is disappointing. While it looks very well from the outside, they have retained no vestiges that might speak to the previous character of the interior.  The interior is plain and boring.

I think small kids who like trains would still enjoy the model. But for the rest of us I would have preferred to have parts of Tom Tighe’s model, even if there were no moving trains.

So if you’re thinking of visiting because you have small kids then you may enjoy it. But everyone else can save their money.

Apparently Fingal County Council invested a further €2.8 million into the project on top of Mr Gaffney’s contribution. How badly wasted that money was!

To be honest, I can’t help thinking that Mr Gaffney is rolling over in his grave to see what Fingal did with his money.

If you have an interest in the Fry Model Railway, then I suggest that you should instead watch this segment from RTE’s Late Late show (originally shown on 31 March 1989) where Gay Byrne interviews Tom Tighe and shows some footage of the model railway in Malahide Castle.

 

John Hume

Ireland lost one of its greatest this week, with the passing of John Hume on Monday, and his funeral on Wednesday.

I always held John in the highest regard. And I was not the only one. He was voted “Ireland’s Greatest” in a public poll run by RTE in 2010.

Many tributes were paid to John (and his wife, Pat) over the last week. During the funeral itself, messages were read out from Pope Francis, the Dalai Lama, Bill Clinton and Bono. Many have said that without John’s vision, courage and perseverance that Northern Ireland would not have achieved peace in the way that it did. People have talked over the last few days of the number of lives which John has saved.  He has been called Ireland’s Martin Luther King.

He was awarded many richly deserved honours during his life, including:

  • Nobel Prize for Peace, 1998
  • Martin Luther King Peace Award, 1999
  • International Gandhi Peace Prize, 2001

We were on holiday in Moville for a week, leaving for home on the day he died.  On the Saturday we went into Derry city and went on the Bogside History Tour, guided by  Paul Doherty whose father was killed by British soldiers during Bloody Sunday in 1972.

The tour was excellent, and we all learned a lot over the course of those two hours. Obviously John Hume was mentioned a number of times, including the fact that he had advised against the march on Bloody Sunday because he was afraid of what the soldiers were going to do.

There are so many great stories of what this “shy schoolteacher” (as his wife Pat described him) did and achieved in his life.  There is a story here, for example, of how John called around to the families of the victims of Bloody Sunday and gave money to held with funeral expenses.

I am sorry that we were not still in Moville on the evening of his removal to the church. If we had been we could have stood on the roadside to pay our respects to him and his family. But we were home and we had to content ourselves with lighting a candle in the window instead.

Truly were lost Ireland’s Greatest this week.

There are so many photos that I could finish this with, including photos of John with the great and the good. But I think the most fitting is this photo of John and his wife Pat on the day of voting for the Good Friday agreement. Ar dheist Dé go raibh a anam.

Things I hate about How I Met Your Mother

OK. So the title of this post is misleading.

There is nothing I hate about HIMYM! I love that show. I just finished watching all 9 seasons.

If you asked most people what they hate about HIMYM, they would say the ending. On IMDB the series has a rating of 8.3 but the final episode has a rating of 5.5, which is by far the lowest rating of the whole series.

I don’t hate the ending really, but if I was forced to criticise something about the show I would have to say:

  • The last episode seemed a bit rushed. I think the could have taken a lot longer with this. Alyson Hannigan has said that there was a lot of great material for the finale and she was shocked at how much was cut
  • I wish Barney could have had a happier outcome. But I guess the writers did their best with what they had

Since the premise of the story is that Ted is telling his kids how he met their mother, it is reasonable to assume that she might not be alive at that stage.

Having dealt with the bad, let me list my favourite things:

Barney

Barney is a fabulous character. I had watched a few episodes because my son was watching the show, and I think that Barney was (more than anything else) the thing that made me want to watch the show. He was so cool. He was (and there’s no way to avoid saying this) “legen … wait for it … dary!”

 Time Travel

The device of having Ted telling the story to his kids gave the series a fabulous potential (which the writer exploited to the fullest) of time travel.

One example is that he was able to tell them that various girlfriends were NOT their mother. But he was also able to tell stories of near-misses with the mother, stuff about the umbrella, etc. It was great.

Another were the Rashomon elements in the story telling. In “Ted Mosby: Architect”, for example, Robin and Lily are hearing stories from various people of Ted seeming to act out of character.

Another was shown in “The Burning Beekeeper” where the same story is told again and again with different people filling in blanks from their perspectives.

Another was in the episode called “Dowisetrepla” where Marshall and Lily were shown saying this before Ted would say “is what he/she should have said” before showing what they actually said.

And then there was “We’re Not from Here” where Marshall and Lily write letters to each other to be opened upon the person’s death. But we jump far into the future to see one of them being opened.

And to further emphasise the time travel theme:

  • In “The Time Travelers” Ted and Barney get advice from their future selves!
  • Finally, in “The Window”, Marshall sends a letter to his future self and then future Marshall makes an appearance in the bar to arrange wings for his former self.

All in all, the time travel was one of the cleverest, funniest and most novel things on the show.

Very, very funny

The main thing to like about the show was that the writing was so clever and the show was so funny.

I don’t think there was an episode where I didn’t laugh out loud at some stage.

One of the funniest jokes, I think, was in “The Magician’s Code”. Lily was in hospital and in labour with Ted and Robin in the room when the following exchange happened:

Robin: That was not cool Ted.
Lily: Contraction!
Robin: That wasn’t cool Ted?

Genius!

In conclusion, HIMYM is a great series. I may even watch it again!

Reunited Apart

I guess some people realised that it might be possible to get big stars to do things using ZOOM during COVID which might have been difficult or impossible to get done during normal times.

And in so doing, to raise money for charity.

One such person was Josh Gad. He created a series of videos where he reunited the cast and crew of great movies such as The Goonies, Back to the Future, Splash, Lord of the Rings, Ghostbusters and Ferris Bueller’s Day Off.

Josh is a great host and his enthusiasm makes the shows a joy. I know most of the participants are actors but they seem to get genuine pleasure out of being reunited.

Here is my favourite of them:

Music and COVID and The Late Late Show

The Late Late Show did a great job during the early months of COVID. They educated and had a great focus on the front-line workers.

They also had lots of great musical guests and collected a huge amount of money for various charities.

Much credit to Ryan Tubridy and his team, and to Miriam O’Callaghan who stepped in when Ryan was hit with the virus.

Here are links to some of the great musical performances:

Hozier – The Parting Glass

Glen Hansard & Colm Mac Con Iomaire – Falling Slowly

Dermot Kennedy – All My Friends

Picture This – Troublemaker

Mary Black, Mary Coughlan, Frances Black & Sharon Shannon – A Woman’s Heart

Sinéad O’Connor – Thank You For Hearing Me

But the one that really blew my away was the appearance by Gavin James. I love his song “Always” and I didn’t realise that he was Irish!! He’s a superstar!

Music and COVID

Some nice things happened in relation to music over the period of the COVID lockdowns.

The first thing I remember was seeing people in Italy singing and playing instruments from their balconies.

Then people began to get creative about what could be done from home using technologies such as Zoom.

An early one was “True Colors – Camden Voices (self-isolation/virtual choir cover” from March.

In April Andrea Bocelli gave his “Music For Hope” performance live from Duomo di Milano.

In May we were treated to “RTÉ Concert Orchestra and Sibéal perform Mise Éire from home” and “Kodaline – Saving Grace ft the RTE Concert Orchestra, Dublin Gospel Choir“.

In June we got “No Frontiers | Mary Black and Friends in aid of Women’s Aid Ireland“.

But then came the most fabulous one of all.  I simply do not tire of listening to (and watching) “Irish Women In Harmony – Dreams”. Congratulations to RuthAnne who started the initiative, and to all of the women who participated. and it’s all in aid of Safe Ireland, who support domestic abuse victims and survivors.

Peter’s Programming Principles: Data-Driven

When I started programming, my focus was on writing code. But I learned that when you need to perform a series of actions, it’s best to drive that using data, which is interpreted by code. The data is easier to understand, and to change. It’s easier to show to business users if that is appropriate. And it’s easier to have code that acts in a robust and resilient manner with that data.

Example One

When I worked in Shield Life, I wrote a program which allowed external users to do terminal emulation onto the Wang VS minicomputer over a dial-up connection. The program had to do a series of actions to connect to the VS:

  • Interact with the modem and dial the appropriate phone number
  • Interact with the X.25 PAD if appropriate (this used by users around the country to avoid having to make long-distance phone calls)
  • Log in to the VS (we did not want to show the login screen to these users – instead we logged them in automatically)

Rather than coding all of this, I used DATA statements in BASIC. Here are some examples:

DATA “RETRIES”, 3, 3

DATA “SEND”, “AD~”

DATA “WAIT”, OK”, 6

DATA “DELAY”, 2

DATA “SEND”, “ADTP <number>~”

DATA “WAIT”, “CONNECT”, 60

DATA “IF”, “X.25”

etc.

This means:

  • Set the number of retries for the subsequent commands. This means that if the response which is required in a WAIT command is not received, that the preceding SEND command will be repeated up to 3 times. The statement also acts as a marker within the script. The second number indicates that the processing should return here up to 3 times if the smaller retry loops don’t get the desired result
  • Send AT followed by a carriage return to make sure that the modem is responding
  • Wait up to 6 seconds for a response of OK
  • Delay for 2 seconds
  • Send the dial command followed by the appropriate phone number and a carriage return to the modem
  • Wait up to 60 second for the modem to respond with a CONNECT message
  • The “IF” statement starts a block of commands which will only be used if the computer is configured to connect via the X.25 packet switching network

Having all of this in data, rather than code, meant that it was easier to tweak the commands to respond to changing needs.  Examples might be:

  • The data could be changed to work with different modems with different command sets.
  • Delays could be added between each character which is sent to suit systems which could not respond to data which is sent at full speed

Notes:

  • The data could have been held in a file rather than in DATA statements but by putting them inside the compiled program code we made it more difficult for people to see it and potentially tamper with it. A good solution, in fact, would be to check for the existence of such a file and then use it in preference to the DATA statements if one exists. This would allow you to troubleshoot and adapt when working on a client machine
  • On-site troubleshooting would be facilitated by having a secret series of keystrokes which would bring up a window which would show the commands which are being processed along with the data which is being sent and received

Example Two

When I worked in Lotus Development, we had a Lotus Notes application which  we used to receive and manage queries from customer helpdesks around EMEA. We wanted to add some workflows to this application so that it could send notifications, reminders, escalate  cases, etc. This was an early version of Lotus Notes where this couldn’t be done in the application itself (this was before scheduled agents) and would have to be done using the C API.

I could have designed the workflow and got some C developers to code it. Instead, I designed a workflow engine where you could define the workflow using documents in a Lotus Notes database, and then that workflow could run against our tracking application. But, of course, it could also be used to create workflows for ANY Lotus Notes application (and we had a huge number of them!)

So it was a bit like Microsoft Flow (Power Automate) but about 25 years earlier!

The first document in a set would define the schedule so you could have a workflow which would run every hour, day, week, or whatever was required.

The second document would define the set of documents which would be processed. This would normally be a specific “view” in a specific Lotus Notes database.

The remaining documents in the set would define the actions. Each action could have a formula which would be run against the documents – the action would only be executed if the formula returned true (this would like an “if”). And then  the action itself could do things like:

  • Sending an email
  • Updating the document
  • Adding a new (response) document
  • Copying or moving the document
  • Deleting the document

Basically I looked at the API documentation and I created an action for anything which as if it might be useful for creating a workflow.

There was also a flag on the action so you could tell the engine to skip on to the next document in the data set without processing any more actions for this document.

So I could have got the developers to hard-code a workflow for me, but instead I got them to develop a data-driven engine which could be used to create any workflow without the need to write something as complex and error-prone as C code.

 

 

 

Peter’s Programming Principles: Event-Driven

When I started reading computer programs, they were written in BASIC for personal computers such as the Apple II and the Commodore PET. They appeared in magazines or books.

When you wrote a program in BASIC, your code had complete control over the CPU from the time you entered the “RUN” command. Nothing could happen that was not under your control (if you ignore bugs!)

If you had an INPUT command, then your program would pause until the user typed something and pressed the Enter key. Then your program would resume on the next line.

For greater control, you would use the INKEY$ function so that you could see and process each character as it was typed.

So your code was “procedural”: it would do something, and then it would do something else, all under your complete control.

When Visual Basic came along, things changed. Suddenly you had a series of control on a screen, and each one of them had code attached to events.

This idea of having to respond to events as they happen in an unpredictable order is good. It means that, as a developer, you need to think about your user doing things in a sequence other than the one you were anticipating.

In his book “Getting Things Done, David Allen talks about something he learned in the martial arts which is being in a state of alertness and readiness which he refers to a “mind like water” (which he has apparently trademarked, believe it or not!)

I think this is a good image for programming – your code should be alert and ready to respond to whatever happens next. Your code should “let go”, and be ready to kick into action again then the user (or something else) completes an action. You should not presume what will happen next, and neither should your code.

Example One

I remember way back when Basic (probably Turbo Basic) introduced ON KEY and ON COM statements so that you could get code to run (a subroutine specifically) when  a specific key was pressed or when something arrived on the serial port.  This was exciting because you could have code that ran on an event automatically without you having to check for it specifically. So the user could press F1 for help (for example) or F10 to quit at any point within the lifetime of the program (while those keys were enabled).

Example Two

When writing a program in Visual Basic (back in the day) you would sometimes write a long-running piece of code. You might be processing every row in a database or a file, for example. If you wanted to update the User Interface (e.g. showing a progress bar) then you would need to call the DoEvents function periodically to yield so that Windows gets a chance to  do this.

VB.NET has a Application.DoEvents method for a similar purpose.

DoEvents is a reminder that your code is not the only important code on the computer and your code should be collaborative. Blocking is bad, yielding is good.

Example Three

I was working with  a developer way back on a program which transmitted data between two mini-computers, a development machine and a production machine. Sending a file involves a series of steps: receiving the instruction to send the file; sending the header; sending the data blocks; sending the trailer; updating the log.

I explained to the developer that the program on the development machine might be sending a file and fetching a file at the same time. So the program would need to check each block as it was received to see what it was and what to do with it.

Because she was thinking in a procedural way, she wrote the code to do all of the steps one after the other.

I had to help her to refactor it so that it had a central tight loop, and that loop would have to respond to its circumstances each time. It might have received some data from its peer; it might have clearance to transmit a new block; it might have received a new command from a user; or it might be able to execute the next command from its queue.

This flexibility was needed. When the program finished receiving a file, for example,  it would move it to the designated location, potentially replacing an existing file. If that file was in use, then the move would fail, and would have to be retried. If the code was determined to perform that operation right away, and was unable to do anything else while waiting to do so, then the exchange of files would be halted for minutes or even hours!

So a central loop with an awareness of what was happening with various requests, and what was waiting in the queue, was essential to the correct operation of that system.

Example Four

When you write code for Arduino (a “sketch”), you get to write a “setup” function and a “loop” function. The former is called once, and the latter is called repeatedly.

Writing code in Processing or p5.js works in the same way, except that the function which is called repeatedly is called “draw”.

When you are writing a loop or draw function, you should do what you need to do right now and then finish, confident in the knowledge that you will be called again in a moment. And by yielding in this manner, you give the CPU a change to do other housekeeping tasks.

When the loop restarts, your code must be able to resume and do the next thing.

When I wanted to add graphics to my COVID program for the MXCHIP,  I downloaded a library which included a sample program which created an animation using graphics commands.

I was shocked to see that the “loop” function included a “while (1)” statement. You can see the program here.

I was surprised to see that the programmer did not respect the need to yield at the end of each loop. I refactored it to do this and it worked just as well.

Example Five

When writing my COVID program, I had to decide what I would do in the setup function, and what I would do in the loop.

At one stage I was doing the HTTP GET functions to get the up-to-date COVID statistics from the REST API. But I moved these to the loop and I used a variable called “init” to track where I was in the step for initialisation. When init is 1, I get the data for Ireland. When it is 2 I get the data for the USA. I do one thing each time loop is called and I increment the init variable. When I have completed the initialisation, I set init to 0 and I can respond to button presses during each subsequent pass through loop.

The great thing about this is that if the user presses the two buttons simultaneously, I just set init back to 1 and the fetching of data starts all over again. So not only is being flexible good, but it had an immediate benefits when I wanted to do something new.

Conclusion

It is important to get away from procedural thinking, to write code which is fluid and flexible, to avoid thinking that you have completed control over the CPU, the network, etc., and to avoid making assumptions about what is going to happen next.

As Bruce Lee said:

Empty your mind. Be formless, shapeless, like water.

 

Peter’s Programming Principles: Layering

Test-driven development (TDD) is very popular at the moment. The basic idea is to code a series of test all of which fail, and then address the failures.

My approach is also incremental, but works in the opposite way. I like to get something working, and then add something else and get that working, and keep adding layers until the code does what is required.

It’s basically a cycle of write, test, fix, write, test, etc.

But the idea is that you are adding layers of functionality, and building on success.

Some of the additions are so simple that they SHOULD work fine, but I just do them and verify that they do.

The opposite approach would be to write a large amount of code and then test and debug it. But if we did that, the bug could be ANYWHERE!

When I started programming we were writing batch programs, and we had limited time on terminals. So we would write the code at our desks, and then get access to a terminal to enter it. Then we would run it (or get an Operator to run it for us) and we would take the output (report) back to our desks to debug.

That approach make no sense these days now that we have IDEs, debuggers, etc.

I should point out that I don’t think anyone else refers to this as “layering”, but for me the word conveys the idea of building layers of functionality which are demonstrably working.

Example

The COVID program holds 14 statistics for 3 counties plus the same for the world. It displays these statistics on six screens which the user can scroll though.  But as I built it up, at one stage it was able to hold and display three statistics for one country.  And before that it was able to display the raw results from a HTTP request. And before that, it was just able to display that it had managed to make a Wi-Fi connection to the router.

Conclusion

It is either arrogant or foolhardy to think that you can write substantial amounts of bug-free code. The best approach is to write small incremental pieces of functionality, proving that it is working correctly each step along the way

« Older posts Newer posts »

© 2024 Peter's Blog

Theme by Anders NorénUp ↑