Archive for 2006

[2006-12-27] Utterly Disgusting

It is utterly disgusting that Microsoft so readily bends over backwards to please the immensely greedy folks from the entertainment industry.

For example:

(Originally posted on Blogspot.)

[2006-12-25] On The One Hand

On the one hand, a cute baby...

(Originally posted on Blogspot.)

[2006-12-21] “LtU Books” In India

There are some books on computer science that I had never heard of until I had started reading "Lambda the Ultimate" (LtU). I found these books being mentioned and recommended in various posts and forum topics on LtU from time to time. As I found out more about these books, I became interested in reading them. Since they were relatively obscure, I had no hopes of finding them here in India. The prospect of having to fork out hefty sums of money for buying the books via something like Amazon.com made me apply the brakes on my normal impulse of buying an interesting book when I come across it.

Imagine my delight then, when I stumbled upon the fact that all of these books had an Indian reprint available at an extremely affordable price. Incidentally, all of these books were originally published by MIT Press and the Indian reprints are published by Prentice-Hall of India.

Here are the "LtU Books" along with the ISBNs of their Indian reprints and the corresponding price:

  1. "Types and Programming Languages" by Benjamin Pierce, ISBN: 81-203-2462-5, 350 rupees.
  2. "Concepts, Techniques, and Models of Computer Programming" by Peter Van Roy and Seif Haridi, ISBN: 81-203-2685-7, 450 rupees.
  3. "How to Design Programs" by Matthias Felleisen, Robert Bruce Findler, Matthew Flatt and Shriram Krishnamurthi, ISBN: 81-203-2461-7, 325 rupees.
  4. "Advanced Topics in Types and Programming Languages" by Benjamin Pierce, ISBN: 81-203-2792-6, 425 rupees.
  5. "The Elements of Computing Systems" by Noam Nisan and Shimon Schocken, ISBN: 81-203-2885-X, 195 rupees.
If you are not able to get these books in a local book store in your city, you can order them directly via the web site of Prentice-Hall of India. If you stay in Bangalore, you can also contact Suman M. (msuman AT phindia DOT com) to obtain these books directly from Prentice-Hall.

(Originally posted on Blogspot.)

[2006-12-14] Articles by Dheeraj Sanghi

Dheeraj Sanghi is a professor in the Computer Science and Engineering (CSE) department at IIT Kanpur. Our batch, the CSE class of 1996, studied "Computer Networks" under him and he was an active patron of the Association of Computer Activities (ACA).

Recently I stumbled upon a collection of his articles on various topics, including career counselling for students who want to study CS in India, improvements to the undergraduate programme in IIT Kanpur, views on the recent move by the Indian government to impose quotas in the IITs, etc.

Though I found myself disagreeing with some of his points, I found these articles quite interesting as they touch upon topics that I have been thinking about in recent times.

(Originally posted on Blogspot.)

[2006-12-11] Dhoom 2

Go and watch Dhoom 2 if you haven't already. You get to see from two to four hot bodies (depending on your inclination) and some of the best stunts seen in Hindi cinema.

Besides that, try not be disappointed by the script (such as there is) comprising utterly inane dialogues, the plot (such as there is) comprising completely illogical turn of events, the skill of the actors (such as there is) that makes a chiselled wooden statue look more expressive, the fact that the character played by Uday Chopra is not killed off in this film either, the tendency of every actor in this film to walk or run in slow motion, the unnecessarily numerous and forgettable songs (except for the title song), etc.

See also: VikGup's hilarious review of Dhoom 2.

(Originally posted on Blogspot.)

[2006-12-07] “The Elephants of Style”

“The Elephants of Style” by Bill Walsh is a style guide for written English. The title is a play on the title of that classic book on style by Strunk and White, “The Elements of Style”.

Read More...

[2006-12-05] Bumper Sticker

On the way to work this morning I saw a rather dilapidated car sporting this bumper sticker:

!! CAUTION !!
My Senseless Driving
May Fear You

I found this rather funny in more ways than one.

(Originally posted on Blogspot.)

[2006-11-27] Website Versus Weblog

Now that I have my own weblog, the “News” items on this website are simply about updates to the website. For example, newly-added articles or book reviews, software releases, website redesign or restructuring, etc. are announced via “News” items on this website, while my usually inane ramblings on sundry topics appear as posts on my weblog.

[2006-11-27] FOSS.IN/2006: Impressions

FOSS.IN/2006 is over. This year the event was held in the J. N. Tata Auditorium complex of IISc, Bangalore. This meant that we had much better seating arrangements and acoustics compared to last year, though some of the halls were awfully musty and for some reason the airconditioner in every hall was set to too low a temperature for my comfort. The food was much better than what was there last year and there were enough pure water dispensers to quench everyone's thirst throughout the day every day.

The scale of the event however was much smaller this year compared to last year. It was held for just three days instead of four days as in last year and there were just five simultaneous talks through the day instead of six as in last year. While many of the American hackers chose to skip the event this year due to its unfortunate overlap with the Thanksgiving weekend, I don't know what would explain the much lower turnout of Indian delegates and exhibitors.

I didn't find that many interesting talks this year so it was a bit depressing for me. In addition, there were many a glaring error in a couple of talks that I attended. Among the talks that I did like were the ones by Christof Wittig and Russell Nelson on the first day, the one by Aaron Seigo on the second day and the one by Tim Pritlove on the third day.

In a talk on OpenAlchemy, I asked why anyone in India should buy an Amida Simputer when it has a bulky form factor and is more expensive than a Palm Tungsten E2 which at first blush seems to have many a desirable feature and looks far more polished. Another member of the audience asked where it stands now that the OLPC project is here. I wasn't happy with the answers provided for either of these questions.

(Originally posted on Blogspot.)

[2006-11-17] New York, Philadelphia and Boston

In the last week of my recent US trip, Anusha and I tried to cover the cities of Philadelphia, New York and Boston. When the time for travelling between these cities is factored in, we had almost no time to see any of these cities properly. The weird policy of the hotels in the US to have check-in after 4 PM and check-out by 12 noon made the problem worse. It also didn't help that the sun used to set around 5 PM.

We spent about 2 and a half days in New York while staying in New Jersey and we still managed to visit five families of our relatives, meet Saikat and Kalpana and see some of the most famous tourist attractions in New York.

Hotel accommodation in New York, especially Manhattan, seems insanely expensive, even for the hotels with only the most basic of amenities. Ditto for car rentals and parking charges. Fortunately for us, decent hotels in New Jersey are somewhat more affordable and there are excellent public transportation options for shuttling between NJ and NYC. As a matter of fact, we stayed in a hotel in Jersey City that was a five minute walk from the Journal Square PATH train station. PATH trains were numerous and frequent throughout the day and took us into the heart of Manhattan in 20 minutes. Within New York, the excellent subway system made travelling within the city relatively painless.

Visiting the Statue of Liberty and the Empire State Building took half a day each because of the number of tourists and the elaborate security procedures. The view of New York City from atop the Empire State Building was very nice and the audio tour by "Tony, the cab driver" was quite useful for an utter newbie to the city. By the way, I didn't know that the Statue of Liberty was made out of copper sheets and the green colour was due to the usual patination of copper.

12x Optical Zoom is Cool

Central Park was quite impressive with its lush greenery and peace right in the middle of Manhattan. Actually it was amazing just how many parks there were in Manhattan itself. The Grand Central Station was simply awesome for a train station. The New York Public Library was fairly impressive as well. Times Square in the night was just as they show on TV and in the movies but for some reason it had just a lukewarm effect on me. The site where the twin towers of the WTC stood seemed big and eerily empty. Walking on the Brooklyn Bridge was a charming experience. It was nice walking around in Manhattan soaking in the sights of the city and gaping at the numerous skyscrapers.

We didn't get time to watch a Broadway show or visit any of the famous museums. In a city with more than 13,000 restaurants offering the most varied cuisines in the world, we were mostly so pressed for time that we used to just grab a quick bite in a fast food joint. Some day I hope to come back to this city and stay for at least a week or more.

We were not able to see much in Philadelphia due to a lack of time and Boston was only slightly better. In Boston, our misfortune was compounded by the long-term renovations being carried out at the sites of the Boston Tea Party and the Bunker Hill Monument. As if that was not enough, it was also raining persistently throughout the first half of the day we had set aside to see the city. We still managed to follow some of the Freedom Trail, see the USS Constitution and explore Quincy Market, Faneuil Hall, etc.

(Originally posted on Blogspot.)

[2006-11-15] Las Vegas

Anusha joined me on the second weekend of my recent US trip for a visit to Las Vegas along with VikGup and Pooja, who took turns to drive all the way. It took us about 10 hours each way with a break or two and that meant that we had just a little over 24 hours to spend in Vegas.

The glitz and glamour of Vegas was unlike anything I had seen before. It was particularly striking after having driven through hours of arid and dreary landscape. The sheer display of wealth and beauty has to be seen to be appreciated. It also becomes very obvious, very fast, how this city earned the moniker "Sin City".

We hopped from hotel to hotel checking out the attractions on display. It was amazing to see so much money and effort spent on recreating the landmarks of Paris, New York, Venice, etc. We didn't gamble much and I even managed to make a tiny profit. One of the most memorable part of this trip for me was watching the show "O" by Cirque du Soleil at The Bellagio.

Anusha checking out a slot machine

(Originally posted on Blogspot.)

[2006-11-09] FOSS.IN/2006 Registration and List of Talks

You can now register as a delegate for FOSS.IN/2006. The final list of talks for FOSS.IN/2006 has also been released.

(Originally posted on Blogspot.)

[2006-11-09] “The Best of Rumpole”

“The Best of Rumpole” is a collection of seven Rumpole stories personally selected by the author John Mortimer and considered by him to be the best among those he has written so far.

Read More...

[2006-11-08] “Canon Rock” by Jeong-Hyun Lim (“Funtwo”)

It has apparently been a rage on the Internet for some time now, but only recently have I come across the cover version of "Canon Rock" played by "Funtwo". The original version was arranged and played by "JerryC".

(Originally posted on Blogspot.)

[2006-10-23] Fry’s

Ryan and I went to the Fry's store in Sunnyvale yesterday. Our original plan was to spend about half an hour there, move on to the DSW store in Milpitas and then to San Francisco - we ended up spending about 6 hours just in Fry's!

To a bumpkin coming from India, Fry's is just incredibly big and has an amazing variety of items. The very idea of being able to take a shopping cart through aisles upon aisles of hardware components and picking up just the right components to build my dream computer would have been enough to make me wet my pants in my days as an avid gamer. I am sure that electronics enthusiasts back home would have a similar feeling if they see how easily they can get all sorts of electronic components and related hardware in this store. Awesome!

If I were younger, I would have filled my cart with all sorts of cool stuff, including the Lego Mindstorms NXT robotics kit. I did not because I realise that I would simply not have the time to play with all that cool stuff and it would therefore just be a waste of money. Sad.

(Originally posted on Blogspot.)

[2006-10-22] US of A

I have been in the US of A (Redwood City, California) for a little over two weeks now.

This is only my second visit to the US. I was in Edison (New Jersey) for a week about five years ago. For a number of reasons, I was miserable during my stay the last time around. I was suffering from jet lag for much of my stay - I wasn't able to sleep till about 4AM every day, but then had to get up by 7AM to get ready and go to work only to find myself groggy throughout the day. I used to accumulate so much static electricity so rapidly that I used to be shocked by touching almost anything - door knobs, car doors, coffee machines, humans, etc. - and would remain jumpy throughout the day. Even though the hotel that I stayed in was close to my workplace, I couldn't actually walk there and had to always depend on someone to pick me up, take me out for lunch and dinner and drop me back. But for some of my extremely helpful and accommodating colleagues, I would have had a terrible time. Since I stayed for such a short time, I also didn't get to go around and see places.

This time it's much better. My jet lag was less severe and I got over it pretty quickly. The weather is warm and really pleasant most of the time. The hotel that I stay in is a bit further from my workplace compared to the last visit, but there are very nice pedestrian sidewalks and
the path is surrounded by beautiful grass, trees and lakes. There is a supermarket, a bunch of restaurants and other shops very close to the hotel (but for some strange reason, every restaurant and shop in this area closes by 8:30PM - only the supermarket remains open till 11PM). There is good public transportation available here and the nearest Caltrain station (San Carlos) is just about a mile from my hotel. Finally, many of my friends live in this nook of the world, though I've only been able to meet Ananth, Yumpee and VikGup so far.

On the weekends, I've been able to see San Francisco and Las Vegas but both of them merit separate posts.

(Originally posted on Blogspot.)

[2006-10-22] San Francisco

I spent the first weekend of my current trip exploring the city of San Francisco, first with VikGup and Pooja and then with Ananth and Surabhi. I will also be going to the city almost every day this weekend and the whole of next week, but I do not expect to have much time that I can spend exploring the city (which is a shame since I have really liked what I have seen of this city so far).

One of the first things that I noticed about this city was its diversity - there are so many people of so many ethnicities that it seems to be about as cosmopolitan as any city can possibly get. The next thing I noticed was the ruckus created by motorcycle riders (mostly riding Harley-Davidsons) almost everywhere. Finally, I really didn't expect the city to be so small!

I was with VikGup and Pooja for some time on the first day and then I walked around The Embarcadero, visited Fisherman's Wharf, Market Street, Chinatown, etc.

The next day with Ananth and Surabhi, I saw the Golden Gate bridge, visited Haight-Ashbury and the Amoeba store, ate at Massawa (an Ethiopian restaurant) on Haight street, indulged in the creations of Ghiradelli, went up the steep roads of Russian Hill and down the hairpin bends of Lombard Street, etc.

A charming city. I wish I were able to explore it properly.

(Originally posted on Blogspot.)

[2006-09-27] ICFPC 2006: Epilogue

The results of the ICFP contest for 2006 are now available. "Team Smartass" came first, followed by "kuma-" and "You Can't Spell Awesome Without ASM" in the second and third places respectively. Amazingly, the lone hacker "Witrala" was able to take the fifth place. Congratulations!

There is also a a video of the presentation by the contest's organisers at ICFP 2006. It is quite shaky, there are audio and video synchronisation problems and there is a guy sitting near the camera who gets tickled by almost everything into laughing out loud, but it is still worth a watch, especially for those who participated in the contest or those who want to know just how the organisers created the task.

This year's contest has proved to be so popular that the organisers have created a separate site called boundvariable.org dedicated to the "Cult of the Bound Variable".

An interesting bit about this year's contest was that the teams in the first and the third places were both from Google. Another interesting bit is that the individual members of these teams are also ranked very high on TopCoder and have been toppers in various contests organised by TopCoder. "Team Smartass" comprised Christopher Hendrie (ChristopherH), Derek Kisman (SnapDragon), Ambrose Feinstein (ambrose) and Daniel Wright (dmwright). "You Can't Spell Awesome Without ASM" comprised John Dethridge (John Dethridge), Ralph Furmaniak (RalphFurmaniak), Tomasz Czajka (tomek) and Reid Barton (reid).

Update (2006-10-22): Yumpee has pointed me to the ICFP 2006 paper (PDF) written by the organisers.

(Originally posted on Blogspot.)

[2006-09-26] Fullmetal Alchemist

I generally like animé, but I am not into it the way VikGup is, for example. About the only series I used to watch regularly was Dragon Ball Z (DBZ), before Cartoon Network India abruptly and very irritatingly pulled it off the air just as it was near the final few episodes. I liked the overall story in DBZ, but I felt the episodes and the fights were unnecessarily long and dragged-out, really testing one's patience (it reminded me of Ramanand Sagar's TV series "Ramayana"). I also liked Animatrix a lot. I have watched parts of other animé series, but I have never felt compelled to watch an entire series from the beginning to the end.

