Friday, October 19, 2007

"Can you recommend any C++ books?"
"I don't recommend C++."

Afterwards I reluctantly come up with some names. I beginning to notice that I eventually end up mentioning the Scott Meyers "Effective C++" books. The last time I did this I started to wonder why I say this?

When I first read "Effective C++" I was horrified. If I derived any pleasure out of it, it was comparable to the morbid curiosity of going to witness an execution (I probably would not do that though, if I ever got such a chance. I don't have the stomach for it). Back to C++ - Firstly there was no way I was going remember all of that. Secondly I felt deeply uncomfortable. In time I realized that the whole book was written in the style of demonstrating "effective" usages of C++, while what it truly was is a careful documentation of the flaws of the language. Every chapter in that book talks of a language flaw in excruciating detail and how to live with it. That book should have been called "Defective C++".

Then there was "More Effective C++" which essentially did more of the same.  Here is what the language does, here is what you think it would do, here is what you'd like it to do and you put these together and it blows up in your face. In time, my intellectual immune system kicked in and started erasing most of my memories about all this.

So why do I recommend the "Defective" and "More Defective" books? My first recommendation would be to get out of the situation, don't deal with the language if that's possible. If not, and you intend to get it to serve you (instead of the converse) you need to quickly understand that most of the abstractions it provides are leaky. There are hardly any non-leaky abstractions that C++-land provides. (Some people associate this behavior with some notion of "freedom" - I trust evolution will take of those folk.)

So if your abstractions are leaky, in that they are going to have strange interactions with each other under-the-hood, then you should quickly start developing an understanding of what happens under the abstractions you are given. Your effectiveness as a developer becomes proportional to your understanding of what happens under the surface. Hence the "defective" C++ books are a useful read.

Friday, October 19, 2007 12:05:29 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
 Tuesday, October 16, 2007

Today Aziz mailed me a build of his Ikarus compiler for Windows. Though I don't have much to do with software as such these days, I was excited. Ikarus is Aziz's Scheme Compiler. I use Petite Chez Scheme on my machine. Petite  is Kent Dybvig's Scheme interpreter, part of the Chez Scheme compiler system. I don't have Chez Scheme itself because it sells, I am told, for several thousands of dollars and hence I cant afford it. I expect Ikarus to be comparable to full Chez in many ways and surpass most other Scheme systems out there.

What Aziz sent me was a zip file that extracted to a 128k exe and 4mb "boot" file. He says the boot file says the same between windows, linux and mac. The bootstrap executable changes. This is amusing because the "boot" file is actually the compiler binary. It contains the compiled x86 code.  He able to get away with this because he only relies on the OS to load his little bootstrap exe. After that point he simply allocates memory pages from the OS and relies on the OS for almost nothing that he can do himself. So the exe loads the boot file into memory which then acts as its own loader, sets up its own stack, lays out its own code and data areas, does its own GC and such.

Of course, all of this is written in Scheme itself. There is probably a small C file somewhere that acts as the main() and the initial call into some ASM code that transfers control to Scheme. Fun fun.

I have talked to Aziz about many parts of this system and almost always the design has seemed to be of very high quality. His management of code objects, the runtime stack, continuations and on and on. The system has a large part of R6RS implemented and is already a superset of R5RS as far as I understand. Depending on how the development process stabilizes (after all, this is all one persons implementation), I might move over Ikarus altogether and maybe use it exclusively. 

Tuesday, October 16, 2007 10:49:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
 Thursday, October 11, 2007

Joan Baez, 1966, singing Dylan's "With God on Our Side".

Thursday, October 11, 2007 1:37:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 
 Wednesday, October 10, 2007

After being relatively upset about Parzania, I found myself at the RSS community page on Orkut. Needless to say, that was even more disturbing. It was without a certain amount of morbid horror that I looked at their polls, their organized report-as-fraud activities, their cyber-lynchings and such.

I usually don't like to deal with this sort of thing. I am complacent, cowardly and comfortable in my relative safety. It bothered me to think that if I had no fear it would be dishonest, or just plain stupid.

I happened to look at my blog and saw Star Trek and the Q next to Parzania, it struck me what the Q might say about India and the RSS. "Your species is always suffering and dying", he would say in his How-entertaining--What-do-you-expect-anyway attitude.

And indeed, what do I expect? The world has always been a barbaric place. We express surprise and shock at the slaughter of Delhi by Nadir Shah, the slaughter of the Sikhs after the assassination of Indira Ghandhi, the India-Pakistan partition riots, the Bombay bomb blasts, the Ghodhra riots, (and hardly just India) the Khmer Rouge regime of Cambodia, the Rape of Nanking, the Hutu-Tutsi conflict, the occupation of Iraq, the massacre of the Algerians... and on and on and on. Just too many to list. In fact so many, that one should ask, what's the big deal? This is, after all, human nature.

People have been always mercilessly wiping out entire populations of "others" based on some definition of identity. Why are we so surprised by this? Why do we expect that in the times of our generation the world should have magically become a "civilized place"? Hardly, if you look at the evidence.

It will be a long time before we turn into a species that is not always suffering and dying. Something truly deep and fundamental has to change about us for that.

In the short term however, in a few hundred years or maybe in our own lifetimes, the vices of our day shall blow away to be replaced by other ones. To make any of them to go away, something fundamental needs to change that invalidates their cause of existence. A little like the way Frown Power and Superman destroyed the Ku Klux Klan, might there be an Indian equivalent? Prosperity? Accountability? Can we motivate such a change?

Q: Let us pray, for understanding and for compassion.
Capt. Picard: Let us do no such damn thing! What is this need of yours for costumes, Q? Have you no identity of your own?
Q: I come in search of the truth.
Capt. Picard: You come in search of what humanity is!
Q: I *forgive* your blasphemy!

Wednesday, October 10, 2007 10:24:12 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]  | 

