Year: 2008

Animated charts in Excel

Watch Hans Rosling‘s TED Talks on debunking third world myths and new insights on poverty and ask yourself: could I do this with my own data?

Yes. Google has a gadget called MotionChart that lets you do this.

Now, you could put this up on your web page, but that’s not quite useful when presenting to a client. (It is shocking, but there are many practical problems getting an Internet connection at a client site. The room doesn’t have a connection. The cable isn’t long enough. You can’t access the LAN. Their proxy requires authentication. The connection is too slow. Whatever.)

So you need this in Excel. Let me explain a variant of the technique I described earlier.

Let’s start by creating a simple bubble chart.

For each item in a bubble chart, you need 3 pieces of data: the X-axis, Y-axis and size. This graph shows three items A, B and C in one year: 2001. To animate this, you need data for more years, so let’s create that.

The first 3 rows contain the same data as before, except that I’ve added a "Year" column and a "Key" column (which is just a concatenation of the Year and the Item). The data now goes on for many more years.

Now we need to create a scroll bar that can be used to change the year. So add a scroll bar below the bubble chart…

… and right click the scroll bar and go to Format Control. Now, select the cell link to some cell ($H$1 in this case). Now, if you move the scroll bar, the cell value will change.

All you need to do is to now change the source data for the chart based on the year. From the table on the left, VLOOKUP the year + item, and put this into the table on the right. When the year in the cell H1 changes, the data updates itself. So now, as you move the scroll bar, cell H1 changes, then so does the data and hence the graph.

This is what the animation looks like.

And here’s the Excel file.

Resolving the Prisoners Dilemma

If you’re ever taken a course in Economics, and it discussed Game Theory, you may be familiar with The Prisoner’s Dilemma. Roughly, this is the problem.

Assume you possess copious quantities of some item (money, for example), and wish to obtain some amount of another item (perhaps stamps, groceries, diamonds). You arrange a mutually agreeable trade with the only dealer of that item known to you. You are both satisfied with the amounts you will be giving and getting. For some reason, though, your trade must take place in secret. Each of you agrees to leave a bag at a designated place in the forest, and to pick up the other’s bag at the other’s designated place. Suppose it is clear to both of you that the two of you will never meet or have further dealings with each other again.

Clearly, there is something for each of you to fear: namely, that the other one will leave an empty bag. Obviously, if you both leave full bags, you will both be satisfied; but equally obviously, getting something for nothing is even more satisfying. So you are tempted to leave an empty bag. In fact, you can even reason it through quite rigorously this way: "If the dealer brings a full bag, I’ll be better off having left an empty bag, because I’ll have gotten all that I wanted and given away nothing. If the dealer brings an empty bag, I’ll be better off having left an empty bag, because I’ll not have been cheated I’ll have gained nothing but lost nothing either. Thus it seems that no matte what the dealer chooses to do, I’m better off leaving an empty bag. So I’ll lease an empty bag."

The dealer, meanwhile, being in more or less the same boat (though at the other end of it), thinks analogous thoughts and comes to the parallel conclusion that it is best to leave an empty bag. And so both of you, with your impeccable (or impeccable-seeming logic), leave empty bags, and go away empty-handed. How sad, for if you had both just cooperated, you could have each gained something you wanted to have. Does logic prevent  cooperation? This is the issue of the Prisoner’s Dilemma.

There’s nothing wrong in the logic, actually. The key assumption is that it is clear to both of you that the two of you will never meet or have further dealings with each other again. If you’re never going to deal with someone again (and hence there is no question of retribution or any fallout), you really should cheat.

An aside. During my first few days at IIT, two third years were ragging me about my stance on pre-marital affairs. After trying my best at defending the moral standpoint, I finally confessed that it was only the fear of the after-effects that worried me.

"There’s this beautiful naked girl in your room," they said. "You are guaranteed no repercussions. What will you do?"

"No repercussions?"

"None whatever."

I thought for a while. "I’ll flip a coin." 🙂