I am not a fan of the way most serious animé suddenly switches to "silly mode" in the middle of a scene, with characters swinging their limbs about wildly and screaming for no good reason, the drawing degrading in quality with quivering outlines - it just ruins the whole experience for me. I also find a bit odd the technique of showing an essentially still frame and then moving the camera about - I realise that the animators want to save effort and that it is a commonly-used technique elsewhere, but it seems to be used a lot more often in animé and I wish they didn't do it. Finally, the English dubbing is almost always terrible and I wish I could just see them in the original Japanese with English subtitles (I believe the DVD releases allow you to do that). All this aside, I must admit that many of the more popular animé series are beautifully drawn and have an overall story that is so fantastically different from anything else that one generally gets to see.

When I read Stevey Yegge's blog post on animé, I felt an urge to check out some of the animé series that he recommends. As luck would have it, Animax India has been showing some of the animé series that he highly recommends and on a whim I decided to check out Fullmetal Alchemist.

I am not disappointed at all - this is a wonderful series. It does switch to "silly mode" some times, but the rest of it is so good that I can live with that. The art is awesome, the story is intriguing, the music is nice and the story actually moves forward in each episode. No wonder many people have rated it one of the best animé of all time.

By the way, by the time I started watching the series, the episodes being shown were from the last one-third of the series so I didn't quite follow some of the things. Fortunately, Animax started showing the whole series from the beginning on weekends in a "catch-up marathon", with eight episodes shown back-to-back on every day of the weekend. In the evening on weekends they also show five episodes back-to-back to allow you to catch-up with the regular episodes that were shown during the week. It is a bit exhausting and my wife and sister think that I have gone crazy.

I am really looking forward to watching the concluding episodes that will be shown during this week and the next. I am also looking forward to watching the movie.

(Originally posted on Blogspot.)

[2006-09-19] “The Vietnam of Computer Science”

Via reddit.com, "The Vietnam of Computer Science":


"Although it may seem trite to say it, Object/Relational Mapping is the Vietnam of Computer Science. It represents a quagmire which starts well, gets more complicated as time passes, and before long entraps its users in a commitment that has no clear demarcation point, no clear win conditions, and no clear exit strategy."

A nice albeit verbose article on why using Object/Relational Mapping to store objects in relational database systems sounds like a good idea at first but then becomes a quagmire once you start trying to resolve more and more of the inherent differences between the two approaches.

(Originally posted on Blogspot.)

[2006-09-15] Terminal Sickness

I have a simple requirement: I want my programme to be able to spawn another programme on the same machine and talk to it using the simplest possible means of communication, that is, via the spawned programme's standard input and output streams.

The driving programme is written in C and the spawned programme could have been written in any programming language (hence the need for using as simple a form of communication as possible). The messages exchanged between the programmes are terminated by newline characters.

This should have been a relatively simple task with code somewhat like the following (error-handling has been omitted for clarity):


/* File descriptors for pipes connecting driver and inferior
processes. */
int drv2inf[2], inf2drv[2];

/* Create communication pipes. */
pipe (drv2inf); pipe (inf2drv);

if (fork () == 0) {
/* In child process - close "other" ends of pipes first. */
close (drv2inf[1]); close (inf2drv[0]);

/* Redirect stdin and stdout. */
close (0); dup (drv2inf[0]); close (drv2inf[0]);
close (1); dup (inf2drv[1]); close (inf2drv[1]);

/* Spawn inferior process - should never return. */
char *args[] = { prog, NULL};
execv (prog, args);
} else {
/* In parent process - close "other" ends of pipes first. */
close (drv2inf[0]); close (inf2drv[1]);
}


However, running this with a test programme (written in C) revealed a problem: messages sent by the spawned programme were not reaching the driving programme!

The reason is that stdout is normally "line-buffered" - i.e. output is buffered till either the buffer becomes full or till a newline character is encountered. When stdout is not connected to a terminal however (for example, when output is redirected to a file), it becomes "block-buffered" - i.e. output is buffered till the buffer becomes full. Of course, you can force the output buffer to be flushed out using fflush() at any time. This behaviour of the C runtime is a reasonable tradeoff that seeks to optimise throughput and response under different conditions. In my case the C runtime determined that stdout was not connected to a terminal and therefore should be block-buffered. The messages sent by the spawned process were therefore still sitting in its output buffer while the driving process waited to hear from it.

My knee-jerk reaction was to insert a call to setvbuf() with a mode of _IOLBF just before the call to execv() in order to force a line-buffered mode for the spawned process. Of course, this does not work for the simple reason that the C runtime is re-initialised after the call to execv().

A possible solution is to mandate that the spawned programme force a line-buffered mode for stdout using something like setvbuf(). Another solution is to mandate that the spawned programme always use the equivalent of fflush() to flush its output buffers after every message. However, these just work around the problem rather than solving it. I also do not want to place unnecessary restrictions on spawned programmes.

So it seems the only solution left is to use a pseudo terminal to fool the spawned programme's runtime into thinking that it is attached to a terminal. A glance through the sample code given in my copy of Stevens's "Advanced Programming in the UNIX Environment" reveals that some ugly code is needed to make it work properly. It also makes my programme even less portable than it currently is. I am therefore a bit loath to take this approach.

Does anyone know of a better solution to this problem?

Update (2006-09-16): Thanks to all who responded. Using a pseudo terminal solved my problem. The forkpty() function from libutil provided by the GNU C Library (thank you Scott) conveniently wraps everything I need into a single function. The only problem is that it also redirects stderr to the newly-created pseudo terminal and this robs the spawned programme of a simple method of debugging. To work around this issue, I had to save the stderr stream using a dup() before calling forkpty() and then restore it using a dup2() in the child process.

One of the problems with using a pseudo terminal that initially stumped me was the fact that the spawned programme seemed to send the driver programme all the messages it was sent by the latter in addition to sending messages of its own. It took me a while to realise that this was because of terminal echo. Switching terminal echo off resolved this problem.

Update (2007-10-18): Here is the relevant portion of the programme that finally worked for me:


#include <stdio.h>
#include <stdlib.h>

#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <termios.h>
#include <pty.h>

/* Spawns a process with redirected standard input and output
streams. ARGV is the set of arguments for the process,
terminated by a NULL element. The first element of ARGV
should be the command to invoke the process.
Returns a file descriptor that can be used to communicate
with the process. */
int
spawn (char *argv[]) {
int ret_fd = -1;

/* Find out if the intended programme really exists and
is accessible. */
struct stat stat_buf;
if (stat (argv[0], &stat_buf) != 0) {
perror ("ERROR accessing programme");
return -1;
}

/* Save the standard error stream. */
int saved_stderr = dup (STDERR_FILENO);
if (saved_stderr < 0) {
perror ("ERROR saving old STDERR");
return -1;
}

/* Create a pseudo terminal and fork a process attached
to it. */
pid_t pid = forkpty (&ret_fd, NULL, NULL, NULL);
if (pid == 0) {
/* Inside the child process. */

/* Ensure that terminal echo is switched off so that we
do not get back from the spawned process the same
messages that we have sent it. */
struct termios orig_termios;
if (tcgetattr (STDIN_FILENO, &orig_termios) < 0) {
perror ("ERROR getting current terminal's attributes");
return -1;
}

orig_termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
orig_termios.c_oflag &= ~(ONLCR);

if (tcsetattr (STDIN_FILENO, TCSANOW, &orig_termios) < 0) {
perror ("ERROR setting current terminal's attributes");
return -1;
}

/* Restore stderr. */
if (dup2 (saved_stderr, STDERR_FILENO) < 0) {
perror ("ERROR restoring STDERR");
return -1;
}

/* Now spawn the intended programme. */
if (execv (argv[0], argv)) {
/* execv() should not return. */
perror ("ERROR spawning programme");
return -1;
}
} else if (pid < 0) {
perror ("ERROR spawning programme");
return -1;
} else {
close (saved_stderr);
}

return ret_fd;
}

(Originally posted on Blogspot.)

[2006-09-10] Crikey

Germaine Greer in The Guardian on Steve Irwin:

"The only creatures he couldn't dominate were parrots. A parrot once did its best to rip his nose off his face. Parrots are a lot smarter than crocodiles."

[...]

"What Irwin never seemed to understand was that animals need space. The one lesson any conservationist must labour to drive home is that habitat loss is the principal cause of species loss. There was no habitat, no matter how fragile or finely balanced, that Irwin hesitated to barge into, trumpeting his wonder and amazement to the skies. There was not an animal he was not prepared to manhandle. Every creature he brandished at the camera was in distress."


This was the seemingly sole voice of reason among the glowing obituaries all over the place hailing the "Crocodile Hunter" as a hero and a conservationist of wild life.

(Originally posted on Blogspot.)

[2006-09-09] Exercise

I'm not a fitness freak but I do believe in the old adage that a healthy body houses a healthy mind. Consequently, I had decided early on in my life to try to remain as fit as is reasonably possible. Unfortunately for me, I have not consistently implemented this resolution over the years with the natural result that I had become lethargic, easily tired and had gained unseemly tyres of fat on my person. I have been trying to rectify matters over the last few months and it seems to be paying off, slowly but surely.

Back in college there was a time when I used to jog in the mornings, swim in the afternoons and play football in the evenings, though I took on the latter two activities more for fun than for improving fitness as such. After leaving college and taking up a job, I tried to jog regularly in the mornings but gave up after a couple of months or so. Without jogging partners from my college days like Pranjal and Subra to goad me, it required too much will power and discipline to refuse the warm embrace of sleep and brave the cold morning air every day. As a wit once remarked, the toughest distance you have to cover while jogging is the stretch between your bed and the floor. To keep myself from putting on excess weight, I tried to regulate my diet a bit. However, that can only help so much when your entire day is spent sitting on a chair at your workplace and your entire night is spent either sitting on a sofa or lying on a bed. Before I realised it, ten years had passed and I had become an embarrassingly unfit image of my former self, advancement of age notwithstanding.

So I have been forcing myself over the last few months to go to bed relatively early (10 PM) and get up and go for a jog, or even a brisk walk, early in the morning. It was difficult at first and I was very irregular but it has now become easier - I wake up by 6 AM without the need for an alarm and am able to convince myself to get out of bed.

I prefer running through the streets of the city in a single long loop and getting a varied view rather than doing monotonous laps in a park or a stadium or staying at one place on a treadmill. Unfortunately for me, it turns out that there are an alarming number of vehicles on the streets even at 6 AM in the morning and spewing noxious fumes and that there are a large number of stray dogs which sometimes bark at you, sometimes run after you and sometimes leave their poop behind for you to watch out. The footpaths are not continuous or even and the roads have oddly parked vehicles or idiots driving the wrong way. The parks nearby are a bit too crowded for me to have any hope for a decent pace of jogging. The playgrounds in the neighbourhood are either too muddy or filled with children, not to mention stray dogs.

I had therefore switched over rather reluctantly to running on a treadmill. Fortunately for me, I live in an apartment complex that has a fairly decent gymnasium. I found out that running on a treadmill is not as bad as I had feared and is in fact much better in several ways. For one, the surface is not as hard as that of a road or a footpath so it feels much better to run on. More importantly, it allows me to properly warm up, maintain a steady jogging speed for a while and then properly cool down. I can easily control the effort expended by varying the speed, the slope and the duration. I can vary the programme to accommodate any constraints of time I might have. The other equipments available in the gymnasium also allow me to exercise other parts of my body. There are also some other benefits of working out in a gymnasium that cannot be described publicly without putting one's marital life into jeopardy. ;-)

One of the pleasantly surprising facts of working out is that it actually leaves me energetic and enthusiastic, rather than tired and achy, for the rest of the day. I feel much better than before and I hope I am able to maintain this regimen.

(Originally posted on Blogspot.)

[2006-09-08] Good Bye Advogato!

Advogato is going offline.

I feel a bit sad about it even though I had stopped updating my Advogato diary and have been using Blogger for blogging for the last three months. After all, Advogato is where I started blogging regularly.

mibus provides a nice tip: You can access all your Advogato diary entries in a convenient XML format by appending "diary.xml" to your normal diary URL. For example:

http://www.advogato.org/person/rmathew/diary.xml

There is a "Planet (Former) Advogato" for aggregating the blogs of all those who used to blog on Advogato but have moved elsewhere for one reason or the other.

(Originally posted on Blogspot.)

[2006-09-07] Expensive Conferences

I like to pretend that I am interested in compiler construction techniques. I was therefore quite interested in attending the New Horizons in Compilers (mirror) workshop that will be held as a part of HiPC 2006 right here in IISc Bangalore. Unfortunately, it turns out that you have to register for the entire conference to be able to attend this workshop. The really awful part is that I would have to part with 22,500 rupees ($500) to be able to do that. There is no way that I am ever going to shell out that kind of money for something like this.

Apparently this is supposed to be the "reduced rate" for Indian participants who are not from academia, government organisations or three-four letter organisations. Even for ACM/IEEE/IFIP members, it is still 16,900 rupees ($375) and that is still a lot of money in this part of the world for this kind of an event. It is as if they are making an active attempt to keep everyone else out. I did ask the "registration chair" and the workshop organisers for a better option but apparently there is none.

What a shame!

(Originally posted on Blogspot.)

[2006-09-06] Where is The Purple Dragon Book?

The "second" edition of the Dragon Book (a.k.a. "Compilers: Principles, Techniques and Tools" by Alfred Aho and others) has already been delayed a lot, considering that the previous edition was published twenty years ago in 1986 and the new edition was supposed to be published "soon" years ago. The final publishing date was supposed to be 31st August 2006 and the corresponding Amazon.com page and the Addison-Wesley page continue to stick to the same date as of this writing and yet proclaim the title to be unavailable. Jeffrey Ullman says that the book is finally done and that they handed it over to the publisher at the end of June 2006, so I wonder what is causing all these delays and whether the wait would be worth it. Note that an online preview of some of the revised as well as newly-added chapters is still available, though the site uses an awful amount of Flash, JavaScript and pop-ups for some weird reason.

I put "second" in quotes since the publisher says that this is the second edition, though coming after the Green Dragon Book and the Red Dragon Book, I think this should be called the third edition of the book. However, I do realise that there was a change in the title of the book and it was thoroughly revised when it was published as the Red Dragon Book, so this is just nitpicking on my part. It has already been nicknamed the Purple Dragon Book based on its cover, continuing the convention for giving nicknames to its predecessors.

I read parts of the Red Dragon Book when I took the Compilers course in my college about twelve years ago. It was a bit boring (as are almost all textbooks I have ever read), but it was the only book I could lay my hands on that covered bits of everything about compiler construction. Even to this day, 20 years after it was published, it still seems to be a recommended book if you want to know about the basics of compiler construction. However, it is acknowledged to be terribly out-of-date with the current techniques, so a major revision was long overdue.

I have been meaning to brush up on the fundamentals of compiler construction techniques for several years now, especially since the time I was introduced to the development of GCC, but my excuse was that I wanted to postpone it till the time the new edition of the Dragon Book becomes available (which was always marked to be released "any time now"). Now that the Purple Dragon Book would become available "soon", my excuse is that I would at least wait for the second printing so that all the readily-apparent errors are corrected and I don't have to read the book with a thick errata in hand. I would also wait for the low-priced Indian edition to become available since the international editions are atrociously priced in my opinion.

Yes, I do make up really silly excuses for what is ultimately procrastination driven by plain old sloth.

Update (2006-06-07): As luck would have it, just a day after I write about the unavailability of this book, both Amazon.com and Addison-Wesley now show it as in-stock and ready for shipping.

(Originally posted on Blogspot.)

[2006-09-04] “If You Come Today”

"If you come today, it's too early. If you come tomorrow, it's too late. You pick the time."

Sriram pointed out a video of the (English) song "If You Come Today" sung by and featuring Rajkumar. The lyrics of the song are rather confounding, but my favourite parts are the "Tick, Tick, Tick, Tick..." and the "DOHLING!".

(Originally posted on Blogspot.)

[2006-08-28] “Watchmen”

“Watchmen”, written by Alan Moore and illustrated by Dave Gibbons, has been widely hailed as one of the best graphic novels ever written. In fact, Time magazine even went to the extent of putting it in its list of the 100 best English-language novels of “all time” published since 1923. It is also the only graphic novel to have ever been awarded the Hugo Award (given every year to the best work in science fiction and fantasy). It has also won numerous other awards for its creators.

