Monday, February 02, 2009

Technology Notes Vol 1, Issue 8: Lessons at work and play

This edition of Technology notes is dedicated to some lessons I learnt at work and at play.

* Conceptual Abstractions

If I were to stick my neck out on things I don’t fully understand, I’d do so and say that Abstraction and Recursion are the most fundamental principles in Computer Science. There is something magical about the way these two concepts solve so many problems that we encounter 'in code’. In fact, in the OO design community, “an additional layer of abstraction” is almost a silver bullet for most design problems.

In the last month though, I got first-hand exposure to some conceptual abstractions. In my definition, a conceptual abstraction is one that solves a complete class of problems while trying to solve a single instance of the class. Let me give an example. Over the last year or so, I have been working on a tool that uses some modified IR techniques to solve a problem faced by developers in our organization. We read some algorithms, coded them up, created a service abstraction for folks to use, and made it available to our user community. We decided to publish this work, and I had detailed discussions with my manager and Sriram Rajamani, who is a principal researcher in our organization. In the space of a few hours, we (truth be told, they) created a conceptual framework around our tool, in such a manner that we solved the general IR problem for our problem space! I wish I could write more about it, but I’ll have to defer it till we submit the paper.

* The beauty of Windows

When I got my first PC, nearly 14 years ago, one of the games I loved playing was Xargon, a 1993 game created for DOS. I couldn’t afford to buy the game, so I played a shareware version that was available on a PCQuest CD. 15 years and five OSes later (Win3.1, Win95, Win98, Windows ME, Windows 2000, Windows XP)  I installed the now-free retail version of the game on my XP box, and lo-and-behold, it worked! I had a few problems with the sound card which I was able to fix by some minor changes to the game’s default settings. I don’t think any company makes software that preserves backward compatibility to such an extent. In a world where different versions of Linux are not compatible, where Mac software bought two years ago for the 68x processors won’t work properly on the new Macs, the extent to which Windows preserves backward compatibility is amazing. You can read the 68 posts Raymond Chen has about it here.

* The best feature of Java

The one feature of Java I miss in C#/.NET is that of checked exceptions. You know, you declare a function as

public static void X( ) throws A, B, C

and the function can only throw A, B or C. Clients of this function must handle these exceptions or declare them in their “throws” clause. Further, if a derived class overrides a base class method, it can only throw a subset of the exceptions that the base class method has declared in its “throws” clause. Not only is this a great example of documentation enforced by the compiler, what this also does is takes Java one step closer to the ideal of LSP (Liskov Substitution Principle).

(PS: C++ fanatics will now argue that it too has a “throw” clause. All I’ll say is “don’t use it”.)