Anyway, the aside aside, the solution to the one-off Prisoner’s Dilemma is for both people not to cooperate. If contracts are not enforceable, we’re all better off not trading. If there are no cops, we’re individually better off stealing.

But, of course, that’s not true in the real world. Most situations are repeatable, and you do tend to meet people again. Those you cheat may even have a motivation to meet you again.

This is the iterated Prisoner’s Dilemma. Douglas Hofstadter wrote about this in the May 1983 issue of Scientific American in his Metamagical Themas column (which, by the way, is brilliant). While the Prisoner’s Dilemma has a simple solution (don’t cooperate), the iterated Prisoner’s Dilemma does not have a predetermined solution. At best, you can have a strategy. (That can be proven. If there was a predetermined solution, your opponent would know it, and could beat you. One of those cases in mathematics where you are not guaranteed a solution.)

But is it possible for cooperation to emerge in an iterated Prisoner’s Dilemma? Can it beat competitiveness?

Robert Axelrod of U.Mich conducted a computer tournament to find out. He invited strategies from game theorists and wrote them as BASIC programs. Each program would be pitted against another. Every time, it could response with either C (cooperate) or D (defect). Cooperation gets both programs 3 points. If one defects, the defector gets 5 points and the cooperator gets nothing. Both defecting gets 1 point each. Axelrod ran each program against each other many times, and added up the scores.

The program that won was called TIT FOR TAT. It was the shortest program (4 lines of BASIC code). Here’s it’s strategy:

Cooperate the first time.

Do what your opponent does thereafter.

Think about it. TIT FOR TAT starts by being nice, and stays that way, unless you defect. Then TIT FOR TAT punishes. If you repent, TIT FOR TAT forgets and forgives. Interestingly, TIT FOR TAT can never win a game. It can, at best, draw a game, but never score more points than its opponent. It goes for winning the war by losing battles.

That’s four traits:

  1. Being nice
  2. Punishing immediately
  3. Forgiving immediately
  4. Willing to lose battles

After publishing these results, and having learnt a lot about different strategies, Axelrod repeated the tournament. Four times as many entries poured in. This time from world experts on game theory. It also included an improved TIT FOR TAT called TIT FOR TWO TATS, which is an improved TIT FOR TAT that does not fall into a C – D – C – D cycle when playing against TIT FOR TAT.

TIT FOR TAT won again.

Till date, TIT FOR TAT remains an unbeaten individual strategy, and people believe it may be optimal.

(PS: By individual strategy, I mean that there are multiple programs that can team together, losing to each other and making sure that one of them wins. This sort of thing can beat TIT FOR TAT. But no individual program beats TIT FOR TAT.)


In our first term at IIMB, we played a game in our organisational behaviour class, intended to help us understand inter-departmental cooperation (or rivalry). The class was split into two ‘companies’. Each company had four divisions.

The game had 10 rounds. In each round, every division could choose to cooperate or defect. If everyone cooperated, each division made 3 points. If any division defected, it would make 5 points, while all cooperating divisions made 0 points. If all divisions defected, they would all make 1 point. The divisions were not allowed to talk to each other.

The aim was to beat the other company. (Not other divisions, within or outside the company.)

Our company started off with 3 Cs and a D, which quickly deteriorated to 1 C with 3 Ds by round 6. At round 7, it was 4 Ds.

Before round 8, we were all given a chance to have a huddle. A representative from each division would come together and talk things through. We promised to cooperate, and thereafter, it was 4 Cs to the end.

We lost the game. The other ‘company’ had started off with 1C and 3Ds, but had learned to cooperate pretty quickly, aided, in Prof N M Agrawal‘s words, by "… Aparajita threatening the other divisions with her glares."


The reason there’s a Prisoner’s Dilemma is the inability to reliably communicate or enforce behaviour. Having a chat helps. Having laws that punish you helps. Having a bully threaten you helps. The thing is, you need a signal of some kind. And it needs to be an early signal, or you end up waiting till round 8 and lose the game.