Read More...

[2006-08-28] A Bold Question

Does anyone know why comics writers put one or two words in every sentence in every dialogue in bold typeface?

For example, "Watchmen" is perfect in every other way except for this flaw. I tend to translate bold typeface as indicating an emphasis on a word or a phrase, so it is rather jarring to read dialogues mouthed by characters in comics.

Why do they do this?

(Originally posted on Blogspot.)

[2006-08-18] RMS, GPLv3 and Bangalore

Richard Stallman will be talking about "Free Software: Current Status and Challenges" at 11 AM in the Faculty Hall in IISc Bangalore tomorrow (Saturday, 19th August 2006). I came to know of this event just this afternoon and I understand that this is too short a notice, but I hope to meet some of the fellow Free Software enthusiasts in Bangalore.

On a related note, Bangalore will also be hosting the Fourth International Conference on GPLv3 on the 23rd and 24th August 2006, this time in IIM-B. Both Richard Stallman and Eben Moglen will be presenting in this event. Since this falls in the middle of a work week (Wednesday/Thursday), I will have to skip it.

(Originally posted on Blogspot.)

[2006-08-18] “Programming Languages: Concepts and Constructs”

“Programming Languages: Concepts and Constructs” (Second Edition) by Ravi Sethi is a book desgined to be used as one of the text books in a “Principles of Programming Languages” CS course. To that end, it covers all the major programming styles (imperative, functional and declarative) and variants (object-oriented and concurrent), basic lambda calculus, a short tour of a representative programming language or two for each of the covered styles, numerous exercises for the students to work out, extensive bibliography, etc.

Read More...

[2006-08-17] Good Math, Bad Math

I came to know of Mark Chu-Carroll's "Good Math, Bad Math" blog via a post in "Programming Musings", the blog of Josť Antonio Ortega Ruiz. Mark writes mostly about mathematics, the theoretical foundations of programming, debunking bad use of mathematics in popular and not-so-popular media, etc.

I find many of Mark's articles very interesting to read, though many others go way over the top of my head. Some of his recent articles that I found really interesting include one that shows how absurd arithmetic with Roman numerals can be, one on Poincaré Conjecture, some in the "Friday Pathological Programming Language" series, one on zero, one on i, one on e, one on ?, one on ?, one on ?, one on continued fractions, etc. The old home for the GM/BM blog contains many more interesting and insightful articles on math and programming theory. What an amazing guy!

Highly recommended.

(Originally posted on Blogspot.)

[2006-08-14] Balancing Acts

You are given 8 billiards balls, numbered 1 to 8, identical in shape and size. All but one weigh exactly the same. The odd ball is either heavier or lighter than the others. Using just three weighings on an ordinary two-pan balance, find the odd ball out as well as whether it is heavier or lighter than the others.

If you solve the previous puzzle, solve the same problem for 12 billiards balls (instead of 8) while keeping the maximum weighings to just three. Yes, there is a solution for this puzzle - if you give up, you can find the solution here.

For the first puzzle (with just 8 billiards balls), here is my solution (obfuscated using rot-13):

  1. Xrrc onyyf ahzorerq 1, 2 naq 3 ba bar cna naq 4, 5 naq 6 ba gur bgure.
  2. Vs gurl onynapr, gurl ner nyy abezny naq bar bs 7 naq 8 vf gur bqq onyy. Jrvtu 7 ntnvafg 1.
  3. Vs gurl onynapr, 8 vf gur bqq onyy naq lbh pna svaq vgf bqqvgl ol jrvtuvat vg ntnvafg 1.
  4. Vs gurl qba'g onynapr, 7 vf gur bqq onyy naq lbh jvyy vzzrqvngryl xabj vs vg vf urnivre be yvtugre guna gur bguref.
  5. Vs gur onyyf qba'g onynapr va fgrc #1, bar cna jvyy tb qbja. Jvgubhg ybff bs trarenyvgl, nffhzr guvf vf gur bar pbagnvavat 1, 2 naq 3. Rvgure bar bs 1, 2 naq 3 vf urnivre guna gur bguref be bar bs 4, 5 naq 6 vf yvtugre guna gur bguref.
  6. Xrrc 1 naq 5 ba bar cna naq 4 naq 2 ba gur bgure. Xrrc 3 naq 6 nfvqr.
  7. Vs gurl onynapr, bar bs 3 naq 6 vf gur bqq onyy. Sebz fgrc #5, jr pna pbapyhqr gung rvgure 3 vf urnivre guna gur bguref be 6 vf yvtugre guna gur bguref. Jrvtu 3 ntnvafg 1.
  8. Vs gurl onynapr, 6 vf gur bqq onyy naq vf yvtugre guna gur bguref.
  9. Vs gurl qba'g onynapr, 3 vf gur bqq onyy naq vf urnivre guna gur bguref.
  10. Vs gur onyyf qba'g onynapr va fgrc #6, rvgure gur cna jvgu 1 naq 5 jvyy tb qbja be gur cna jvgu 4 naq 2 jvyy tb qbja.
  11. Vs gur cna jvgu 1 naq 5 tbrf qbja, sebz fgrc #5 jr pna pbapyhqr guna rvgure 1 vf gur bqq bar bhg naq vf urnivre guna gur bguref be 4 vf gur bqq bar bhg naq vf yvtugre guna gur bguref.
  12. Jrvtu 1 ntnvafg 8. Vs gurl onynapr, 4 vf gur bqq bar bhg naq vf yvtugre guna gur bguref. Vs gurl qba'g, 1 vf gur bqq bar bhg naq vf urnivre guna gur bguref.
  13. Vs gur cna jvgu 4 naq 2 tbrf qbja va fgrc #10, sebz fgrc #5 jr pna pbapyhqr gung rvgure 2 vf gur bqq bar bhg naq vf urnivre guna gur bguref be 5 vf gur bqq bar bhg naq vf yvtugre guna gur bguref.
  14. Jrvtu 2 ntnvafg 8. Vs gurl onynapr, 5 vf gur bqq bar bhg naq vf yvtugre guna gur bguref. Vs gurl qba'g, 2 vf gur bqq bar bhg naq vf urnivre guna gur bguref.
  15. Va fgrc #5, vs 4, 5 naq 6 tb qbja, pneel bhg gur erznvavat fgrcf ol fjnccvat 1, 2 naq 3 jvgu 4, 5 naq 6 erfcrpgviryl.
I confess that I had to finally give up while trying to solve the 12-ball variation in the second puzzle.

(Originally posted on Blogspot.)

[2006-08-10] Lost Books on Computer Programming

I am not into old books on computers the way Graydon seems to be, but I still feel sad that the current generation of programmers will most likely never get exposed to some of the great books on computer programming that I was able to read when I was young.

At least here in Bangalore, it is almost impossible to buy these books from a bookshop unless they have either retained very old stock or are selling second-hand books. For example, here are a few books that seem to be very difficult to buy these days in Bangalore:

  1. "The Elements of Programming Style", Brian Kernighan and P. J. Plauger.
  2. "Algorithms + Data Structures = Programs", Niklaus Wirth.
  3. "A Discipline of Programming", Edsger Dijkstra.
  4. "The Science of Programming", David Gries.
  5. "Communicating Sequential Processes", C. A. R. Hoare.
  6. "How to Solve it by Computer", R. G. Dromey.
  7. "Microprocessors: A Programmer's View", Robert B. K. Dewar and Matthew Smosna.
(I am sure I have not listed a lot of other interesting and important books here, but these are the names that readily spring to my mind.)

Of these, I have only been able to buy Dromey's book so far. In my opinion, it is one of the most under-appreciated books in computer science and deserves to be read by every novice programmer. It is a perfect complement to the usual textbooks for a Data Structures and Algorithms course.

A kind soul has scanned in the pages from "A Discipline of Programming" and made them freely available to everyone. The electronic version of "Communicating Sequential Processes" is now freely available for download. But I still wish I had these books "for real".

By the way, Robert Dewar hopes to produce an updated version of "Microprocessors: A Programmer's View" sometime soon.

Alarmingly, some relatively recent books are also becoming difficult to find these days. For example:

  1. "Programming Pearls", Jon Bentley.
  2. "The Practice of Programming", Brian Kernighan and Rob Pike.
I also note rather sadly that the "XYZ Unleashed" and "Learn ABC in 3 Days" type books are still going strong even after almost a decade.

Thankfully, the "The Art of Computer Programming" (TAOCP) series by Donald Knuth is still easily available. "Structure and Interpretation of Computer Programs" (SICP) by Harold Abelson, Gerald Jay Sussman and Julie Sussman is also visible in bookshops from time to time.

I think the strong sales of TAOCP are more due to the "classic book" effect than anything else. To quote Mark Twain, "A classic is a book that everyone wants to have read but no one wants to read". If there are people who have actually read TAOCP, they seem to have been rather successful at avoiding to meet me. To quote Bill Gates, "If you have read The Art of Computer Programming from cover to cover, send me your resume!".

(Originally posted on Blogspot.)

[2006-08-10] “How to Solve it by Computer”

“How to Solve it by Computer” by R. G. Dromey is inspired by George Polya's classic book on problem-solving “How to Solve it”. This book explores how good problem-solving techniques can be applied in computer programming to come up with efficient algorithms for many problems.

Read More...

[2006-08-07] The Suez Crisis and The IBM PC

"Those who cannot remember the past are condemned to repeat it."

- George Santayana

A recent issue of The Economist featured the article "An Affair to Remember" about the Suez crisis (also known as the Sinai War) of 50 years ago. I found it to be a very interesting read. It provides some great insights into the events precipitating the formation of the European Union, the establishment of the US and the Soviet Union as the only superpowers, the reasons for the different way that the British and the French view the US, etc. I also found it a bit surprising how the then British prime minister Anthony Eden and his foreign secretary blatantly lied to the House of Commons about the sinister collusion between Britain, France and Israel that led to the war.

In the light of the recent events, it is amusing to find out that at that time the US actually went via the UN to put a stop to this uncalled-for agression by the Israelis, the British and the French against the Egyptians. It was apparently also the last time that the US actually acted against Israel while intervening in a war.

How times change.

The same issue of The Economist also featured the article "Getting Personal" about the 25th anniversary of the introduction of the IBM PC. The first IBM PC was apparently priced at USD 1,565, had 16K of RAM, used audio cassettes for storage (a floppy drive was optional) and featured ?green phosphor characters for reading comfort? (i.e. text-only, no graphics). It wasn't until Lotus 1-2-3 was introduced about 1.5 years later that the PC really took off. These days you are overwhelmingly more likely to see a PC than an Apple Macintosh or any other kind of personal computer.

I first got to work on an (8086-based) IBM PC in 1990. It struck me as rather ugly and severely lacking. I was used to the excellent BBC Micro and the primitive CGA display of the IBM PC and the PC speaker were nothing compared to what was available on the Beeb. As a novice programmer, it was also very irritating to find how different BASICA was from BBC BASIC. All the "VDU" (graphics) and "ENVELOPE" (sound) tricks I had learnt on the Beeb were also useless on the PC.

It was not until I got to work on the 80386-based IBM PCs and play Prince of Persia and Wolfenstein 3D that I really began to enjoy working on the PC. Borland's Turbo Pascal and Turbo C/C++ were excellent tools that made programming on the PC much easier. After the advent of Linux, there was no question about what my first personal computer was going to be.

(Originally posted on Blogspot.)

[2006-08-04] Another River Crossing Puzzle

Most of us would have seen the standard river crossing puzzle. However, Prasadini recently sent me another river crossing puzzle (Flash animation) that I think is far more challenging.

A father and his two sons, a mother and her two daughters, a thief and a policeman are on one side of a river. There is a boat by the river bank, but it can only take two people at a time. Only the father, the mother and the policeman know how to operate the boat. The father can not be with any of the girls without their mother around. The mother can not be with any of the boys without their father around. The thief can not be with anyone else without the policeman around. How can you get everyone across to the other side of the river?

Start the game by clicking on the big round blue button. Click on a person to get him or her on or off the boat. Click on the levers to get the boat to move.

It took me a fair bit of time to crack it and here is my solution (obfuscated using rot-13):

  1. Gur Guvrs naq gur Cbyvprzna pebff bire.
  2. Gur Cbyvprzna pbzrf onpx (Gur Guvrs qbrf abg eha njnl jura yrsg nybar!).
  3. Gur Cbyvprzna naq n obl pebff bire.
  4. Gur Cbyvprzna naq gur Guvrs pbzr onpx.
  5. Gur Sngure naq gur bgure obl pebff bire.
  6. Gur Sngure pbzrf onpx.
  7. Gur Sngure naq gur Zbgure pebff bire.
  8. Gur Zbgure pbzrf onpx.
  9. Gur Guvrs naq gur Cbyvprzna pebff bire.
  10. Gur Sngure pbzrf onpx.
  11. Gur Sngure naq gur Zbgure pebff bire.
  12. Gur Zbgure pbzrf onpx.
  13. Gur Zbgure naq n qnhtugre pebff bire.
  14. Gur Guvrs naq gur Cbyvprzna pbzr onpx.
  15. Gur Cbyvprzna naq gur bgure qnhtugre pebff bire.
  16. Gur Cbyvprzna pbzrf onpx.
  17. Gur Cbyvprzna naq gur Guvrs pebff bire.
See if you can come up with a better solution.

(Originally posted on Blogspot.)

[2006-08-03] Optimising Linker Load Times

Last week's LWN.net Weekly Edition had a nice article on optimising linker load times by John Richard Moser. It was based on some recent features added to the linker in GNU binutils. It explains the kind of things that most of us never bother to learn about, but which can affect the loading times of our applications and shared libraries. As someone noted in the comments, an informative read even by LWN.net's usually high standards.

(Originally posted on Blogspot.)

[2006-08-02] “Batman: The Dark Knight Returns”

“Batman: The Dark Knight Returns”, written by Frank Miller and published in 1986, presents a Batman that is completely different from the stupid television series of the 1960s. If you liked Tim Burton's “Batman” and “Batman Returns” movies, you will love this graphic novel.

Read More...

[2006-07-31] FOSS.IN 2006

FOSS.IN/2006 will be held between November 24-26 at the J. N. Tata Auditorium in IISc Bangalore. This event used to be called "Linux Bangalore" and is justly touted as "India's Premier Annual Free and Open Source Software Event". It has been organised every year since 2001 by the Bangalore Linux Users' Group (BLUG). Atul Chitnis's diary entry has some more information.

I have personally attended only two of these events and I regret not having attended more of these. FOSS.IN/2005 was fairly good and mostly fun. I hope to be able to attend this year's event as well.

(Originally posted on Blogspot.)

[2006-07-31] Decadence

I complete 10 years in the software industry today.

Ten years ago, as a lad fresh out of college and fascinated with computer programming, I felt tremendously excited that I had got a job where I could write computer programmes all the time.

That delusion was rather short-lived. I soon discovered that programming is actually a very small part of software engineering. Much of my time is spent writing specifications, communicating with my teammates and clients via email, conference calls and meetings, writing documentation, fixing bugs, giving demonstrations and presentations, etc. I spend more time within Microsoft Word than within Vim.

When I do get to write code, I have to write the simplest of programmes. The requirements almost never merit anything sophisticated. On the rare occasions where better data structures and algorithms can help, I still cannot use them since the code then becomes unmaintainable by the "average" software engineer. For an underperforming application, the standard solution seems to be to use a bigger machine instead of making the application more efficient. Developing "enterprise" software can be really dull and depressing for someone even mildly interested in programming.

(Originally posted on Blogspot.)

[2006-07-25] ICFPC 2006

I participated in the ICFP programming contest for 2006 over this weekend. I was taking part in it purely for the fun of it (yes, really). It turned out to be a very interesting task. Check out the task description to see what I mean.

