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”.)

5 comments:

Prashanth said...

Mac CPU compatibility is not entirely true. At least at the application layer, there is an excellent PowerPC arch emulator called Rosetta that shipped with OS X Tiger. Also, most software immediately started shipping with universal binaries. The only software I have seen that had incompatibilities on the Mac was Onyx - a system maintenance program. This is also understandable because it probably depends upon the OS's internals for its functioning.

Balbir said...

Please don't make comments that Linux application software is not compatible, Linus will kill you. It is and we make every effort to make sure things don't break. Linus in fact mentioned that he was able to run an old application from his initial Linux days, even today. The kernel is good and fine, but libraries change and break ABI from time to time. You should be able to get the old library and get everything working.

BTW, Windows broke compatibility, hint XP SP2 (forcing applications to change) and with Windows 7 64 bit beta, I see loads of compatibility issues. Having said that Windows 7 is not all that bad, in fact I am beginning to like it very much.

Gops said...
This comment has been removed by the author.
Gops said...

Ballu, Linus can try to kill me (or he can send a henchman - you?) for that, :) but you are admitting yourself that that the libraries break the ABI from time to time - well, there you go. As I mentioned over the phone yest, app compat is a major concern for Windows, and MS goes to great lengths to preserve it. My experience was just an illustration of that.

Win7 is still in Beta. Let's wait for the full version. In any case, my story stops with XP SP3. :) :)

Prashanth, well, that isn't completely true. Rosetta had a major performance penalty - my cousin's hubby who swears by Photoshop on the Mac (despite all my attempts) had a tough time with it. Many games didn't work for quite a while too. Further, it is also a matter of ideology - putting the burden of app compat on the vendors instead of taking it on the platform. Don't get me wrong - I'm not saying one is necessarily better than the other, just saying that there is a difference in ideology, and that I love the fact that a 1993 DOS game works seamlessly on a 2009 XP (SP3) system.

Anonymous said...

Insightful!