Never Compile Again

I’m up to reason seven in the “Ten Reasons to Use Eclipse” posted by Renaud Waldura (my discussion of the previous six reasons can be found here: 1, 2, 3, 4, 5, and 6). I have to admit that this is one of my favourite reasons.

One aspect of Eclipse I dearly love is the utter lack of a “Build” or “Compile” button. Isn’t it paradoxical, an IDE that doesn’t let you build? IDEs started precisely as GUI wrappers around a compiler and a make tool, how can the “Build” feature be absent?

Here’s the key: Eclipse always builds for you. Every time you save a file, run a program or a tool, or any other action that accesses resources contained in the project, Eclipse compiles. This essentially means your code is always compiled. (Note that a “Rebuild” menu option is still present for those rare cases that require a manual build.)

I find this to have a profound impact on my programming work. For the first time I’m working in an environment where the natural state of code is compiled. Text, source code, used to be the primary form of a computer program. In Eclipse, source code has almost become a transient state, used only as input to the compiler. As soon as possible, and in fact, almost continuously, code is compiled to its binary form, with all the benefits of compilation (type checking, static analysis, etc.). Eclipse also builds incrementally, thus ensuring that most build operations are completed within seconds.

I couldn’t agree more. Incremental compilation rocks. However, it does tend to catch people off guard. On a fairly regular basis, we get questions about compiling Java in Eclipse (generally on the newcomer newsgroup, or on EclipseZone). Most folks assume that there is a big “Build” or “Compile” button hidden somewhere but can’t find it. It’s initially hard for some folks to get their brain around the fact that compilation of Java code just happens (usually Eric or Ed will set them straight).

Incremental compliation ensures that your application code is always ready to run. As Renaud points out, Eclipse keeps track of the dependencies amongst all the files and rebuilds only those components that need to be rebuilt. Compilation happens in the background, so unless you’re paying attention, you’ll likely not even know it’s happening.

As an aside, something that a lot of people don’t know about the Eclipse Java compiler is that it was designed to be decoupled from the Eclipse platform. The JDT can be used separate from the Eclipse platform; even from the command-line. If you’re using Apache Tomcat to host Java ServerPages (JSPs), then you’re using the JDT. When you’re using the JDT batch compiler, you don’t get the fancy incremental compilation, but you do get a darned fast, top-quality Java compiler that you can easily make a part of your Ant build scripts.

I love the Java compiler in Eclipse. Of course the notion of incremental compilation isn’t anything new. We’ve had incremental compilers for years. I am duty bound to point out that incremental compilation was a fundamental part of Smalltalk. VisualAge for Java also employed incremental compilation. It is natural, then, that the JDT developers would make it a fundamental part of their implementation.

Them JDT guys are some smart.

This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Never Compile Again

  1. SDiZ says:

    I agree the “always ready to run” is a nice thing. However, the auto build thing can quite annoying when you use j2ee or other “slow” builder. Every time I save the file, eclipse just become very very slow for a few seconds. i always found the “waiting task to complete” dialog very annoying.I know i can disable that… but then I cannot enjoy the “always ready to run” feature….. maybe I should just get a faster computer

  2. Doug Schaefer says:

    Blasphemy! The C in CDT stands for Compiling rules!

  3. Pingback: Eclipse hints, tips, and random musings » Blog Archive » Interpreted Java

  4. Pingback: Fix Slow Computer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s