If you’re ever in a situation where cooperation helps everyone, but it’s not in interest to cooperate, here’s what seems to work:

  • See if you can agree to cooperate before-hand
    1. Have a chat
    2. Find policies that punishes defectors
    3. Threaten if required
  • If not, then try to force cooperation by signaling.
    1. Be nice
    2. Punish defection immediately
    3. Forgive repentance immediately
    4. Lose battles to win the war

The Non-Designers Design Book

I’ve been thumbing through books on visual design for a while, and recently, picked up a copy of The Non-Designer’s Design Book by Robin Williams.

If there’s one book that I’d suggest to a newbie on visual design, it’s this one. It’s rare among design books in that it offers 4 design principles that are easy to remember, easy to spot when violated, and easy to fix. Over 90% of the slides that I have reviewed violate at least one of these principles (often all), so I guess there’s a 90% chance this book will improve your design.

The four principles are (in the order of how often I see them violated):

  1. Alignment. Every edge of every element should be aligned with an edge of another element.
    Get that? Every edge of every element. No exceptions.
  2. Repetition. Use the same styles right through the presentation: fonts, size, colours, shapes.
    If you ever change a font, you must have a reason. Same for colour, size, shape, etc.
  3. Contrast. If you do change something, change all the way. Change the font, size, colour, everything.
    If two elements are not the same, then make them very different.
    If there were just 3 words on this slide, what should they be? Make those stand out.
  4. Proximity. Related items should be close together and grouped. Unrelated items should be far away.
    After designing your slide, list the elements, group them, and redesign to keep the groups together.

Contrast and proximity are important for the message. Proximity groups information into messages, and contrast highlights the key message. Alignment and repetition are more important for design. It makes for more appealing reading.

Williams orders these in a different way to create a memorable acronym. (I’ll never forget it.)

  1. Contrast
  2. Repetition
  3. Alignment
  4. Proximity

I’ll let you read the book and absorb it better. At less than 200 pages, it’s a very readable book.

Caching pages on Apache

I don’t use any blogging software for my site. I just hand-wired it some years ago. When doing this, one of the biggest problems was caching.

Consider each blog entry page. Each page has the same template, but different content. Both the template and content could be changed. So ideally, blog pages should be served dynamically. That is, every time someone requests the page, I should look up the content, look up the template, and put them together.

I did that, and within a few days outgrew my hosting service‘s CPU usage limit. Running such a program for every page hit is too heavy on the CPU.

One way around this is to create the pages beforehand and serve it as regular HTML. But every time the template changes, you need to re-generate every single page. I had over 2,500 pages. That would kill the CPU usage if I changed the template often.

At that point, I did a piece of analysis. Do I really need to regenerate all 2000 blog entries? Wouldn’t the 80-20 rule apply? The Apache log confirmed that 20% of the URLs were accounting for 76% of the hits. So I’d be wasting my time regenerating all the pages every time I changed the template.

Graph: 20% of URLs account for 76% of hits

So based on this, I decided to dynamically cache the pages. When a page is requested for the first time, I create the page and save it in a cache. The next time, I’d just serve it from the cache. If the template changes, I just need to delete the cache. This way, I only generate pages that are requested, and they’re only generated once.

OK, so that’s the background. Now let me get to how I did it.

I wrote a Perl script, blog.pl, that would generate a page in the html folder whenever it is called. Next, I changed Apache‘s .htaccess to run this program only if the page did not exist in the html folder.

# Redirect to cache first
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)\.html$       html/$1.html

# If not found, run program to create page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^html/([^/]*)\.html$  blog.pl?t=$1

The first block redirects Apache to the cache. The second block checks if the file exists in the cache. If it doesn’t, the Apache redirects to the program. The program creates the page in the cache and displays it. Thereafter, Apache will just serve the file from the cache.


This Apache trick can be used in another way. I keep files organised in different folders to simplify my work. But to visitors of this site, that organisation is irrelevant. So I effectively merge these folders into one. For example, I have a folder called a in which I keep my static content. I also have this piece of code:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$   a/$1