You have to first implement an interpreter for a simple but quirky virtual machine called the Universal Machine (UM). You then use this interpreter on the given data file ("codex.umz") to run a small programme that takes a password and uses this password to decrypt and uncompress a binary image. You then use the interpreter on this extracted binary image to discover a small UNIX-like multi-user system where you can log in as "guest". This system, called "UMIX", includes a set of common UNIX utilities like "ls", "rm", "cat", "more", etc., an interpreter for BASIC (called "Qvikbasic", that only recognises numbers written with Roman numerals) and a file-transfer utility called "umodem".

Using the guest account, you complete a simple password-cracking utiliy written in BASIC and use it to discover the passwords of a couple of other user accounts. When you log in as those users, you find more tasks that you can complete to discover the passwords of other user accounts, which yield even more tasks and so on till you get the "root" password. For example, one of the tasks was in the form of an Adventure-like game and another was using a "2-dimensional" programming language, complete with ASCII-art boxes for each function, to solve a given problem.

It was incredible and this is easily one of the best ICFPC tasks I have ever attempted.

You might also want to check out Mark Probst's account, Mauricio Fernandez's account, Gregory Brown's accounts (1, 2, 3, 4), etc.

The organisers also provided a handy benchmark for testing your UM implementation (called "SANDmark") and a reference UM implementation (in the form of a UM binary of course). If you want to quickly check it out, here is my UM implementation (written in C). You can use "(\b.bb)(\v.vv)06AAVKIru7p0OmCvaT" as the password to extract the UMIX binary image from "codex.umz" using this interpreter. (Paul Ingemi has even implemented a JIT-ing UM using LuaJIT!)

When I first implemented the UM, it ran quite slowly - it took a very long time for the UMIX login prompt to appear and over three hours just to compile "hack.bas" with Qvikbasic. I first tried simple tricks like converting indexed array accesses to incremental pointer accesses, caching values that were being used often, using a function-pointer-based dispatcher table to decode and execute instructions instead of a big switch statement, etc. but nothing helped. I found that the UM binaries allocate and deallocate a lot of "arrays" of various sizes and inspired by one of the posts to the ICFPC 2006 mailing list, I even implemented a system where arrays were only allocated in sizes of the smallest power of two larger than the requested size and recycled internally instead of being returned back to the operating system. However, even that did not help much.

