Sunday, February 14, 2016

Delphi at 21, an era

Today marks an interesting day. As the title suggests, today is year 21 since the public announcement of Delphi. At the Software Development West conference in San Francisco, California, I remember sitting in the audience as I watched my colleague, Anders Hejlsberg, demonstrate the new Object Pascal based development tool.

I remember the run-up to the introduction and the building hype. As I was cleaning out my office this weekend, I came across a reprint of a column from Windows Tech Journal written by J.D. Hidebrand simply gushing about how Delphi "..is going to change our lives". I also have my still sealed Delphi 1 box with the much coveted "First Ship" sticker.

I sat there among the standing-room-only crowd, next to my wife (now of more than 27 years) having convinced her that visiting a veritable geek-fest was more important than a nice Valentine's day dinner, finally seeing all those long days and weekends coming to fruition. I watched as Anders worked through the demonstration script which was punctuated with various "Oooo's" and "Ahhh's" and even various gasps of disbelief at what they just saw.

Finally Anders got to a portion of the demonstration that was particularly harrowing for me personally. He was about to demonstrate a feature of the Delphi language and runtime that, until that point, no other tool or framework I'm aware of could accomplish. He drops a button onto a form, double clicks the button and proceeds to enter code very similar to this:
procedure TForm1.Button1Click(Sender: TObject);
var  
P: ^Byte;
begin
  P := nil;
  P^ := 1;
end;

You see, I was the one responsible for the getting the language exception system hooked into the hardware exceptions such that CPU-generated errors or exceptions would map onto specific language exceptions. Under Windows 3.1, the OS didn't have any concept of exceptions. It wasn't until Windows 32bit that exceptions were defined as part of the OS. Delphi 1 did it's own stack unwinding and handler searching.

As I watched this drama unfold (hey! this is my story and I can tell it with as much flourish and flair as I wish), I could feel my face flush and little beads of sweat form on my forehead. As I witnessed a critical piece of code that I wrote get exercised in front of thousands of like-minded developers and self-avowed geeks, I held my breath. Anders deftly explained to the enrapt crowd that unlike other development tools out there, dereferencing a nil (or NULL for you C/C++ folks) pointer was considered strictly verboten and downright deadly to the continued execution of an application.

Remember the dreaded "General Protection Fault" error? Because of the way memory was handled in Windows 3.1, this not only took down the offending application, it could also adversely destabilize other applications or even the entire OS. The crowd saw the implications of the above code and watched as Anders pressed the run button. The application popped up with a single button on the form. A hush fell over the crowd as the mouse cursor displayed on the large projection screen drifted over toward the button marked with the ubiquitous "Button1" caption. The button visually changed indicating that Anders had pressed the button on the mouse.

Just as the button was released, the "OnClick" event is fired and the above code is then executed. Suddenly a dialog pops up on the screen with those dreaded words, "General Protection Fault". There was a slight pause as Anders points out that he is able to now dismiss the dialog and yet the application is still running without any apparent (nor actual) negative effects. He then presses the button again, revealing the same dialog. The crowd breaks out into thunderous applause. I see a few folks stand up here and there throughout the crowd which quickly spread to a few more and then more. Within moments the whole meeting hall was filled with thousands of standing, clapping, whistling and hollering people.

To this very day, my wife has never let me live down the fact that she spent that Valentine's day there instead of having a quiet, intimate evening with a nice dinner and maybe a movie. I don't think she was very impressed.