If any file is not found in the main folder, just check in the a/ folder. So I can access the file /a/hindholam.midi as /hindholam.midi as well.

This can be extended to a series of folders: either as a cascade of caches, or to merge many folders into one.

How often to write

If you look at the number of entries I’ve written every month since 2005, there has been a clear decline. While I was averaging almost an entry a day in 2005 and 2006, that dropped to 2-3 entries a month since mid-2007.

Number of entries per month declining

This doesn’t bother me. I’ve been lucky to never have lost sight of the purpose of this website. This website is meant for me. Not for you, the reader. For me, the author.

Writing helps me clarify my thoughts. It forces me to learn. It gives me input from a broad audience. It preserves my thoughts. It kills boredom. But nowhere in that list is the need to entertain or enlighten you.

Not that I care less about you, but rather that I care more about me. If I start writing because I need to keep up the pace of output, the quality declines and I stop enjoying it. (This contradicts what I said earlier about Quantity Always Trumps Quality. Well, let me take back the “quality declines” part. If I stop enjoying it, it’s not worth doing.)

So I’ve been taking micro-sabbaticals. Just 3 posts between July – November 2007. No posts in June – July 2008. Whenever I have something to write, or feel like writing, I just go ahead.

It’s very relaxing. I don’t feel the obligation to keep up the readership. In fact, I don’t keep track of the readership, so that helps.

But in fact, while the number of posts has dropped, the average volume of writing hasn’t changed all that much. If you look at the size of writing (I write about 25KB worth a month), except for a blip near end-2007, it hasn’t changed that much. Those blips in the middle were me copying and pasting articles on Classical Ilayaraja, so they don’t really count.

Size of entries per month has not changed much

In other words, I spend about as much time as before writing. I write about the same stuff as before. Except that I’m putting in a bit more work into each piece, and it takes longer.

It’s just a different way of doing things. I’m getting more out of building larger pieces than blogging fragmented threads, so I’ve moved that way. And in doing so, I need to take a break every now and then, because you just can’t get some stuff done at a stretch.

That’s fine by me, and I hope you don’t mind. In fact, as Asimov put it, “I’m not too proud to ask a favour. Please don’t mind.”


I’m writing this for two reasons. One is to tell you why you don’t see stuff regularly from me, and to tell you not to expect any regularity. Just subscribe to the RSS feed and we’re all better off.

The other is because I see bloggers abandoning some great blogs. (You know who you are.) I think it’s sort of like earthquakes and forest fires. The pressure to take a break from blogging keeps building up, and unless indulged in, bloggers quit. Something like Guru’s sabbatical is a great idea. It provides the option for the return, and reduces the cost of taking a break.

A new home page

I have a new home page design. (If you’re reading the RSS feed, check the home page.)

One reason is that the old home page’s design sucked. Almost everyone told me that it was drab in black and white. Personally, I think the new home page sucks in terms of colours as well. There’s too many. I suck at picking colours. The only good thing about these colours is that I left it to the judgement of experts. These are the colours in Powerpoint 2007‘s “Concourse” theme color, and I’ve just lifted them.

So, no, it wasn’t the colours that drove the redesign. My last redesign was over a year ago. I changed the structure from a list of links to two lists: one where I was just linking to interesting sites (bookmarking, really) and the other where I was writing content. The purpose behind that was to allow me to focus on writing stuff rather than just bookmarking.

And that worked pretty well for me.

In the last several months, I find myself writing more code than articles. I don’t quite have a way of sharing that. The new home page has a section dedicated to the sites I’m creating, and hopefully, it’ll let me share what I’m doing in a clearer way.

Another problem I have is that in attempting to write articles, I’ve cut myself off from writing the frivolous. Sometimes, I just need to share something small, like “I bought an Acer Aspire 5715Z” without going into the details of it. That’s not a bookmark. That’s not an article. I need a space in-between.

And that’s exactly the space micro-blogging captures.