That is when I decided to stop fooling around and ran the interpreter through qprof (I feel gprof and oprofile are not as immediately useful as qprof is - try it out and you would probably agree). I discovered that the real bottleneck was in the code that searched for a free slot to assign an index to a newly allocated array. When I eliminated that bottleneck by explicitly keeping track of freed slots, the performance of the interpreter improved drastically and it became usefully responsive. I eliminated the power-of-two array size foolery and it was still pretty responsive - malloc()/free() are really implemented pretty well in GNU libc and it is not usually worth it to second-guess it (except perhaps in extreme cases). (Also check out Doug Lea's notes on the design of a memory allocator.)

One of the wicked ideas from the mailing list did help however - using the pointer to an array's memory as its index instead of maintaining an "array of arrays", yielded a 20% boost in the performance of my UM implementation (as measured by SANDmark) but reduced its "portability" to only those machines where both integers and pointers are 32 bits.

The lesson learnt? We programmers are really quite bad at guessing the hotspots in our programmes. We should always use a profiler to find out where the real bottlenecks are in our programmes.

By the way, a few hapless souls discovered that the lack of unsigned integers in Java makes it unnecessarily difficult to implement something like this in Java. Why exactly couldn't the creators of the language provide unsigned variants of the integral types?

(Originally posted on Blogspot.)

[2006-07-21] Validating XML Documents

I was writing a couple of XML documents conforming to certain XML Schemata the other day. I was looking for a simple command-line tool that would take an XML document and an XML Schema and check if the document was well-formed and really conformed to the given XML Schema (I did not want to use web-based validation). I could have written a tool like this myself but I was feeling rather lazy and just wanted to quickly download a tool from somewhere to do this.

It turned out to be a surprisingly frustrating task and eventually took more time than what I would have taken to write it myself. Perhaps my Google queries were not good enough, perhaps people are just happy with their respective IDEs, perhaps everyone just writes their own little tool around the usual XML parsing libraries, perhaps people are not so anal about writing XML documents that strictly conform to the applicable XML Schema, etc. - I don't know why, but it took me a while to locate such a tool.

I first used Sun's Multi-Schema XML Validator (MSV) and it worked for me for a while but then tripped with a StackOverflowError on a particular XML Schema that I had to use so I had to abandon it. I next tried XMLStarlet but the error messages it spewed were a bit confusing and it did not fully support XML Schemata so I abandoned it as well. I am now using a little tool called "DOMCount" that is included with Apache Xerces and that ostensibly parses a document and prints out the number of DOM elements it has encountered but that also works fairly well as a document validator. The error messages shown by this tool, while better than those from XMLStarlet, can still confuse some times but I can live with it for the moment.

While creating these documents from the appropriate XML Schemata, I found xs3p [link currently seems broken] to be really useful. This is a stylesheet that takes an XML Schema and generates a pretty HTML document from it that you can use to understand the original XML Schema and easily navigate through its structure. I used Apache Xalan to generate the HTML documents.

(Originally posted on Blogspot.)

[2006-07-21] New Delhi, US Visa and Kingfisher Airlines

I was in New Delhi at the beginning of this week to appear for an interview at the US embassy for a visa application for a business trip to the US in the near future.

This was my very first visit to New Delhi. I have finally fulfilled a long-held desire to see all the four metropolitan cities of India, viz. Delhi, Bombay (Mumbai), Madras (Chennai) and Calcutta (Kolkata). I was there for just a little over 24 hours, but I was still quite impressed with what I saw - wide, pothole-free roads with traffic zipping along at 50-60 kmph, lots of trees, everything spread out instead of congested together, etc. It did not feel like an Indian city at all. I am told that what I saw was just "New" Delhi and that Old Delhi is just like any other Indian city in terms of congestion and chaos. It's also rather myopic of me to judge a city by what I saw on my trips back and forth between my hotel in Connaught Place , the domestic and international airport terminals (a distance of about 20-25 kms) and the US Embassy.

However, others who have stayed in Delhi as well as Bangalore also insist that Delhi is a far cleaner city, has much less of traffic congestion and is a much larger city than Bangalore. I tend to agree based on what I have seen. I did not find Bombay, Madras and Calcutta much better than Bangalore - the awful amount of time you spend commuting in Bombay, the utter lifelessness of Madras for a youngster and the insanely congested traffic in Calcutta made me realise how much better off I was being in Bangalore than in any of these cities. With Delhi, I wasn't so sure.

While applying for a non-immigrant US visa, you have to fill out DS-156. One of the queries in this form that never fails to amuse me is:


Do you seek to enter the United States to engage in export control violations, subversive or terrorist activities, or any other unlawful purpose? Are you a member or representative of a terrorist organization as currently designated by the U.S. Secretary of State? Have you ever participated in persecutions directed by the Nazi government of Germany; or have you ever participated in genocide? [Yes/No]

Do they really expect anyone to answer "Yes" to that query?

My flights for this trip were with the new Kingfisher Airlines. I was quite impressed by them and would rank them higher than Jet Airways, the only other domestic airlines that I think has a reasonably good service. (My sister says that Paramount Airways is also quite good, but I am yet to travel with them.) Kingfisher has these little touches everywhere that score over Jet - the tickets are generally priced lower, you can select your seat over the Internet before checking in, when you arrive at the airport a valet takes your luggage, tags it, puts it through the security check and takes it to the check-in counter for you (no, I was not travelling Business Class but "Kingfisher Class", which is what they like to call Economy Class), there is an in-flight entertainment system to keep you occupied, the seats have slightly more leg room, etc. Oh yes, the air hostesses are really pretty too (with a bit too much of make-up I think, but quite pretty nonetheless). Wonderful.

(Originally posted on Blogspot.)

[2006-07-20] ICFP Contest 2006

Those interesting in programming might want to check out the ICFP Contest for 2006 which will be held during the coming weekend (21st to 24th July 2006). The problems are generally open-ended and fun to solve even if your entry does not make it to the top - check out the problems from the previous years' contests to see what I am talking about.

(Originally posted on Blogspot.)

[2006-07-19] All Your Blogs Are Belong To Us

We in India are no longer able to directly view blogs hosted on Blogspot, Typepad, Geocities, etc. This is because ISPs in India are blocking access to these popular sites acting on a government diktat to block some blogs "within the provisions of the Fundamental Right to free speech and expression granted in India's constitution" [sic]. Mridula was one of the first ones to notice and write about this blockade and the story has already made it to Slashdot and some of the mainstream media in India.

The government's diktat was to block a specific set of blogs ("to ensure a balanced flow of information") but since all the Blogspot URLs resolve to the same IP address, the blockade ends up blocking all blogs hosted on Blogspot. Ditto for Typepad, Geocities, etc. Since blogger.com is not blocked, I am able to post to my blog. I can also view my blog from my office since the Internet connection there is routed via a corporate proxy server located in the US. Using pkblogs.com, which was set up to allow people in Pakistan to view Blogspot blogs since they have a similar blockade in place, is another workaround, as is using a public proxy server or the Tor network using something like Torpark.

In 2003, a similar government diktat to block a specific Yahoo! Group had caused all Yahoo! Groups to become inaccessible from India. Thankfully that situation was resolved quickly and let's hope this issue is too.

A clueless bureaucracy eagerly assisted by a servile and clueless set of ISPs is not good news. Where is a cluebat when you need one?

(Originally posted on Blogspot.)

[2006-07-14] GCC Summit 2006

Just FYI, the proceedings of the GCC Summit for 2006 are now available online. They usually make for interesting reading for those even mildly involved with GCC in particular or with compilers in general.

(Originally posted on Blogspot.)

[2006-07-11] “Year's Best Graphic Novels, Comics and Manga”

“Year's Best Graphic Novels, Comics, and Manga”, edited by Byron Preiss and Howard Zimmerman, is a collection of short snippets from graphic novels, comics and manga published between May 2003 and December 2004.

Read More...

[2006-07-10] Presentation Skills

Most of us geeks seem to think that presentation skills are something for the marketroids or the suits to worry about. Even if we do have to present something, we only have fellow geeks in the audience who ought to be able to understand what we are talking about. However, geeks are humans too and humans need you to take care of certain things in your presentation for them to be able to fully appreciate and understand what you are talking about.

For example, in FOSS.in/2005 most of the talks were about cool stuff but in my opinion many a presentation left a lot to be desired. Among the talks that I attended, Jim Zemlin's talk about the Linux Standards Base was one of the precious few where the speaker seemed to understand and care about the basics of presentation.

Here are a few suggestions for speakers based on personal observations:

I can go on and on like this, but most of these points are obvious if you have any common sense or if you observe a good speaker. You can also search the web for a great deal of material on presentation skills. If your company offers a training on presentation skills, take it instead of sniggering and dismissing it as something for "losers".

Finally, here are a few suggestions for presentation attendees:

Once again, you would think that all of this is common sense but it is surprising how many people are willing to forget all of these when they attend a talk.

(Originally posted on Blogspot.)

[2006-07-08] Books on C and C++

Tarandeep asked me what books on C and C++ I would recommend for someone who knows a bit of each of these programming languages. My problem is that I do not generally like reading books specific to a given programming language. In addition, I do not know C++ properly enough to be able to discern a genuinely good book on C++ from a mere pretender. He still insists that I write down a list of such books. I am therefore putting this list as a blog post in the hopes that people more knowledgeable about such things would help him out. We did search for such lists on the web but I was frankly not satisfied with the lists that we could readily find.

Here are the books on C that I would readily recommend:

  1. "The C Programming Language", Second Edition, by Brian Kernighan and Dennis Ritchie.
  2. "Expert C Programming - Deep C Secrets" by Peter van der Linden.
  3. "C Traps and Pitfalls" by Andrew Koenig.
(See also: List of books recommended in the comp.lang.c FAQ.)

Here are the books on C++ that I think should be useful:

  1. "The C++ Programming Language", Third Edition, by Bjarne Stroustrup.
  2. "Effective C++", Third Edition", by Scott Meyers.
  3. "Essential C++" by Stanley Lippman.
I did not particularly like Stroustrup's book, but it served as a useful reference when programming in C++.

By the way, many people do not like "The C Programming Language" but I am one of those who just love this book. It is a short book that is always to the point and has examples that teach you a lot about computer programming techniques and style. I agree that you should already know a bit about computer programming to fully appreciate this book. It was the book that I used to learn C. I love all of Brian Kernighan's books in general. He is one of the very few authors who have actually imbibed the lessons from "The Elements of Style".

In India, we have a few books on C and C++ written by some Indian authors that are terrible in my opinion but that unfortunately have been mandated as text books in several colleges here. The result is that many of the graduates who have not been exposed to other books form extremely warped ideas about these programming languages and about things like pointers. Sad.

(Originally posted on Blogspot.)

[2006-07-06] Pricing Your Time

We often hear clichés like "Time is Money" or "Lost Time is Lost Money". Most of us generally agree with these assertions but do not actually try to quantify the money associated with our time. We therefore rely on our intuition or mood to decide whether it is worth it to do something ourselves or pay someone else to do it on our behalf.

For example, does it make sense for us to fill out the relevant form and file our income tax returns ourselves or should we just pay the fees to an agent who will do it for us?

Suppose the agent charges 200 rupees for this service, you drive a motorcycle that gives you about 48 kilometres per litre of petrol in city traffic conditions, the price of petrol is 55 rupees per litre, the distance to the income tax office is about 15 kilometres and the parking attendant there charges 2 rupees. If you were to file the returns yourselves (filing income tax returns online is not yet fully available in India), you will directly incur a cost of about 36 rupees in fuel and parking charges. Assuming that it takes about 15 minutes for you to fill the form yourself and about 60 minutes for the trip to the income tax office and back, is it worth saving this time and pay the agent an extra 164 rupees for his service?

A couple of my friends and I used to amuse ourselves by trying to calculate our time's worth using our salary as a guide. Assume that your annual salary is about 4,00,000 rupees, your employer expects you to work about 8 hours every day from Monday to Friday and grants you a leave of 15 days in a year. With about 52 weeks in a year, that is about 246 working days or 1,968 working hours. This means that your employer is willing to pay you about 203 rupees for every working hour.

So in this particular case, at least from your employer's perspective, it is better for you to pay the agent the extra 164 rupees that he is asking for rather than waste about 254 rupees in lost (hopefully productive) time.

Technically we should also consider other factors like the price we are willing to pay to save ourselves the effort (in addition to the time) involved in the task, the amount of trust we place in the agent to do the job correctly and on time, our willingness to share the information about our income with a third party, the amount of masochistic desire we have to do our job ourselves, etc. This is therefore a very crude measure of the monetary value of your time.

A professor of Economics has come up with another formula to calculate the monetary value of your time and you might have your own method of calculating this value. Whatever method you use, these methods can be used to quickly tell if it could be worthwhile to do something ourselves or pay someone else to do it for us.

(I wrote this piece purely for its amusement value - it should not be taken too seriously and should merely be used as an indicator in the spirit of Burgernomics.)

(Originally posted on Blogspot.)

[2006-07-03] Superman Returns

I watched this movie over the weekend and was somewhat disappointed. The special effects were decent and more natural than in the original series of movies, as was to be expected, but the plot just had so many holes and the acting was so so-so that I was wondering how Bryan Singer and Kevin Spacey who gave us "The Usual Suspects" could have also given us this.

The New Yorker's Anthony Lane has written a far more eloquent critique of the movie than I can ever hope to write, but I would add that Brandon Routh is also about as good-looking as Christopher Reeve and is unfortunately about as wooden an actor. Of course, they are still nothing compared to Keanu Reeves when it comes to having a consistent lack of expressions throughout a movie. Perhaps having a chiseled good-looking face implies that your facial muscles are in a permanent rigor mortis.

There are some things that I would never understand about superhero stories. For one, why do they always have the same villain in story after story either as the main villain or as a willing aide to the main villain? Superman has Lex Luthor, Batman has the Joker, the X-Men have Magneto, He Man has Skeletor, etc. Do fans never get tired of seeing the same villains bugging their superheroes in episode after episode? Do they never wonder that if their superhero is all he is chalked out to be, why he is not able to get rid of this villain for good? Are they in fact aware of this irony and actively relish it?

Another thing that bugs me about superheroes is the need for almost all of them to have a mild-mannered alter ego. Why? And why can't other people recognise them in most of the cases? Clark Kent as the alter ego of Superman is particularly worrisome - does the addition of spectacles so change the facial appearance of a person that even someone close to them, like Lois Lane is to Superman, is unable to recognise them?

Yet another thing that really irritates me about superhero stories is the mess that all the hundreds and thousands of stories and story branches create. Again, Superman is the perfect example of this mess. Are there Supergirl, Superboy and Krypto, the Superdog, or not? Does Superman have a son or not? Has Superman died or not? Et cetera. What is the canonical Superman storyline?

Finally, why do most superheroes wear their underwear outside of their tights? What is it about superpowers that affects their sartorial sensibilities? In our college, a mild form of ragging involved the seniors making the freshers wear their underwear outside of their trousers, tying a bedsheet or a shawl around their neck as a cape and making them run down the corridors of hostels screaming "I am Superman!". Some of my friends would also remember our batchmate, who is now a banker in Bombay, running through the corridors of our hostel one night in an obviously inebriated state and clad only in an underwear and a bedsheet tied around his neck screaming "I am Superman!".

(Originally posted on Blogspot.)

[2006-06-30] Separating Debugging Information

Debugging information in an executable usually takes up a lot of space so developers usually "strip" an executable before shipping it. This however makes it difficult to diagnose problems in your programme reported by the users, especially when a problem is only reproducible in the reporting user's environment.

Microsoft's development tools support creating a separate "Program Database" (PDB) file for an executable containing debugging information for the executable. Its diagnostic tools support reading a PDB file for an executable , if one is available, to generate a more usable diagnostic report for a fault. You ship stripped executables to your users and when they report a fault, you ask them to install the corresponding PDB files to help you get a better diagnostic report. I think that this is a nice idea and I used to wonder if the GNU toolchain would ever support something like this.

Danny Smith pointed out to me that something similar is already supported by recent versions of GDB and binutils. You can use the --only-keep-debug option of objcopy for this purpose. For example:


gcc -g hello.c
objcopy --only-keep-debug a.out a.dbg
strip --strip-debug a.out


a.dbg now has the debugging symbols and a.out has been stripped of debugging symbols. When you want to debug a.out you can use:


gdb -s a.dbg -e a.out


Simple.

(Originally posted on Blogspot.)

[2006-06-29] Tales of Human Resources

In an organisation that I once worked for, the Human Resources department was particularly prone to engaging in activities and issuing diktats that were rather Dilbert-esque. Here I recount a couple of egregious examples of this behaviour that unnecessarily damaged the careers of several employees for absolutely no fault of their own.

At that time, the employees in that organisation were awarded grades every year reflecting their perceived performance based on appraisals by their peers, their seniors and anyone working under them. The grades ranged from A (exceptional) to D (unsatisfactory) and affected how much of a hike in salary (if any) you get when the next round of salary hikes takes place. They also affected the chances of your promotion.

Someone in the HR department read somewhere that the distribution of these grades in a large organisation usually follows the bell curve of a normal distribution with a few employees being graded exceptionally good or marked unsatisfactory and most employees being graded good or merely satisfactory. This person then made the leap of logic in deciding that the distribution of these grades must necessarily look like a bell curve and that too for each team in the organisation!

Needless to say, this had a very bad effect on some teams and our team was affected especially badly. Our team was assembled by hand-picking the best people from a lot of teams across the organisation to work on a particular project that the company perceived to have a lot of potential at the time. It was natural for almost everyone in the team to perform well and the managers mostly awarded Bs and As. The HR department, of course, would have none of this. The distribution must be "normal" across the team and all the pleas of the managers fell on deaf ears. The result was that some of our team members were awarded a D even though they had done good work throughout the year! This had a predictable effect on employee morale. A lot of people from the team left the company very soon.

The same organisation also had an unwritten rule of letting go of the bottom 5% of the employees of the organisation every year judged by their performance. The merits of this kind of a rule is, of course, debatable but once again a diktat from HR made it even more damaging. They decreed that every team should let go of the bottom 5% (rounded up to the nearest whole number), irrespective of whether there was actually anything unsatisfactory about the affected employees. Once again managers pleaded in vain with HR and were helpless as useful team members of a project were unnecessarily laid off. The crazy thing is that hiring continued to go in full swing during this period. Some managers thought they could take advantage of this and hire back the laid-off workers but HR nipped their plans by reminding them of the policy that an employee could not join the company after leaving it for a period of at least six months.

These incidents were not only devastating for the morale of the employees directly affected, but they were also depressing for the rest of us. Ironically, one of the purported aims of the HR department was to devise ways of boosting employee morale. Their actions however had the exact opposite effect.

(Originally posted on Blogspot.)

[2006-06-25] Rolling in Money

"Is Indian IT getting too expensive?" is an article in The Times of India that is a perfect example of the reckless and utterly irresponsible journalism that is increasingly becoming the norm for this newspaper. While the general thrust of the article is more or less correct, either the reporters in question or the "analysts" they consulted seem to have simply made up all these numbers. Believe me, it is not at all the norm to pay a guy with 10 to 15 years of experience an annual salary of 1.5 to 2 crores Rupees (about 330,000 to 440,000 USD)! The numbers are off by about an order of magnitude. I also think a salary of 70,000 USD for a middle-level manager in the US as stated in the article is a bit on the lower side, though I cannot be sure. As a couple of us were joking upon reading this article, these guys should have published the names of the companies which supposedly pay such salaries so that all of us can apply for a job with such suckers. On the other hand, such a company will not last long because it will quickly drain out its cash reserves doling out such largesse.

Unfortunately, these are precisely the kind of stories that unnecessarily widen the divide between software engineers and other sections of the society. They also unnecessarily make software engineers a lucrative target for robbers and other criminals. They create frustration among gullible engineers who think they are never paid enough for their job, even if they are already being paid far more than they deserve. They cause engineers returning to India from the US and elsewhere to demand really outlandish salaries for a job.

Pathetic.

(Originally posted on Blogspot.)

[2006-06-23] Mathematical Digressions

In my previous post, I said that the sum of the geometric series:

1 + x + x2 + ... + xn-1

is (xn - 1)/(x - 1). One of my beliefs (as also shown by that post) is that you should never take a formula at its face value. Here I quickly attempt to show why this particular formula should be correct using a very commonly used proof. Let us assume that S denotes the desired sum. That is:

S = 1 + x + x2 + ... + xn-1

If we multiply both sides of this equation by x, we get:

x×S = x + x2 + x3 + ... + xn

If we subtract each side of the first equation from the corresponding side of the second equation we get:

(x - 1)×S = x + x2 + x3 + ... + xn - 1 - x - x2 - ... - xn-1

This simplifies to:

(x - 1)×S = xn - 1

which gives:

S = (xn - 1)/(x - 1)

as we had claimed.

By the way, while attending a conference call last night where it was particularly hard to concentrate on what was being discussed, I began to doodle and stumbled upon a simple result which might have been interesting about a millennium ago and is probably just an idle curiosity now. I am also sure it is contained somewhere in our high school text books for mathematics, but I cannot recall seeing it before. (Despite what might be indicated by these blog posts, I do not have much of an interest in mathematics itself and have never pursued it for its own sake.)

Anyways, looking at the factorisation of (x2 - y2) into (x - y)×(x + y) and (x3 - y3) into (x - y)×(x2 + x×y + y2), I wondered if (x - y) is always a factor of (xn - yn). By playing around a little bit with the terms, I could write:

xn - yn = (x - y)×(xn-1 + xn-2×y + ... + x×yn-2 + yn-1)

confirming my hypothesis. If you set y=1, this reduces to:

xn - 1 = (x - 1)×(xn-1 + xn-2 + ... + x + 1)

which can be rewritten as:

(xn - 1)/(x - 1) = xn-1 + xn-2 + ... + x + 1

which is the same formula that we derived just a while back for calculating the sum of a geometric series!

(Originally posted on Blogspot.)

[2006-06-23] Calculating EMIs

Most of the software engineers I know here in Bangalore have either already bought a house or are planning to buy one. The biggest incentives are perhaps the easy availability of home loans at interest rates far lower than that available to the previous generation and the tax-breaks one gets here in India on the principal and the interest paid on home loans. Our generation is also not averse to taking on a debt unlike the previous generation. In addition, many of us feel that it is better to take the plunge now and enjoy the comforts of your own house than to diligently save all the required money for years and then buy a house, only to find out that the dream was realised a bit too late in your life.

Read More...

[2006-06-22] Libraries

I really miss having access to a well-stocked and conveniently accessible library of books here in Bangalore. I really like reading books and it is not possible for me to buy all the books I fancy reading. It is not just a question of being able to afford these books; I do not have enough space in my home to stock all such books and they are a pain when moving houses.

Read More...

[2006-06-20] Sports

The football world cup is messing with my sleep patterns but I do not mind it at all. It is one of the most wonderful games to watch (and play), especially at this level of competition. What is especially amazing this time round is the fact that little countries like Trinidad and Tobago, Cote d'Ivoire, Ghana, etc. are playing so well against the "big guys" of the game. (With a population of around a billion each, neither China nor India seem to be able to put together a team of just 11 men who could compete at this level.)

Unlike most of my countrymen, I do not enjoy watching cricket at all - I cannot fathom how people can spend an entire day watching a game like this (for the "shorter" one-day matches) and (even worse) how they can spend five days watching the longer test matches where most of the time the result is a frustrating draw! Do people really have so much free time on their hands? Cricket is also a frustrating game to play - if you are neither a good batsman nor a good bowler (as I was), all you can do is wait in the field for the ball to come over to your nook of the universe to brighten up your otherwise utterly dull existence. Football, Volleyball, Basketball, etc. on the other hand are such wonderfully participatory games.

By the way, even though I quite like playing Pool and Bowling myself, I cannot watch these games being played at the professional level since the players have become so perfect! Seeing one strike after another in Bowling or seeing all the target balls being pocketed perfectly and the cue ball being positioned perfectly for the next shot every time in Pool ceases to remain interesting for me after a while. Watching the Chinese or the Koreans play Table Tennis is a similar experience for me - they are so perfect. That way Tennis and Football are a long way from being perfected though the professional players are fairly good and are therefore still very exciting to watch. I hope they never perfectly play the game of Tennis (e.g. hitting an ace on every serve) or Football.

(Originally posted on Blogspot.)

[2006-06-16] Spam

Gmail is pretty good at detecting and filtering out spam, but these days a lot of spam is making its way past Gmail's filters. Spammers have started sending emails where images show the text of the email, leaving no hope for Gmail's filters to process the text to determine if its spam or not (unless of course they use an OCR software, in which case the spammers might resort to using captcha-like text in the images, ad nauseum). I have also started receiving a lot of spam in languages like Chinese and Spanish (perhaps Portuguese, I can't tell), again something that Gmail's filters apparently can't process.

A big irritant on Gmail is its single biggest misfeature (in my opinion) - mails delivered to, say, "r.mathew" are delivered to me ("rmathew"), filling my inbox with random (sometimes personal) mails. They try to justify it as a feature, but since they let people register usernames with a period for a while, this can either get very amusing or very irritating for a lot of people depending on their disposition. Why can't they just stop implementing this "feature"?

Anyway, I have now become used to quickly scanning the subjects and senders of the mails in my inbox to select and "Report Spam" the ones that are obviously spam and then proceeding to read the mails in my inbox.

(Originally posted on Blogspot.)

[2006-06-15] Driving In India

This video shows an example of how people drive in Indian cities. This is unfortunately not an exaggeration - for example, the junction of Taverekere Main Road and Hosur Road near my office building has a traffic pattern very similar to the one shown by this video. I come to work every day driving through such traffic. No wonder foreigners find it very difficult to drive in Indian cities and Indians find it very difficult to control their urges in foreign cities.

(Originally posted on Blogspot.)

[2006-06-14] “V for Vendetta”

“V for Vendetta” by Alan Moore and Dave Lloyd is the graphic novel that was the inspiration for the eponymous movie by the Wachowski brothers. I was quite impressed by the movie and was eager to read the book. The book did not disappoint me at all. I found out that the movie and the book had many differences in the plot and the characters, but for once I did not mind it - in fact, I quite liked each of the forks in both the media.

Read More...

[2006-06-12] GCJ for MinGW

I have updated my article "Building GCJ for Windows" and the associated scripts to work with the current SVN mainline sources of GCC (to be released as GCC 4.2). They might also work with GCC 4.1 sources, but I have not checked it myself. The article also has some tips for building GCC natively on Windows using the MSYS toolkit, especially to make the built and installed GCC relocatable (see below).

A major portion of the effort went in to ensure that the resultant toolchain was actually relocatable (that is, the installation can be archived and then extracted elsewhere, possibly on a different machine, and everything can still be expected to be working). The proper locations of the Windows headers and runtime libraries and the flags to pass to the GCC configuration scripts were something that took a lot of trial and error (and a lot of help from Mark Mitchell and Danny Smith) to get right, since I was trying to do something less common (building cross and crossed-native compilers) for a platform that gets the attention of very few GCC hackers as such, if at all.

I had stopped working on GCJ for Windows quite a while back and the reason I had to update my article and scripts was that there seemed to be a lot of people trying to build GCJ for Windows themselves using the latest released or in-trunk sources (and my instructions and scripts) and they were running into all sorts of issues. Unfortunately, GCJ on Windows has become worse than it used to be which is understandable since there is no one who is actively working on it to improve it. It is also a shame since even though it is a closed platform with an ugly design it appears to have the most number of users enthusiastically willing to try out GCJ.

We must do something about this situation.

QEMU
For a fan of Linux trying to make GCJ for Windows work, a very useful property of GCC is that it can be built on Linux as a cross compiler or as a crossed-native compiler targetting Windows. For a person with a relatively old machine and limited free time to hack on GCJ, this is also important since the build on Linux is way faster and far more reliable than that on Windows itself using MSYS. Equally important is the ability to test out the binaries created in this process without having to reboot the machine into Windows or having access over the network to another machine running Windows. Wine doesn't quite help since I need an environment that is as faithful to the real thing as possible.

QEMU running Windows on Linux comes to my rescue here. When run with the -kernel-kqemu option using the QEMU Accelerator ("kqemu"), the guest OS runs at very close to native speeds without adversely affecting the performance of the host OS. It has a built-in TFTP server that allows you to easily transfer files from the host machine into the guest system (there are also other ways of achieving this using QEMU, but this is the simplest). It's almost magical and is immensely useful. It's no wonder that virtualisation is becoming so popular these days and every developer who has tried it out sings its praises. If you are an "enterprise software" developer, you should already know what I am talking about. If you haven't tried it out yet, you really should. Virtualisation offers you the freedom and the flexibility to play around that is very useful and quite addictive.

(Originally posted on Blogspot.)

[2006-06-07] “W”, “A” and “D”

Tarandeep gave a short presentation on JavaServer Faces the other day and I couldn't help but wonder how similar it was to the "W" web-application development framework that we had developed about seven years ago when I used to work for "T".

"W" was an MVC-based framework written in Java that encouraged you to build your web-applications as a composition of reusable components rather than as monolithic one-time efforts. Since "T" used to build a lot of web-applications for its clients, we found ourselves doing some things over and over again, with only slight changes in look-and-feel and functionality for different applications. To save ourselves time and effort (which meant you could do the same stuff for lesser money - a big advantage over your competitors in the cut-throat software services industry), we developed the "W" framework and used it in our work.

"A" was a similar framework developed around the same time to provide a set of services that were needed by almost all the Java web-applications we were developing (user management, security, licensing, accounting, logging, caching, etc.). This framework provided the infrastructure that an Application Service Provider (ASP) could utilise to quickly build and deploy web-applications, provide detailed reports on their usage by its customers and create invoices based on the pricing scheme applicable to a customer. Its name however was an unfortunate misnomer since most of the framework was useful for almost all Java web application developers, not just ASPs. ASPs also quickly went out of fashion and many people didn't want to touch anything related to ASPs with a barge pole.

"D" was yet another Java application framework we had developed for implementing simple distributed workflows. Once again, it was born out of a necessity to reliably and quickly implement workflows that were a part of many web-applications we developed for our clients. It supported a simple and straightforward XML-based format for defining workflows, several out-of-box actions, a graphical workflow designer application, etc.

The sad thing is that none of this really went anywhere. We tried to turn "A" and "D" into products ("W" was deemed "too fundamental"), but being a company primarily focussed on software services and struggling to survive in the post-dot-com-boom era and the havoc caused by the events of 11 September 2001, we just couldn't devote enough resources to polish these and effectively market them. We also tried to donate "A" to the Apache Jakarta project (yes, the approach was extremely naive of us) with disastrous results. "A" was used by one ASP. These frameworks were used in a few applications for the company intranet and in a few applications developed for its clients, but as far as I can tell, they are no longer in use. In fact, I couldn't even locate the blurb on these frameworks and the associated white-papers on the website for "T". I think they are dead for all practical purposes.

R.I.P.

I am not saying that any of this was insanely great and necessarily deserved to succeed. In fact some of the aspects of the design of these frameworks reflected the naivete of its inexperienced designers (yours truly being one of the prime culprits) that can only be cured by years of experience with solving hard problems in real applications. I am also not saying that no one else had thought of these things at that time or had built frameworks or products around these ideas. What I am saying is that there were aspects of these frameworks that could have helped a lot of people save time and effort on building Java-based web-applications, much before the tools that are now available made their appearance, if only we had created a better awareness of these frameworks and promoted them differently.

There were several good things that did come out of these frameworks though. I learnt a lot about proper object-oriented design and architecture by working on them. I found out just how completely different creating a software product is compared to providing turnkey solutions for your clients. While promoting "A", I got a chance to experience the wonderful city of Amsterdam for over a week. Most of the people in the team that created "A" have become some of the best friends I've ever had - one of them, Anusha, is now my wife. There is a silver lining to every dark cloud in life.

Update (2007-08-06): Replaced the actual names of the products and the company with their initials on a request from "T" - Google was ranking this page too highly for their comfort.

(Originally posted on Blogspot.)

[2006-06-06] Graphic Novels

I am quite intrigued by graphic novels and look forward to reading some of them, especially those by Alan Moore. I was therefore very happy when I spotted some graphic novels in Landmark, Blossoms and Crossword here in Bangalore. The happiness was rather short-lived as I discovered that they were quite expensive. There is no way I am going to shell out 800 rupees for such a thing when I don't even know if I am going to like it and especially since many of them are in a rather battered condition probably caused by many people browsing through them but then deciding to not buy them.

(Originally posted on Blogspot.)

[2006-06-03] GCJ and ECJ

RMS has finallly agreed to using ECJ to generate bytecode for GCJ!

That sound you hear is the huge collective sigh of relief heaved by Free Java hackers everywhere.

(Originally posted on Blogspot.)

[2006-06-02] I Blog in Your General Direction

Yumpee considers blogging an act of vanity and inanity. Of course, he doesn't actually refrain from reading such blogs himself and would sometimes tell you a couple of things based on one of your posts accompanied by his trademark smirk.

Steve Yegge has a very nice writeup on why one should blog and I will not repeat here what he says there - it is a must-read for all people who think blogging is a completely wasteful activity. I would just add that I personally use my blogs and website as a sort of a Pensieve (what Dumbledore uses to store some of his memories in the Harry Potter series of books), except that I like to record my thoughts too instead of just memories. Sometimes I look at what I wrote a few years ago to see what I was intrigued by or interested in back then and occasionally I can't help but be embarrassed or amused by what I see. It still does not stop me from blogging though, mostly for the reasons that Steve points out in his article.

I have found out that blogs tell me a lot more about a person beyond what I can learn from everyday interactions with him or her. For example, Vikgup, Arpana, Anupama and Mridula have blogs that showed me aspects of their personality and areas of their interest that I had absolutely no inkling about from my conversations with them. If you do not blog yet, go forth and blog (and send me the URL for your blog).

By the way, despite my (admittedly mild) pleas to the contrary, Mark has added this blog to Planet Classpath as well. If you see posts in Planet Classpath via this blog about stuff not related to GCJ or GNU Classpath or Free Software or even technology, you now know who to blame for it.

(Originally posted on Blogspot.)

[2006-05-31] Moving

I am now moving to rmathew.blogspot.com for blogging. I find Advogato a bit painful to use for blogging. I also do not want to be restricted to only talking about hacking on Free Software.

(Originally posted on Advogato.)

[2006-05-31] Hello World

I will now be using this weblog instead of my Advogato diary.

(Originally posted on Blogspot.)

[2006-05-31] GCJ: Quo Vadis?

Andi Vajda asked whether GCJ would cease to exist if Sun were to release the source code for Java and its tools under a really Free licence. I have also seen such questions asked on Slashdot, OSNews and other fora.

The response from Andrew Haley mirrors what I personally think of the situation - as long as there are hackers willing to maintain it, GCJ would continue to exist. Miguel de Icaza says that among the two types of hackers who usually work on Free Software in their spare time, GCJ and GNU Classpath only attract the Free Software idealogues and not those who want to get something free (gratis) working for them since Sun's JDK already works well for them and is free. Tom Tromey has a more philosophic take on the current situation - almost ascetic in fact. All this is enough to make a GCJ or GNU Classpath hacker reflect on the current state of Free Java, the utility of his contribution to it and the impact of a fairly Free release of Java source code from Sun. Despite being an extremely erratic contributor working on the fringes of Free Java, I cannot help doing the same.

It was about four years ago that I first flirted with GCJ. I wondered, for no particular reason as is usually the case with me, if it was possible to use GCJ to create native GUI applications with SWT in Java on Windows. I found out that the support was almost there and with a little effort and a lot of support from the GCJ hackers (especially Tom), I was able to add in that support and contribute it back to GCJ where it was accepted with minor modifications. That was my epiphany with Free Software. Until then I was more impressed by the fact that I could get so much decent-quality software for free than the liberty to make modifications to such software. But now I began to realise that having the source code available to you meant that you could change it yourself to fix its shortcomings and share your improvements with the other users. It also meant that the availability of the software did not depend on the solvency of the vendor or its willingness to maintain it. There were many other factors in favour of Free Software that became apparent to me over time. Suffice it to say that I finally understood what that twitchy, smelly and passionate preacher of Free Software was talking about all the time.

In time, my original itch died out (like so many of my digressions in life) but I continued to work on GCJ. I quickly moved from Windows to Linux (since that was the only platform that I enjoyed working on) and began fixing front-end bugs more out of a desire to help folks than to fix anything that was affecting any of my personal or professional work. This played a part in the fact that my track record with GCJ has been absolutely abyssmal (except perhaps in the area of contributing the most noise to the GCJ mailing lists). My pathetic time-management skills and a propensity to be carried away by even the slightest distraction have also played a big role. Since I worked on GCJ in my free time at home and I did not want to compromise too much on my personal life (spending time with my family, watching movies, reading books, meeting friends, getting enough sleep, etc.), I rarely found the time to debug and test anything except the most trivial of bugs. Finally, my tendency to "wait and watch" (first for GCJX and now for ECJ) has not helped matters much either.

There are some inherent problems with GCC and GCJ too. The GCJ front-end seems to have been written in a hurry in order to get as many things working as fast as possible with not much thought given to overall maintainability. The people who originally wrote it have moved on to other things in life leaving others with little idea of how it all works. Subsequent hackers (including me) have always made incremental changes to fix immediate issues rather than perform any big refactoring of the code, with the natural result that the code has become even more unwieldy now than before. To fully bootstrap GCC, especially with checking enabled, and then to run its testsuite takes an awful amount of time, especially on slightly older hardware (like my otherwise perfectly capable P3-based system). This is a huge barrier for most prospective hackers. (I reserve my rant about the disastrous effects of bundling several language front-ends and their ever-bloating runtime libraries into a single compiler system for another day.) Until recently, the ubiquitous tree data structure was used in funky ways for almost everything in GCC. There is precious little documentation for a programme of this complexity and some parts of this documentation is out-of-date. The best way to understand stuff in GCC is to read through the source code, to watch the operation of the relevant parts in a debugger and to ask questions on the mailing lists when you do not understand something even after doing all this.

All these are problems that can be overcome one way or the other. The biggest problem with GCJ however is the sheer paucity of hackers willing to work on it to improve it compared to the number of people willing to use it and reporting problems with it. This situation is particularly severe for Windows. Were it not for Red Hat's sponsorship of some critical GCJ hackers (and the heroic efforts of Tom in particular), GCJ would have been in a very bad shape by now. This situation really makes me realise how true Miguel's observations are with respect to hackers of Free Software and Free Java.

A Free Java from Sun would not obviate the need for GCJ though. I personally feel that ahead-of-time compilation to native code providing more opportunities for aggressive optimisations (platform-agnostic as well as platform-specific) and a more straightforward integration with C/C++ via CNI are enough to show the utility of GCJ orthogonal to the status of the freedom provided by Sun's JDK.

This post has already become the longest I have ever posted, so I will reserve my rant about how Java the language and its bloated "standard" runtime is not even worth spending so much time and effort on in the first place, for another day.

(Originally posted on Blogspot.)

[2006-05-29] “Softwar”

I did not want to read “Softwar” by Matthew Symonds at first. I thought it would be just like the numerous other biographies endorsed by their subjects that are so common these days and that are utterly banal and filled with nauseating flattery of their subjects. I also felt a bit weird for some reason reading about the company (and its CEO) that employed me.

Read More...

[2006-05-17] Google and Maths

"Fuzzy Maths", an article on Google in the latest edition of The Economist, contains this interesting bit:

Google constantly leaves numerical puns and riddles for those who care to look in the right places. When it filed the regulatory documents for its stockmarket listing in 2004, it said that it planned to raise $2,718,281,828, which is $e billion to the nearest dollar. A year later, it filed again to sell another batch of shares -- precisely 14,159,265, which represents the first eight digits after the decimal in the number pi (3.14159265).
Their famous recruitment campaign and their very name further reinforce the impression of their obsession with Mathematics.

(Originally posted on Advogato.)

[2006-05-14] “A Short History of Nearly Everything”

“A Short History of Nearly Everything” by Bill Bryson is the kind of book everyone who is even remotely interested in science, or even slightly intrigued by it, should read.

Read More...

[2006-05-10] Security: The 3 As and the 3 Rs

(I am just collecting my thoughts here; I do not require anything like this right away.) A useful framework for security should provide:

The authentication framework should be able to able to plug into various authentication mechanisms (OS-based, LDAP-based, etc.), be flexible enough to accept various types of credentials (username/password, PKI certificate, etc.) and reliably establish the "Identity" of the user. The authorisation framework should allow the specification of: Role-based authorisation allows for the maximum flexibility compared to the direct checking of the Rights of the given Identity. An Identity could be associated with multiple Roles. Realms establish domains of privileges - for example, a person has administrator privileges on his desktop PC but is just an ordinary user on the LAN. Rights could be positively stated ("Allow Foo") or negatively stated ("Disallow Bar"). Authorisation could be inclusive (at least one Role associated with the Identity has the Right) or exclusive (no Role associated with the Identity should be denied the Right). I personally favour positively stated Rights and inclusive authorisation. The auditing framework would be used for non-repudiation, so it should have integrity (only the auditing framework could have written out a given audit record) and an almost transactional association with the respective action (record an action if and only if it was actually done). Of course, in real "enterprise" software we end up with various degrees of compromise on each of these aspects.

(Originally posted on Advogato.)

[2006-05-10] Peer to Patent

The US Patents and Trademarks Office will soon try out Peer to Patent as a pilot project. This is great news. It is really important for silly patents to get rejected upfront than be granted and then used to bully everyone into either paying up an extortion fee or engaging in costly lawsuits. Unfortunately, there is still the problem of lots of such silly patents having already been granted and used for corporate "defence funds" (an equivalent of the "Mutual Assured Destruction" strategy) or towards unscrupulous ends. The Economist has a nice set of balanced articles on patents and other IP-related topics.

(Originally posted on Advogato.)

[2006-05-05] Faster Logging

When you have an application that must log information (for auditing, debugging, etc.) but still run as fast as possible, it is rather wasteful to always dump fully-formatted human-readable trace records. It's far better to dump a short binary record indicating the message identifier, parameters for the message (if any), timestamp, process/thread identifier, etc. that can be processed later for human consumption using a separate "trace formatter" tool. This way you save on processing time and disc space but make it slightly inconvenient to view the log files. On UNIX-like systems, utmp and wtmp records are created and processed this way. I have also seen this kind of logging in IBM's AIX operating system and its CICS transaction processing monitor. Why then do several modern "high-performance" applications still insist on using the slower and more bloated method?

(Originally posted on Advogato.)

[2006-05-05] Digital Cable TV and PBF

Our cable operator has switched over to Hathway for the feed and this means that we can now opt for digital cable TV. Hathway has given us a Humax ND-1000C as a set-top box to receive the digital signals on a trial basis.

Read More...

[2006-05-02] Planet GCC

There is now a Planet GCC aggregating the feeds from Planet Classpath and the blogs of a bunch of GCC hackers. If you know of a blog of a GCC hacker that is not directly or indirectly aggregated here, please let Dan know. Thanks to Dan for this initiative.

(Originally posted on Advogato.)

[2006-04-29] “Just for Fun”

“Just for Fun: The Story of an Accidental Revolutionary” is a book about the life of Linus Torvalds, the creator of Linux, till the year 2001. It has been written by Linus and David Diamond.

Read More...

[2006-04-27] Worse than the DMCA

The Intellectual Property Protection Act (IPPA) looks even worse than the DMCA. If you are a US citizen, please do what you can to campaign against this threat to your fair-use rights. The irritating thing about such laws is that they affect even non-US citizens, since other countries do not want to be seen as harbouring or encouraging "intellectual property thieves" and usually play along with whatever the US comes up with (except for the EU in some notable cases). Even more irritating for us non-US citizens is the apparent willingness of the US lawmakers to please corporates and various lobbyist groups in creating sometimes extremely draconian or irrational laws to the detriment of the fundamental rights of its own citizens (and the US citizens do not seem to mind all this very much). The appalling thing is that the magic word "terrorism" is used as a blanket weapon to silence killjoys who dare to question such travesties. The proposed PERFORM Act is another example of what I am talking about.

(Originally posted on Advogato.)

[2006-04-27] “Writers and Their Tall Tales”

“Writers and Their Tall Tales” is the second book I have read in the “Dead Famous” series of books (the first one was on William Shakespeare). It is a light book written in a humourous manner and is loaded with comic illustrations.

Read More...

[2006-04-26] Website Maintenance

I am now using GNU Make and GNU m4 to maintain my website. The main advantages of these tools over others were that I was already familiar with them and they were readily available on the platforms I work on. Some of the things that are now easily possible with the new setup:

I use the --prefix-builtins option of m4 (just to be a bit safer) and had to use different quote characters in some places because it was getting a bit confused with embedded apostrophes in JavaScript method calls and commas in normal text.

(Originally posted on Advogato.)

[2006-04-21] QEMU USENIX Paper

Fabrice's USENIX QEMU paper is now freely available.

(Originally posted on Advogato.)

[2006-04-21] Firefox Bus

A bus painted by a painter who was "inspired" by the Firefox logo.

(Originally posted on Advogato.)

[2006-04-20] HTML/CSS/JavaScript: Duh!

dorward: Thanks again for your comments. I don't know why it didn't occur to me to use GCC itself as a pre-processor. Some of the simple things I tried out worked well with GCC. I haven't checked out The Dolt yet. As for condition #2 ("JavaScript disabled, Stylesheets enabled") mentioned in my previous post on this topic, I have found a better solution to the distracting "peek-a-boo" effect inherent in my previous solution. In the HEAD of the page, I have now put:

     <script type="text/javascript"><!--       hideHiddenDivs( );     // --></script> 
where hideHiddenDivs() is defined as:
   function hideHiddenDivs( )   {     if( document.getElementById)     {       document.write(         '<style type="text/css"> div.hidden { display: none; } </style>');     }   } 
I could have put this scriptlet inline, but there seems to be a problem with the parser of the W3C validator tool which complains about a "</style>" that does not end a STYLE element.

(Originally posted on Advogato.)

[2006-04-19] HTML/CSS/JavaScript

Ankh, dorward: Thanks for your comments. For a sloth like me, it's not easy to once again overhaul the entire site to make it XHTML - I'll let it remain at HTML 4.01 for the time being. By the way dorward, I did not know until very recently that unlike XML, things like "<br/>" are not valid HTML elements. I used to insert "<br/>", "<p/>", "<hr/>", etc. liberally throughout my pages mistakenly thinking it's the "right" thing to do. A rant: I don't know much of HTML/CSS/JavaScript, but I really wish for the ability to "#include" files (for example, for page headers and footers) and to define macros (for example, to generate a news item's headline and content elements linked to each other). I know these can be overcome by using JavaScript and document.write(), but that's a kludge. I also know that these can be achieved on the server, but I do not want to depend on it - I keep moving my website from one (free) provider to another and I also like it to behave exactly the same way when accessed from my local filesystem as from a remote server. Note that we already have inclusion mechanisms for external stylesheets, scripts, etc. so this is not something too difficult to provide. Now on to something that I hope you HTML/CSS/JavaScript gurus can help me with: I'm trying to implement a handy expandable/collapsible news entries mechanism for my website somewhat similar to what is explained in this article. I have already implemented most of what I want and it can be seen in action on my site, but it's not "right". In particular, I want this system to behave properly whether JavaScript is enabled or not and whether stylesheets are enabled or not, that is, under the following conditions:

  1. JavaScript enabled, Stylesheets enabled
  2. JavaScript disabled, Stylesheets enabled
  3. JavaScript enabled, Stylesheets disabled
  4. JavaScript disabled, Stylesheets disabled
My implementation works right now under #1. For doing #2, I make the stylesheet actually declare "hidden" elements as visible, but then use JavaScript attached to the "onload" event of the page to turn them invisible - if the user doesn't have JavaScript enabled, he still gets to see all the content properly. Note that I cannot use the alternative suggested in the article I have linked to; that is, something like:
   <noscript>     <style type="text/css">       .hidden { display: block; }     </style>   </noscript> 
does not work since the W3C validator rejects it - NOSCRIPT cannot occur inside HEAD, but STYLE can only occur inside HEAD. The downside of my approach is that there is a short but noticeable and sometimes distracting phase under both IE and Firefox, where the browser loads and renders the full page and then hides the hidden sections. Isn't there a better way of achieving this while still remaining strictly valid? #3 poses a slight problem in that I wish that even the "togglers" do not appear if stylesheets are disabled. I was thinking of iterating through the stylesheets defined for the document in the DOM and check if all of them are disabled and omit emitting the togglers if they are. Is there a better way of doing this? #4 is automatically taken care of by the "solution" to #2, since only JavaScript is used to emit the togglers. The user still gets to see the entire contents. Perhaps I'm just wasting my time as #2 and #3 are unlikely to happen with real visitors to my pages - #1 is what almost all human visitors are likely to have and #4 is what almost all search engine bots are likely to have. This impractical fussing might explain why I have not become a manager. ;-)

(Originally posted on Advogato.)

[2006-04-18] “Freakonomics”

I wanted to read “Freakonomics” by Steven D. Levitt and Stephen J. Dubner since the time I read a review of the book in The Economist. For some reason or the other I kept postponing it, though I could not help but notice how rapidly popular it was becoming. Now that I have finally read it, I wholeheartedly agree with almost every praise showered on this book.

Read More...

[2006-04-17] Website Redesign

After a long procrastination, I have finally updated my website to be more standards-compliant, better looking and somewhat easier to navigate. I wanted to shift completely over to XHTML but that has its problems besides lack of support in Internet Explorer. I have therefore settled for HTML 4.01 Strict. Every page on my website should now validate with the W3C validator. To enhance the looks of the site, I am using a variant of the Sinorca 2.0 design created by haran and provided by OSWD. I stumbled upon OSWD while admiring the recent makeover of Tom's site (which uses the Blue Haze design also created by haran). While I was at it, I renamed the folders and files that had names like "phartz", "philez", etc. - these names had looked "kewl" half a decade ago, but now look rather juvenile. This results in some of the links posted elsewhere becoming invalid and I apologise to anyone affected by this change. I have also implemented support for simple expandable and collapsible sections so that some of the pages do not appear intimidatingly verbose. Right now the website is mostly an exercise in vanity. I need to add content that is actually useful so that someone other than googlebot finds the website interesting.

(Originally posted on Advogato.)

[2006-04-17] GCC and Google Summer of Code 2006

GCC is looking for students interested in working in Google's Summer of Code on a project helping GCC.

(Originally posted on Advogato.)

[2006-04-16] Website Redesign

After several years, I have finally redesigned the entire website making it far more standards-compliant. All the pages should now have strictly valid HTML 4.01. The presentation is driven by stylesheets, allowing me to change the look-and-feel of the entire website very easily. I have also implemented a simple system for expandable/collapsible news entries that should make it easier to read the main page. I expect a few glitches from a site redesign of this magnitude, so please let me know if you encounter any problems.

[2006-04-07] ZINC

ZINC is a variant of the game of Core War in which programmes (called "warriors") fight each other in a battle to control a virtual computer. The programmes are written in a simple language called Redcode and run inside an emulator known as Memory Array Redcode Simulator (MARS). ZINC implements a simpler and more symmetric dialect of the Redcode language than the current International Core War Society (ICWS) standard known as ICWS-94. To get a feel for ZINC and Redcode, look at the following simple warrior:

       ; Bomb every fourth cell in the core with a "DAT #0".       org start     target:       dat #0     start:       add #4, $target       mov #0, @target       jmp $start 
Redcode looks very similar to the assembly language of many modern microprocessors. A DAT #0 instruction indicates the number 0 stored as the datum at that location in memory. This instruction is itself encoded as 0 and is not executable - an attempt to execute this instruction leads to the death of a warrior. So the warrior shown above (called "Dwarf", a classic Core War warrior) bombs every fourth location in the core in the hopes of fatally wounding an opponent. Note that Core War only supports relative addressing and @ represents indirect addressing (the location pointed to contains a pointer to the final location). More details, including a tutorial for beginners, are available in the ZINC User Manual as well as on sites like www.koth.org and www.corewar.info. There is also an active USENET newsgroup rec.games.corewar for Core War enthusiasts. ZINC is currently at version 0.1 and is Free Software released under the GNU General Public Licence (GPL). By the way, I expect to receive a lot of flame for my decision to not recognise TAB characters as whitespace in the Redcode dialect implemented by ZINC.

(Originally posted on Advogato.)

[2006-04-07] GCJ

I seemed to be in my elements on the GCJ list this week, provoking a thread on the lack of good support in GCJ for Windows and eliciting a reply from the GCC Steering Committee on the status of the proposal to integrate ECJ into GCJ.

(Originally posted on Advogato.)

[2006-04-06] ZINC (“ZINC Is Not CoreWar”)

I am pleased to announce the release of ZINC. ZINC is a variant of the game of Core War in which programs fight for the control of a virtual computer.

Read More...

[2006-04-03] More Front Ends in GCC

One of the great advantages of structuring a compiler such that the front-end, the middle-end and the back-end are relatively independent is that if you write M front-ends and have N back-ends, you get M*N compilers "for free" assuming you have a good enough intermediate representation in the middle-end. This idea was discussed as far back as the 1950s and UNCOL was an ambitious effort towards this goal. GCC is a stellar example of such a compiler - it supports C, C++, Java, Ada, etc. "out-of-the-box" and can target a whole bunch of platforms. You implement a language front-end for GCC and you immediately have a compiler for that language for a whole lot of platforms; you implement a target back-end for GCC and you immediately have compilers for several languages for that platform. Of course, this is grossly oversimplified, since you have to usually port the language runtime to a platform too or since your language might strain the GCC intermediate representation or expose latent bugs in the middle-end making the effort rather difficult. But the overall idea still remains valid. The GNU Pascal Compiler (GPC) guys recently proposed an integration of GPC with GCC (in the same source repository, but on a different branch - weird). Some day, the GCC Scheme Compiler (GSC) guys, the PL/I for GCC guys, etc. might also want to integrate their front-ends with GCC. Having more front-ends in the GCC source tree itself means that middle-end changes do not inadvertently break these front-ends, latent middle-end bugs and unwarranted assumptions are exposed, general GCC enhancements are automatically applied, etc. So it's a good thing for GCC, in a way. However, I personally think it is not a good idea. The GCC mainline is already quite bloated with a number of languages and runtimes and building all of the languages and their runtime libraries (thank you Sun for regularly increasing the bloat in the "standard" Java runtime with every release of the JDK) takes quite a while even on a decent system. Having more languages and their runtimes within GCC will only exacerbate this issue. I personally also feel (though I have no real practical experience in this area) that it does not let the optimisers make assumptions that they can use to perform stronger optimisations. A recurring problem in this area is the folding of constants, where languages like Java specify a bit too much with respect to what can be folded and how it should be folded. On a slightly different note, the GSC guys have also created a "Hello World" front-end for GCC that shows you how to build a front-end for GCC for your favourite language. On an entirely different note, I have ended up writing 3,000 lines of text in the user manual of a 4,000 line programme (both rough "wc -l" figures)! Either the manual is unnecessarily verbose or the programme is too complex.

(Originally posted on Advogato.)

[2006-04-03] ECJ for GCJ: Still in limbo

It has been almost a month since Tom formally proposed integrating ECJ in GCJ to the GCC Steering Committee (SC). There has been no word from the SC yet on this request. However, the SC did ask the GCC developers to avoid gratuitously including source code from external projects in GCC. One consequence of this for GCJ was the removal of fastjar from the GCC source tree. I'm not sure if the SC's decision was coincidental or in fact a result of deliberations triggered by Tom's request.

(Originally posted on Advogato.)

[2006-03-28] Tatjana van Vark

Tatjana van Vark looks like an amazing Dutch inventor and machinist. Just look at her works and you'll know what I mean. My favourites were the oscilloscope that she created when she was just 14 years old and an Enigma-like "Coding Machine". I just wish they had put up some more information about the devices than just the pictures. Another of those humbling experiences for yours truly.

(Originally posted on Advogato.)

[2006-03-27] Miscellaneous

Steve Yegge is now on Blogger for those of you who can't seem to have enough of his rants. Ranjit Madampath pointed me to a rather hilarious entry on Frameworks in the Joel on Software discussion group. Planet Scheme used to be available as planet-scheme.yi.org, but it seems to be dead now. I used to like reading the aggregated weblogs of a lot of smart Scheme hackers, the weblog of Jose Antonio Ortega Ruiz in particular.

(Originally posted on Advogato.)

[2006-03-27] GNU Texinfo

I wanted to write the user manual for a small personal project that I have been working on in my free time. I wanted the user manual for the project to be available in both HTML as well as PDF and also look good in either case. I considered both GNU Texinfo as well as DocBook for this purpose, but settled for Texinfo simply because it is installed by default on almost all Linux systems and since GCC and many other Free Software projects use it for their documentation. This way, I can easily contribute to the GCC/GCJ documentation without having to learn a new documentation system, should I wake up one morning with the sudden urge to do so. Texinfo proved very simple to learn and produces fairly good looking HTML and PDF files (although some people prefer texi2html to "makeinfo --html" for HTML output). It can also output DocBook XML files, though I don't know how good the output is since I don't know the DocBook system yet. I am very happy with the tool so far. I haven't learnt a whole lot of Texinfo yet, but since when has that stopped me from making a fool of myself? There are still some warts that I see with the Texinfo system though:

These rants aside, I am still sticking with Texinfo for the documentation for my little projects, though for "paper-like" stuff, I'm going to prefer LaTeX.

(Originally posted on Advogato.)

[2006-03-23] Miscellaneous

Firefox leads to a breakup. I don't know whether I should feel sorry for the bloke who was dumped or the lady who had to change her email address possibly after being bombarded with tonnes of silly emails. I do know that I found this bug report rather funny. As I had feared, I performed miserably in the qualifying round of the Google Code Jam India 2006. Good luck to the people who moved on to the next round.

(Originally posted on Advogato.)

[2006-03-23] Assembly Language

saju's first post made me recall some of the things I miss in C which were so simple in x86 assembly language. For example, while doing fixed-point arithmetic with 32-bit operands, it was immensely useful that the CPU could hold the result of a multiplication (using MUL) in the EDX:EAX 64-bit register combination without overflow and that the same register combination could be used in a following division (using DIV), neatly separating the quotient and the remainder. The ADC ("Add with Carry") instruction was similarly useful for neatly handling overflows in addition. I don't know if you can achieve this in C without resorting to inline assembly. Readers of Michael Abrash's "Graphics Programming Black Book" and Oldskool PC coders will immediately realise what I'm talking about.

(Originally posted on Advogato.)

[2006-03-20] Miscellaneous Readings

Some random stuff to do when you're bored:

(Originally posted on Advogato.)

[2006-03-16] Wi-Fi

I bought a D-Link DI-524 wireless router the other day to set up a little Wi-Fi network at home so that Anusha and I can surf the Internet simultaneously using our broadband connection instead of one patiently waiting for (or cursing) the other - she on her laptop, me on my desktop PC. What surprised me was how cheap the equipment was (Rs 2,600/- after 4% VAT) and how easy it was to set up. There was a slight complication due to the Huawei SmartAX MT880 ADSL modem-cum-router we were using for our BSNL DataOne broadband connection and the assumptions made by the wireless router, but that is easy to resolve if you know the basics of IP (Internet Protocol). It was also relatively easy to secure the access point. Of course, this adds a few more cables to the jungle of cables behind my PC that had already made cleaning difficult and any expansion a chore. By the way, I have been seeing the prices of networking equipment (modems, switches, wireless routers) dropping drastically over the last year here in Bangalore, possibly because broadband has become quite affordable and because more and more people have a laptop or two.

(Originally posted on Advogato.)

[2006-03-08] Stevey Yegge’s Blog Articles

reddit.com regulars would have surely noticed several articles from Stevey Yegge's blogs bubbling up with a lot of moderation points. I must admit that I spent more than a couple of hours reading many of his articles. As with Joel Spolsky, I might not agree with everything he says but I have to say that he writes fairly well most of the time (though he is a bit verbose and somewhat incoherent at times).

(Originally posted on Advogato.)

[2006-03-06] A Philistine Watches “2001: A Space Odyssey”

We watched Stanley Kubrick's "2001: A Space Odyssey" yesterday. I was terribly disappointed by this movie: most of the scenes were excruciatingly long, the music (when it was present) seemed mostly arbitrary for the scene in question, the "star gate" scene seemed amateurish and long (and looked as if it was designed to induce a headache), the actors were mostly expressionless, etc. On the positive side, I admired the special effects (awesome for 1968) and was pleased to see how they were shown in a matter-of-fact manner instead of the in-your-face style so common these days. I also like the main music score that was composed for this movie and which is the recurring theme throughout the movie. The painfully long shots reminded me of the "art movies" we had to see in our childhood. At that time, the state television channel Doordarshan (literally "tele vision" in Hindi) was the only thing we could watch on TV. They used to show a movie every Sunday afternoon in one of the regional Indian languages. Being a Malayalee family, we used to watch every such Malayalam movie out of sheer loyalty. Unfortunately for us, Malayalam (like Bangla, but unlike other languages like Tamil, Telugu, Marathi, etc.) seemed to be blessed by a lot of award-winning directors who insisted on making "meaningful cinema" which was anything but meaningful to the vast majority of the population. It was very painful to sit through such movies. I still remember a particularly painful scene from one such movie (whose name I cannot recall). The first shot shows an empty and untarred village road receding into the distance. After quite a while you notice a small speck on the horizon, very slowly increasing in size, until you can make out that it is a man on a bicycle slowly approaching your viewpoint. He finally passes your viewpoint after about five long and painful minutes. The next shot shifts the viewpoint so that now you see the same cyclist slowly pedal his way through the same road away from you till he again becomes a small speck on the horizon and till you admire the empty road for quite a while again. This shot lasts another five painful minutes. This scene makes you wonder what the point of the director was. Was it to drain all remaining enthusiasm for the movie from the viewer so that he does not apply much thought to the rest of the movie? Was it to filter the true admirer of meaningful cinema, who is masochistic enough to sit through such scenes, from the wannabes? Was it simply to fill up an extra reel of celluloid? Needless to say, after about 10 or 15 of such movies, our family lost all enthusiasm to watch Malayalam movies aired by Doordarshan. Only the advent of cable television brought relief and the ability to watch normal Malayalam cinema on TV. Back to "2001: A Space Odyssey". In a couple of shots, there is this chorus of male noises in the background that has been warped to sound somewhat like the collective humming of a swarm of bees. That bit is rather painful on the ear as is the very shrill noise emitted by the black monolith on the moon when it is unearthed by humans. I personally also found some bits of well-known western classical music compositions a bit weird and out-of-place for the respective scenes. The point of this long rant is that I believe that Kubrick could have so easily made this movie much shorter, much more bearable and much more accessible without losing anything of the story. Such a disappointment.

(Originally posted on Advogato.)

[2006-03-06] GCJ and ECJ

Tom has asked the GCC Steering Committee to provide their verdict on the proposed use of the Eclipse compiler for Java in GCJ. This follows his earlier proposal to abandon GCJX for GCJ and adopt ECJ instead. As of this writing, there has been no response from the GCC SC yet.

(Originally posted on Advogato.)

[2006-03-03] Google Code Jam India 2006

Google Code Jam India is back. It was quite popular here in India the last time around. I still haven't decided whether I should participate. I haven't been participating in TopCoder matches for a while now and even while I was, my rating was steadily and embarrassingly declining with every match. I can blame it on a brain that deteriorates with age or more honestly admit that even though I like coding and computer science in general, I'm not really as good at it as I would like to believe.

(Originally posted on Advogato.)

[2006-03-01] Tar Formats

GNU tar creates archives in various formats and recent versions create archives in the POSIX-2001 format. Unfortunately, while this format is the most flexible and is standardised, it is not yet supported by most of the installations out there. When you distribute archives in this format, users using older versions of tar (even GNU tar before version 1.14), will see "weird" folders like PaxHeaders.1640 extracted along with the ordinary contents of the archive as well as get error messages like "unknown file type x". I was bitten by this problem when I tried to extract an archive created on my home PC using GNU tar 1.15.1 on Linux on different systems elsewhere. It seems that the "v7" format is the most portable at the moment, though it has severe problems with long file names and large files. My project does not have long file names or huge files, so I can use this format for the time being to avoid these problems. The long-term solution however is to encourage everyone to use a tar programme that can handle the far better POSIX-2001 format.

(Originally posted on Advogato.)

[2006-02-21] Interval Arithmetic

Via LtU, I became interested in interval arithmetic once again. I had first looked at this alternative method while struggling with errors in numeric computations in my Virtual Taj demo. If you have never heard of interval arithmetic, I recommend reading Brian Hayes's article "A Lucid Interval" (PDF, 84KB) first published in American Scientist and an interview with Bill Walster of Sun Microsystems. Essentially, interval arithmetic lets you keep track of the margins of error in your data and provides you an estimate of the probability of the correctness of the results of your computations with this data.

Read More...

[2006-02-20] Visual Effects in “The Chronicles of Narnia: The Lion, The Witch and The Wardrobe”

Thanks to Anirban Deb, I attended a presentation yesterday that was given by some of the guys from Rhythm and Hues India where they demonstrated how they created some of the visual effects in the recent movie "The Chronicles of Narnia: The Lion, The Witch and The Wardrobe". It was organised by ASIFA India and supported by CG Tantra, Animation 'Xpress and Women In Animation. The auditorium was full of interested people - students from the various animation training institutes in Bangalore, professionals from the animation and visual effects industry and "outsiders" (like yours truly) who were just curious about such things. The presentation was enlightening in several ways. Some interesting tidbits included:

It is also heartening to know that Blender 3D is getting better and better, especially for character animation, and we can actually do some of this stuff at home. Synfig, a 2D vector animation tool, also became Free recently though I do not know how good it is.

(Originally posted on Advogato.)

[2006-02-14] What Was Your First Computer?

Seen on Slashdot: "What Was Your First Computer?" The first computer I worked on was the SCL Unicorn which was a clone of the BBC Micro Model B. This was a microcomputer based on the 6502 microprocessor and came with the OS and an interpreter for BASIC on ROM and 32KB of RAM.

(Originally posted on Advogato.)

[2006-02-13] IITs All About

Someone has uploaded CBS's "60 Minutes" feature on the IITs to Google Video (thanks to Arpana for pointing me to this). There is a lot of truth accompanied by the usual hyperbole in this video with unfortunately some of the interviewed students also playing along. For instance, not everyone likes to stay up all night preparing for examinations, that too accompanied by a doting tea-making mother. Certainly not everyone has their entire family dropping them off at the examination centre and has them hanging around for the entire duration of the examination. "Puh-sycho!" It is also too much of a stretch to put the IITs above MIT, Princeton, CMU, etc. - they are each good and bad in their own ways. For the IIT Kanpur junta, someone else has also uploaded the musical production targetted at nostalgic alumni "Din Bhar" to Google Video. You must see this at least once.

(Originally posted on Advogato.)

[2006-02-13] C99

In a personal project, I have been using some of the niftier and simpler C99 features like //-style comments, mixed variable declarations and statements, the bool type with its true and false pre-defined values and the uint16_t, int32_t, etc. integral types from stdint.h. They resolve some of the minor irritants I used to face when I am forced to code in C89. I plan to use these features from C99 in all my personal projects written in C. Unfortunately, compiler vendors do not seem too eager to support all the features in C99 even after a better part of a decade after the standard was released! Microsoft is surely not in a hurry to support C99 and GCC and glibc are still not completely there yet. A sad state of affairs. Either the standards committee was eager to get new features into C without a buy-in from the compiler vendors or the C coders have been a little underwhelmed with these features and hence have not been pushing for support for them in their compilers.

(Originally posted on Advogato.)

[2006-02-10] QEMU on steroids

First there was QEMU that provided a fairly fast emulation of x86 hardware using a technique called "dynamic translation". Then came kqemu (or QEMU Accelerator Module) that allowed user code (ring 3) to run directly on the actual hardware providing speedups of around 3-5 times. Now comes the -kernel-kqemu option that allows even some of kernel code (ring 0) to run directly on the actual hardware providing impressive speedups over the old kqemu. Of course, these speedups come at the cost of affecting the stability of the host OS because of bugs in kqemu. kqemu is also not Free software, though it is free (gratis) for non-commercial uses. In other news, GCC's SVN repository is also available for read-only access via HTTP for those who are stuck behind corporate firewalls and want access to the latest sources without having to download weekly snapshots. Of course, this is slower than the SVN protocol and might also be pulled off if it contributes too much to the load on the server.

(Originally posted on Advogato.)

[2006-02-09] “A look at GCJ 4.1”

Mark Wielaard has written another article for LWN.net titled "A look at GCJ 4.1" (where he also looks at GCJ 4.2 and beyond). It is subscribers-only for the moment (for a week), but if you are interested in Linux in any way, you should seriously consider subscribing to LWN. It's quite good.

(Originally posted on Advogato.)

[2006-01-30] ECJ for GCJ?

Tom proposed killing GCJX and replacing it with the Eclipse compiler for Java (Eclipse JDT Core plug-in, known informally as ECJ). He has been almost single-handedly working on GCJX for more than a year and it looks pretty good already, so it is pretty courageous of him to be the one to propose using something else instead of GCJX in the overall interests of GCJ. ECJ seems pretty good and very actively maintained. It must be one of the fastest Java compilers around and fully supports the new language features introduced in JDK 1.5. So it is a very good move for GCJ. Using ECJ does introduce GCC bootstrapping issues though. However, it should be possible to easily overcome these issues. The bigger issues are political and legal in nature. Let us hope these are resolved favourably. I personally feel a little sad though. This removes another "fun" part of GCJ even though it is pragmatically a better thing to do, especially considering the precious little resources that the GCJ project has. I feel that GCJ is becoming more and more an "integration" project combining the best-of-breed in Free software for a given task - the Java language compiler would be ECJ, the garbage collector is Boehm-GC, the runtime library is GNU Classpath and the optmisation and code-generation is done by GCC. Of course, this can hardly be characterised as bad and is in fact quite a sensible thing to do given the limited amount of resources that the Free software world has at its disposal, but...

(Originally posted on Advogato.)

[2006-01-18] “Lisp is Sin”

Sriram Krishnan writes an interesting weblog entry on Lisp. As a side-effect, it made me read some of Peter Norvig's essays and mark his book "Paradigms of Artificial Intelligence Programming: Case Studies in Common Lisp" as well as Richard Gabriel's book "Patterns of Software: Tales from the Software Community" for later reading.

(Originally posted on Advogato.)

[2006-01-16] A Non-Invasive and Reversible Pre-processor for Java

I really like Per's implementation of a Java pre-processor.

(Originally posted on Advogato.)

[2006-01-15] rmathew.com

I have registered the domain name “rmathew.com” for myself. The canonical URL for my website is now http://rmathew.com/.

[2006-01-13] rmathew.com

I have finally registered the domain rmathew.com for myself. It just points to my site hosted by Hosting Zero. The registration was surprisingly easy and rather quick. Within just a couple of minutes, the domain was accessible and the redirection was working. I chose GoDaddy.com even though they were more expensive for just the registration than Yahoo! because their private registration add-on turned out to be slightly cheaper on the whole than that of Yahoo! - I really do not want random people to access my personal information via a WHOIS lookup. The "gotcha" about this registration turned out to be the fact that I inadvertently ended up with a pre-approved payment agreement with GoDaddy.com on my PayPal account, even though I had paid all the amount upfront and had marked my domain for manual renewal. Talking to their customer support didn't help much except stuff my mailbox with verbose and heavily graphic HTML messages. I have tried to contain the damage a bit by limiting the monthly outflow to USD 0.01, but I don't think I'll be sticking with them after my domain registration expires.

(Originally posted on Advogato.)

[2006-01-13] Profound Statement in Latin

Courtesy Anirban: "Quidquid Latine dictum sit, altum viditur" ("Whatever is said in Latin sounds profound").

(Originally posted on Advogato.)

[2006-01-06] Virtual Address Space Randomisation and Debugging

I feel rather silly today. Even though I knew about virtual address space randomisation in newer Linux kernels, it never struck me that I should disable it to get a reproducible debugging session with predictable breakpoint conditionals. My silly workaround was to use this patch:

 Index: tree-ssa-operands.c =================================================================== --- tree-ssa-operands.c (revision 109196) +++ tree-ssa-operands.c (working copy) @@ -1460,6 +1460,16 @@ get_call_expr_operands (tree stmt, tree    tree op;    int call_flags = call_expr_flags (expr);   +  if (strcmp (lang_hooks.decl_printable_name (current_function_decl, 2), +              "of") == 0) +    { +      const char *called_f +        = lang_hooks.decl_printable_name (TREE_OPERAND (TREE_OPERAND (stmt, 0), +                                                        0), 2); +      if (strcmp (called_f, "_Jv_ThrowBadArrayIndex") == 0) +        printf ("Hello \"_Jv_ThrowBadArrayIndex\"!\n"); +    } +    if (!bitmap_empty_p (call_clobbered_vars))      {        /* A 'pure' or a 'const' functions never call clobber anything.  
and then put a breakpoint at the "printf" to get the debugger to stop the compiler process while processing the operands for the statement I was interested in. Thanks to Mike Stump, we now have a page in the GCC Wiki that explains this problem and how to avoid it. Putting in the desired breakpoint is very simple now and avoids unnecessarily kludgy patches that contaminate the tree:
 (gdb) b tree-ssa-operands.c:1463 Breakpoint 1 at 0x80d1f3f: file /extra/src/gcjx/gcc/gcc/tree-ssa-operands.c, line 1463. (gdb) cond 1 stmt==0xb7c27fc8 
Cool! Now all that is left is to use this breakpoint to figure out what the actual problem is that caused us to fire up a debugger.

(Originally posted on Advogato.)

[2006-01-04] “A Practical Sanskrit Introductory”

Thanks to Anirban Mukherjee, I came across a nice document (2.5MB PDF) written by Charles Wikner containing introductory lessons for the Sanskrit language. Just take a look at the first chapter to see why I personally consider the phonetically precise Devanagari script to be far superior than the utterly challenged and much abused Roman script, even at the risk of appearing jingoistic.

(Originally posted on Advogato.)

[2006-01-04] The Etymology of “Foo”

RFC 3092 is devoted to explaining how "foobar" came to be used so much in software code and documentation.

(Originally posted on Advogato.)

[2006-01-04] Confessions of a TAB-hater

I do not like it when people put TAB characters in their source code for indentation. I prefer to use spaces instead of TAB characters to indent my source code. Jamie Zawinski has written a nice document that clearly explains the problem. Note that I am not against using the Tab key as a quick way of indenting, but putting in actual TAB characters (ASCII character #9) in the source code. Different people set tabstops differently, so what looks good to them looks terrible to others. These characters also mess up the indentation in patch diffs. VIM has an unfortunate optimisation that replaces consecutive spaces with as many TAB characters as possible and if you "set expandtab", then even desirable TAB characters (in Makefiles for example) are replaced by spaces. Yes, I know of using the Ctrl-V + Tab sequence to insert an actual TAB character in this mode, but it is painful. So I have ended up putting the following in my ".vimrc":

 set shiftwidth=2 set tabstop=8 inoremap <Tab> <C-V><Tab> autocmd BufNewFile,BufRead *.java setlocal expandtab autocmd BufNewFile,BufRead *.c setlocal expandtab autocmd BufNewFile,BufRead *.cc setlocal expandtab autocmd BufNewFile,BufRead *.cpp setlocal expandtab autocmd BufNewFile,BufRead *.h setlocal expandtab autocmd BufNewFile,BufRead *.hh setlocal expandtab autocmd BufNewFile,BufRead *.hpp setlocal expandtab autocmd BufNewFile,BufRead *.xml setlocal expandtab autocmd BufNewFile,BufRead *.sql setlocal expandtab 
If I were to design a programming language, I would seriously consider not allowing TAB characters to be counted as whitespace. It would make source code use up a few extra bytes compared to what it would if consecutive spaces are replaced by as many TAB characters as possible, but I would trade that off for overall sanity. By the way, I consider it really silly that the authors of make chose to make TAB characters so important, when they are virtually indistuingishable from spaces when you inspect Makefiles. Their mistake has cost the software world the creation of the monstrosity named Ant.

(Originally posted on Advogato.)

[2006-01-03] Twenty Years of comp.compilers

comp.compilers has turned twenty. It is one of the few USENET newsgroups that I try to read regularly and whose moderator John R. Levine has done a rather fine job over the years of keeping the signal-to-noise ratio high enough. He is also known to put in editorial remarks, almost always at the end, in many a post that either answer a question outright or contain pointers to useful material or contain quirky and mostly amusing remarks. Kudos to him and the community that sustains this awesome resource.

(Originally posted on Advogato.)