I watched Rahul Dolakia and David Donihue's Parzania today.

I don't feel like describing the quality of the production in any way. For a film like this, it doesn't matter. I don't want to use my own words. Gujarat : Lengthening Shadows Of Swastika :

Gujarat carnage was very different from the communal violence which took place in Independent India so far. Here one could most clearly see the well planned violence unleashed on the pretext of Godhra train accident, duly supported by the state Government under the patronizing eye of the central government. While every possible rule of the law was violated by the authorities, the hapless victims were left to rot in the refugee camps with atrocious living conditions, totally ignored by the state government. The mirror of Gujarat's dominant social thinking was to come to light soon with the winning of elections by Narendra Modi, who had played central role in the violence. What has been happening in the social milieu of Gujarat is beyond belief as far as the democratic norms and the communal amity is concerned.

This film left me angry and with a distantly familiar feeling of helplessness at the destiny of my country. A country whose several thousand year old deep rotting "culture" fills me with disgust; a deep disgust and shame at its lethargy and pretentiousness; at its devices for breeding contempt and entrapment.

What bothers me the most is that I am sure these things will happen again. Every bit of my intuition tells me so, and I am helpless to do anything about it. With no accountability, no information, I cant see how to instigate any lasting change. How do you bring accountability to a country like ours?

Wednesday, October 10, 2007 5:55:47 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2]  | 

Did I ever mention that I have always been a die hard Star Trek fan? I havent watched any of the Star Trek series as much as the Next Generation, so my admiration of Star Trek is largely limited to the Next Generation. I got up today morning and with some ado I decided to look at the notes for a test I have about Computational Complexity. I hate exams where I actually have to look at the notes for any non-trivial reason. Even worse, I hate subjects that make me need to look at the notes when I really shouldn't have to, had my love for the subject been left undistrubed. Irritating.

This reminded me of the "human equation" from one of my favourite Star Trek episodes, "Hide and Q":

Data: "Sir, how is it that Q can handle time and space so well, and us so badly?"
Picard: "Perhaps one day we will discover that space and time are simpler than the human equation."

Googling for this, I came across Q saying: "Your species is always suffering and dying".