I created a Twitter account last month. With the huge number of problems that twitter has, such as downtime and the lack of IM support, I hadn’t written a single tweet. Day-before, I created an account at identi.ca and it works just fine. Given that I now have 4 mobile devices, I should be able to do some decent microblogging.


This is actually my third or fourth attempt at redesigning my earlier home page. Every time, I’d start with a redesign, struggle with it, try to get things just right, and then eventually abandon the effort after a few weeks. This time, I succeeded — within a matter of three hours on my flight from Washington DC to London.

Two reasons. Yesterday, I found this CSS framework: 960.gs. It’s a grid system. And grids are absolutely the best way to get layouts for the web.

The other is an article from Coding Horror titled Quantity Always Trumps Quality. If you try to do stuff quickly, you end up doing better stuff than if you tried to do better stuff. To hell with perfection. Just get it out of the door.

Launching applications

Opening programs from the Start – All Programs menu is painful. For many years, I relied on the quick launch bar.

QuickLaunch

But it’s space constrained. There are only so many applications you can place there. I want space enough for frequently used documents as well. Recently, I decided that I need all the space on the screen. So my task bar is on auto hide, and that makes the quick launch bar a little tougher to use as well. And finally, I can’t use the quick launch bar with the keyboard. That’s important.

So I switched to the pinned menus on the Start Menu.

StartMenu

This works better with the keyboard. I access Word, I just type the Ctrl-Esc, W. Excel: Ctrl-Esc, E. But I run short of letters soon. I have trouble between Powerpoint and processing, for instance. And I can’t store documents.

I tried Enso Launcher and Launchy, both of which are great products, but I just can’t stand the thought of them hogging up all the memory that they do. Launchy in particular.

Given that I almost always have one or two command prompts open, I write my own little tool to do the job now. It’s a command line launcher I’ve written in Perl. I call it “o”. At the first run, it indexes my hard disk. (Well, not all of it. I’ve picked what I need.) Now, if I want to read Harry Potter and the Deathly Hallows, I just type:

> o harry potter hallows

If I wanted to pick a Harry Potter book, I could:

> o harry potter
    0: D:/Entertainment/Books/Hugo Awards/2001 - J K Rowling - Harry Potter and the Goblet Of Fire.rar
    1: D:/Entertainment/Books/J K Rowling.1.Harry Potter and The Sorcerer's Stone.pdf
    2: D:/Entertainment/Books/J K Rowling.2.Harry Potter and The Chamber of Secrets.pdf
    3: D:/Entertainment/Books/J K Rowling.3.Harry Potter and The Prisoner of Azkaban.pdf
    4: D:/Entertainment/Books/J K Rowling.4.Harry Potter and The Goblet of Fire.doc
    5: D:/Entertainment/Books/J K Rowling.5.Harry Potter and the Order of the Phoenix.pdf
    6: D:/Entertainment/Books/J K Rowling.6.Harry Potter and the Half-Blood Prince.pdf
    7: D:/Entertainment/Books/J K Rowling.7.Harry Potter and the Deathly Hallows.pdf
    8: D:/Entertainment/Books/J K Rowling.The Harry Potter Encyclopedia.doc
    9: D:/My Pictures/2005-06 London/2005-07-16 06 Waterstones Oxford Street Harry Potter release.JPG
    ... more
> (0-9, q, any word): prince
D:/Entertainment/Books/J K Rowling.6.Harry Potter and the Half-Blood Prince.pdf

The program lists the files matching the words I typed, and lets me filter within that.

I just wrote this yesterday, and already, I’ve used it dozens of times. Here’s the source.

PS: While I was at it, I downloaded a Flickr uploader for Perl. So I can now upload images with the command line. This easily saves me at least 5 minutes per article.

Illegally in Germany

In October 1997, Ram, my manager at IBM, strolled over to my desk and asked if I would like to visit the US. I’d never been there before. The impulse was to say “Yes”. But…

I’d written the CAT exam once before. Didn’t get through. Applied once again. But thanks to my diligence, I’d given the wrong residence address, and never got my admission card, and didn’t bother following it up. This would be my third “attempt”. And I didn’t want to goof it up again. (I didn’t get through that one either, as it turned out.)

