Java vs Ruby: the keystroke effect of good IDEs

Years ago I used to use vi for all of my programming. I also used JEdit for a while. I remember being in a Sun conference about 7 years ago when the speaker asked for a show of hands as to whether the assembed programmers were using text editors or IDEs. About 90% were using text editors. She asked “Why?” The answer some audience members gave was that the Java IDEs were crap. And so they were.

However since then they have come along way. Today the rare individual you encounter who does not use an IDE is a Unix hacker who has been living in a cave. Or a Ruby fanatic. The Ruby guys tend to use TextMate, which is a nice text editor. I have been using it the past few days. Apart from the .conf files it gets its cursor out of sync on, it seems to work well. So why aren’t they using IDEs? I think the answer is the same we gave at that Java seminar 7 years ago. I have tried out about 5 of them now and that is my conclusion. ActiveState’s Komodo is probably the best.

Dave Thomas in his Ruby talk at OSCON dealt with the issue differently; he was openly disparaging of the whole idea of IDEs or any language that was either compiled or verbose enough to require one. His argument was that, in Ruby, you write so little code that things like autocomplete do not matter. And there is no compile to do.

In Java by contrast, I find autocomplete, syntax highlighting, quick documentation lookup and so on highly productive.

Continuing the verbosity theme, over at Loud Thinking David Heinemeier Hansson was reduced to giggles by the following Java code snippet:

UploadedFile uploadedFile = (UploadedFile) fileUpload1.getUploadedFile();

It is certainly far more verbose than the equivalent Ruby code. On the other hand it is a familiar idiom; one which is very easy to parse. It has high readability. What about its writability? Is it really that much more work? I thought I would take a similar example and count the key strokes required to produce it in IntelliJ IDEA. Here is the sample piece of code from ehcache:

CacheEventListener cacheEventListener = (CacheEventListener) iterator.next();

It contains 77 characters, including whitespace characters, starting from the first “C”. Is this really 77 keystrokes? Following is the exact key sequence I used to write the above code:

C E L CTRL-SPACE RET SPACE CTRL-SPACE RET SPACE = SPACE i t CTRL-SPACE RET . CTRL-SPACE RET ; ALT-ENTER RET

That is a total of 21 keystrokes, not 77.

Ok, so it was quick to type. Is the instance variable name silly? “cacheEventListener” is the first suggestion made by IntelliJ, as would “uploadedFile” be. I don’t think it is silly; I think it is readable. That you use the class name indicates to the reader that it is a CacheEventListener with no other notable qualities, thus the simple name.

There are many other code examples that require far less keystrokes to write. IDEs like IntelliJ give automation support to structures like looping and exceptions and many others. Rather than the 4:1 ratio in the above example, these can get closer to 10:1.

I like the idea of having lots of tools on my tool belt. I have had a little time lately and have been working my way through Ruby on Rails. I am pretty slick on vi and find TextMate easy enough. But every character of code is a key stroke I typed into the keyboard. And every little bit of API I had to go and lookup in my browser. So lets not kid ourselves: the Ruby community would be much more productive with a great IDE like IntelliJ IDEA.

Published
Categorized as Java

By Greg Luck

As Terracotta’s CTO, Greg (@gregrluck) is entrusted with understanding market and technology forces and the business drivers that impact Terracotta’s product innovation and customer success. He helps shape company and technology strategy and designs many of the features in Terracotta’s products. Greg came to Terracotta on the acquisition of the popular caching project Ehcache which he founded in 2003. Prior to joining Terracotta, Greg served as Chief Architect at Australian online travel giant Wotif.com. He also served as a lead consultant for ThoughtWorks on accounts in the United States and Australia, was CIO at Virgin Blue, Tempo Services, Stamford Hotels and Resorts and Australian Resorts and spent seven years as a Chartered Accountant in KPMG’s small business and insolvency divisions. He is a regular speaker at conferences and contributor of articles to the technical press.