This considerably cheered me up. Ok, back to the notes. (Later addition: if you want to read a nice spoiler about the episode go here. Please read it only for memory sakes, dont read it if you havent watched it already. Ok, now back to my notes).

Wednesday, October 10, 2007 8:46:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 
 Wednesday, October 03, 2007

One of the things I have a hard time truly internalising is the difference between existentials and universals (written sometimes as exists and forall). They have a very strange relationship and its hard to maintain the intuitions about what each of them mean, other than in the most obvious of interpretations. I remember Prof Mike Dunn, who is a renovned logician and was the Dean of the School of Informatics, in his classes on Galois logics would say that he keeps mixing them up because they are duals of each other.

One area where these crop up and innevitably confuses me is in type theory, especially when looking at the types of continuations. Its at times like this Prof Sabry would saying something mystical sounding, in true sufi style, which will leave me with a little flashlight to use in the darkness.

So some intuitions. What is a universal? Consider the function "head" that takes a list and returns the first element of the list. The function does not concern itself with the types of the quantities in the list, it only cares about the list itself.

So "head" has the type: forall x. List x -> x

(Functions like this may show up when programming with generics (or templates) in some languages. You are free to make these connections, I wont make them here.)

What is the type of head saying? It says that it doesnt care about the underlying type of elements in the list. It only cares about the fact that these elements are in a list. So when head is invoked with a list of integers, "List Int", it returns an integer, "Int". When called with "List String", it returns "String". When called with "List (List Int)" it returns "List String". You get the idea. The "idea" should have two parts (1) "head" is concerned about the fact that it gets an abstract List. (2) There is nothing, no code, inside "head" that depends in anyway on the type of the contents of the list. If head is called with a "List Int" it cannot return an integer that it had hidden off in a variable. It can produce an "Int" only by looking into the List. Why? Beacuse head did not know that its argument would be a list of "Int".

In other words the "forall" says that "head" is truly independant of the type "x". It can manipulate the List, but it can't manipulate the "x". Its is "pure" with respect to "x". The "x" in the List is abstracted away from it. Having a function that is forall quantified is different from having several functions, one for each datatype that you have in your system, because of two reasons (1) There can be an infinite number of data types, which means you will have to have an infinite number of such functions (2) Each such function is for a specific type, "List Int -> Int", and hence knows that it need not ever look into the List but can return any Int to you to satisfy its type; in other words each such function is not "pure" wrt the type of the elements of the list.

Wednesday, October 03, 2007 5:37:27 PM (Eastern Standard Time, UTC-05:00)  #    Comments [1]  | 
 Sunday, September 30, 2007

I came across this on the blog of an old friend Sriram Krishnan. Sriram goes onto give some colorful instances of Dave Cutler, the Windows guru who is the recipient of the award. To put some of this in context, Dave Cutler is considered a brilliant engineer, among the best Microsoft has ever seen - which easily places him among the best anywhere in the world.

Being several steps removed from Microsoft and the community of grace that envelopes it, these days I tend to see things with less rosy shades. If it is indeed true that Dave Cutler is as brilliant an engineer as he is touted to be, if he could have the genius to make design decisions about the NT system in the early 90s that are still revealing their mettle, then why is he being given a "Bill Gates" award? Wouldn't it be more fitting to give Bill Gates a Dave Cutler award? After all Bill Gates, to the best of my knowledge, has never been credited with impecable design that has withstood the test of time, the way Dave Cutler is often described, though he has deisgned systems that have had a huge impact on the future of Microsoft.

In the Computer Science community, the highest award of recognition is the Turing award. The award carries the name of one of the most foundational thinkers of our times, Alan M Turing, and is, in part, a community's recognition of the towering intellect of a man who was among their very best.

The true qualities that Bill Gates deserves to be applauded for, amongst which is being a buiseness-savy geek at a time when such a notion didn't exist, is in a different domain altogether from the strengths of Cutler. Maybe the Bill Gates award is just a name for "Microsoft's Best" award, in which case maybe Gates himself should have got the first one. Otherwise it feels like handing Tagore a Nobel prize for Physics.

Sunday, September 30, 2007 10:10:29 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2]  |