“Ram, I need to be back on Dec 11th.”

“Mmm… I think we should be back by then.”

“NO MATTER WHAT!”

He smiled, and said “OK. We’ll be back by Dec 11th NO MATTER WHAT.” He thought I was going to get married or something.


It was quite warm in Bangalore, so I set out with a T-shirt and formal trousers. As I was leaving, my landlord and landlady (very nice people, and in retrospect, very far-sighted) pulled me in and said, “Have some snacks. You’ll feel hungry on the way.”

I tried my protests. They’ll feed me on the plane. I’m already carrying some food. I have cash to buy stuff. I’m fat and dieting. Didn’t matter. I still ended up carrying a fairly hefty package. “And this is for Kallol.” Another package. A colleague travelling with me was an ex-roommate as well. I just hoped I wouldn’t exceed 27 kgs.

It was a KLM flight that would halt at Amsterdam. We were to land early morning in Amsterdam, take a connecting flight to Boston, and then over to Charlotte. We’d reach Charlotte by night, in time for the class next day.

The flight itself was uneventful, except for my first non-vegetarian bite.

And then the fun began.

Breakfast was done by around 5:00am local time. The captain announced that we were near Amsterdam, fasten your seatbelts.

5:30am. No landing.

6:00am. No landing. When I pulled the shutters up, we were still flying over clouds.

7:00am. No landing.

7:30am. The captain announces that due to bad weather at Amsterdam, we would not be able to land there. We were being diverted to Cologne.

Not having been on any long-haul flights before, I wasn’t even worried. It was a KLM connecting flight. KLM would do something. But for feeling a bit hungry, things were fine.

At around 11:00am, the plane began its descent. We were amidst clouds, though. For quite a while… and the plane kept descending…

Until, all of a sudden, I could see the ground about 20 feet from the plane! The fog dense enough to be indistinguishable from clouds. (Or at least, I couldn’t tell the difference.) Lucky the pilot managed to land, and I’m surprised he even tried.

8:00am. We’re still in the plane, waiting.

9:00am. Hungry. No one has told us anything yet.

9:30am. We’re all asked to get down. Delighted, we all got off, ready to board the next plane…

… only to be herded off into a glass building on the terminal, where our luggage was waiting for us. No problem. Pick up luggage. Wait.

10:00am. All the flight staff had cleared the terminal. And, looking out of the glass walls, we could see our plane taking off! There was a fair bit of confusion (and mild panic) in the room, but being the suave software engineers that we were, we stay put and relaxed.

11:00am. Still in the glass building. No flight has landed or taken off. Worse, no human in sight. I mean it: not a single human in sight other than us KLM passengers in this deserted terminal. We’re still hungry.

12:00noon. My snacks finally come out. We all have a bite. That turned out to be our lunch.

12:30pm. Some official enters the building and is mobbed. The closest we could get to him (or her?) was about 50m behind many hundreds of raised heads.

12:45pm. Official vanishes. We ask around if anyone knows more than we do. No one seems to.

1:30pm. Another official enters. Vanishes after a few minutes.

2:00pm. Finally, word gets around that we’ll be travelling via bus to Amsterdam. Clearly we’d missed our connecting flight. We’d be put in to the same flight the next day.

2:10pm. We hear a lot of activity. People start streaming out of the building. We try to join in the rush.

2:20pm. Ahead of us, we see a guy checking passports. Now, none of us had a German visa. Presumably it was OK, but in any case, we were entering Germany without a valid visa. The official stamped my passport without question.

2:30pm. We exit the airport. The temperature was 0 degrees C. I was still in my T-shirt. My warm clothes were packed. That day, I learnt two lessons. One, never keep all your warm clothes inaccessibly in the check-in baggage. (I had my check-in baggage. But it was packed, and if I opened it, I can’t put it back in. Besides, we were being herded into a bus: not much chance of hanging around to open a suitcase.) Two, it’s actually possible to get a headache from the cold. For 15 freezing minutes, we stood on the road waiting for the bus, and enjoying the pleasures of our first day on European soil.

