IDEs are not about code generation

There’s been a lot of interesting topics on Twitter, the JavaPosse Google Group, and various blogs recently about the “complexity” of the Scala language and whether it will be the next Java. This isn’t meant to be a post ripping on Scala – I respect the hard work from the talented individuals it took to create Scala, and I think it is a delightful language.

However, there is more to a language than the language itself, and I think the tooling situation in Scala leaves much to be desired. This is fixable – Miles Sabin and others are doing some excellent work to improve the tooling situation in Scala. What is more worrisome is the attitude that a lot of people in the Scala community seem to have toward IDEs.

Every week or so, someone pops into the Scala or Lift mailing list and asks about the IDE situation with Scala. They are met with a smattering of helpful replies pointing them to the IntelliJ plugin, the Eclipse plugin, someone’s favorite TextMate bundle or whatever. There are also, inevitably, a handful of people questioning the need for an IDE in the first place – “Scala is such an elegant language, why do you need an IDE?” or “Scala requires no code generation like Java does, so why do you need an IDE?” or “You don’t need anything more than emacs” are some common refrains.

Development environments are very personal, often irrational

I’ve been working on developer tools for the last several years, and one of my most memorable experiences was talking to developers about IDE usage a year or two back. I’m a die-hard Eclipse user, and I was talking to a group of equally die-hard IntelliJ users about what they liked about it. I remember walking away shocked, thinking “What the hell are these guys on? Over half the things they liked about IntelliJ are reasons I quit using it!” I’m sure had I shared my reasons for being an Eclipse enthusiast, they’d be thinking the same thing about me.

One of the biggest lessons I’ve learned over the past few years is that developers are often very passionate about their development setup and are loathe to change it. The best development environment is the one you are most productive in – whether that is Eclipse, Netbeans, IntelliJ, TextMate, vi, emacs, dictating your code to an intern, or writing it on a piece of paper and scanning it in. I’m not arguing that people who are happy writing Scala (or any other language) in emacs are idiots and should use a modern IDE, but I am arguing that there are millions of developers who derive significant productivity benefits from using one and we aren’t interested in stopping just because a new language has nicer syntax.

Not just code generation

A common argument against modern IDEs is that people use them largely for code generation, and thus, languages such as Scala that are generally more elegant and terse don’t really benefit from an IDE. This is way off the mark. Code generation is only a tiny part of IDE usage for most people, and Scala benefits from an IDE almost as much as Java does. Let’s look at some uses for a modern IDE such as IntelliJ or Eclipse:

1. Syntax Highlighting

Yes, most text editors do this perfectly well.

2. Debugging

Being able to debug your code from within the same program you are writing it has a lot of benefits.

3. Real-time compilation information

Being able to immediately see when you’ve done something that the compiler doesn’t approve of is a time-saver, and can be especially helpful when you are learning a new language.

4. Auto Complete

Is this a form of code generation? Maybe, but I’d argue it goes well beyond simply saving you a few keystrokes. For one, autocomplete functionality can be pretty useful when you can’t quite recall what the method name is, what parameters it requires, or what it returns – a nice language can’t help you avoid this, this is a problem of being able to instantly recall details about potentially thousands of classes in hundreds of libraries. Second, autocomplete in Eclipse (and other IDEs, I assume) can show you JavaDoc information inline, saving you a context switch out to your browser to view them.

5. Getting useful information about the code you are working with

What calls this method? Where is this variable referenced? What classes implement this interface? What does this class’ inheritance tree look like? All of these are pretty useful things to know, and IDEs make them trivial to discover.

6. Code navigation

Ctl+o in Eclipse opens up a list of methods in the current class, ctl+o again changes the scope to all of its parents – this makes it trivial to navigate to a specific method. Ctl+clicking on a class or method takes me directly to it.

7. Easy access to sources

Being able to jump directly to the source of a library is often useful as well, and this works quite well in current IDEs. M2eclipse will automatically download sources for Maven-based projects, which makes this even easier.

8. Refactoring

One of the benefits of statically typed languages such as Scala is that you can refactor your code with a high level of confidence that you haven’t horribly broken something. IDEs make this task even easier.

9. Version Control integration

It is also nice to be able to interact with a version control system directly from your IDE, without having to switch to another program to checkin your changes, perform merges, get new code, etc.

Final Thoughts

You’ll notice that of the uses for an IDE I’ve pointed out above (which are not a comprehensive list by any means), at least half of them are especially useful for someone learning a new language or framework. Yes, I know Scala has a REPL that is quite useful for when you are initially learning and playing around with the language, but I think an IDE is incredibly helpful for that phase when you’ve been playing with the language for a month or so and are now trying to do something productive with it – the instant feedback and wealth of information that an IDE can provide is incredibly valuable during that time.

This wasn’t intended to be a mean-spirited post and I hope it didn’t come across that way. I’m just trying to point out that IDEs are not crutches for hack programmers who want a tool to write code for them – IDEs are incredibly useful, even for Scala.

  1. Spot on Spencer – great points

  2. I agree, IDEs are about productivity. I am learning Scala and my biggest gripe is the lack of a solid IDE environment for it. I started looking at the netbeans plugins and then i was getting nightly builds of the plugin, …

    Now I work with eclipse and I’ve got to use an older version with plugins for maven and scala, but the interactions/configurations aren’t straight forward. I’ve got to learn the quirks of the IDE asa I get up-to-speed on Scala.

    To be honest, I liked Visual Studio best in terms of running right out of the box. I’m not critiquing c# or library availability, just saying in terms of a no-hassle IDEs Visual Studio worked well.

    Thanks for a great write-up Spencer!

  3. Does the Scala support for Emacs not include this? Because everything on this list is not hard to do in Emacs for languages like Clojure. It doesn’t really strike me as an Emacs vs IDEs question but rather a “the Emacs scala-mode may have some catching up to do” question.

  4. Phil: Does the Emacs Clojure mode let you find all the functions that can operate on a given object (Auto Complete)? This is the sort of thing that is really easy to do with Eclipse for Java. Type “x.” and press Ctrl+Space and be presented with a list of all the methods for object x. Better yet, if you have something like “int foo = x.” and press Ctrl+Space, you’ll first be presented with methods that return int. I thought that this was impossible in a dynamically typed language, unless your editor does some very fancy type inference.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>