2:45pm. Bus arrives. Mob tries to enter bus. Half of our group manages to get through. I am left behind. Fortunately, next bus is only 5 minutes behind.

7:00pm. Bus finally arrives at Schipol airport. We’re herded out to the KLM counter. By now, it’s been well over 24 hours since my last full meal.

7:30pm. We’re told we’ll get a hotel to stay in, and our flight is confirmed for the next day. At this point, we’re famished. So we exchanged some currency, and decided to buy some food. I picked a green apple. This happened to be my first green apple. No one had told me that apples could taste sour. (While on that topic, I must mention apple pies. I love apple pies in India. I hate apple pies in London. I suspect it’s the red versus green apples.)

7:31pm. I take one bite. Another bite. Have a funny feeling in my stomach. Burning sensation. And at that point, I collapsed. Physically. Just dropped on the floor and had to be pulled up.

8:00pm. Finally reach the hotel. Not entirely sure how. I’m too tired for anything but milk, so I get a glassful and go to sleep.


PS: We finally reached Charlotte a day late. Fortunately, we didn’t miss much.

Apparantly, most passengers on the flight complained to KLM and received gifts / free miles of a substantial magnitude. We didn’t know of that till much later.

This remains my only trip to Germany till date. My passport still holds an entry stamp without a visa.

We did get the bonus of spending half a day in Amsterdam, which is a rather nice place. Again, without a visa.

In search of a good editor

It’s amazing how hard it is to get a good programming editor. I’ve played around with more editors/IDEs than I care to remember: e Notepad++ NoteTab SciTE Crimson Editor Komodo Eclipse Aptana

There are four features that are critical to me.

  • Syntax highlighting. Over time, I’ve found this to increase readability dramatically. Look at this piece of code with and without syntax highlighting:
    Syntax Highlighting
    Doesn’t the structure of the document just jump out with syntax highlighting? Anyway, I’ve gotten used to that.
  • Column editing. I want to be able to do this:
    Column Editing
    Being able to type across rows is incredibly useful. I use it both for programming as well as to complement data-processing on Excel.
  • Unicode support. I often work with non-ASCII files, particularly in Tamil. Unicode support comes in handy when debugging pages for my songs site.
  • Auto-completion. This is 10 times more productive than having to look up the manual for each function.
    AutoCompletion

(Oh, and it’s got to be free too. Except for e Text Editor, all the others qualify.)

The problem is, none of the browsers that I’ve looked at support all of these features.

Editor Syntax highlighting Column editing Unicode support Auto-completion
e Text Editor Yes Yes No Yes
Crimson Editor Yes Yes No No
Notepad++ Yes No Yes No
NoteTab-Lite No No No No
SciTE Yes No Yes Yes
TextPad Yes No Yes No
UltraEdit Yes No No ?
Aptana Yes No Yes Yes
Eclipse Yes No Yes Yes
Komodo Yes No Yes Yes

Wikipedia has a more in-depth comparison of text editors.

Actually, there’s another parameter that’s pretty important: responsiveness. When I type something, I want to see it on the screen. Right that millisecond. With some of the features added by these editors, there’s so much bloat that it often takes up to one second between the keypress and the refresh. That’s just not OK.

I’ve settled on Crimson Editor as my default editor these days, simply because it’s quick and has column editing. (Column editing on e Text Editor is a bit harder to use.) When I am writing Unicode, I switch over to Notepad++. For large programs, I’m leaning towards Komodo right now, largely because Eclipse is bloated and Aptana was slow. (Komodo is slow too. Maybe I’ll switch back.)

There’s many other things on my “would love to have” features, like regular-expression search and replace, line sorting, code folding, brace matching, word wrapping, etc. Most of those, though, are either not too important, or most browsers already have them.

Well, there’s the sad thing. I’ve been hunting for a good text editor for over 10 years now. May someone write a lightweight IDE with column editing.