Interpreted Java

It’s long past time to continue on a path I started down some time ago. About four years ago, Renaud Waldura posted a blog entry titled “Ten Reasons to Use Eclipse”. A few months back, I started reviewing the ten reasons to see what’s changed. My previous entries are here:

  1. Ten Reasons to Use Eclipse
  2. Eclipse is a platform
  3. Eclipse Has Momentum
  4. Eclipse is Easy To Extend
  5. The Eclipse Workbench: Views, Editors and Perspectives
  6. Eclipse is Faster
  7. Never Compile Again

Reason #8 is titled “Interpeted Java”:

Eclipse is revolutionizing Java development by bridging the gap between traditional static languages (think C++) and dynamic OO environments (think Smalltalk). Java developers are used to the repetitive compile/debug/test cycle typical of static languages. Eclipse uses a combination of advanced techniques to emulate a dynamic programming environment normally associated with interpreted languages. This amazing feat gives Java developers the benefits of both worlds: a compiler still performs static analysis, and the repetitive compile/debug cycle yields to a smooth write/test activity.

Let’s look at a spectacular example. As mentioned above, Eclipse builds fully incrementally: it will even let you run code containing syntax errors. Calling a method with compilation errors in it breaks into the debugger, where I can fix the error and resume the execution as if nothing had happened. Behind the scenes Eclipse compiled the new class and dynamically replaced it in the running VM. My Java program can be changed, and in fact, almost be developed, while running! This amazing feature is known as hot code replace, and requires the latest JDK to work best. Eclipse Fill-in Templates

Ctrl-Space in Java editor popped a fill-in template

Because all code is always compiled, Eclipse has detailled knowledge of the methods and classes making up an application. In addition, the Java editor also constantly parses code as you type it. This unprecedented depth of knowledge about the code blossoms in a bouquet of sophisticated features inaccessible to a purely text-based editor. It makes the environment incredibly smart and able to provide contextual help at a level I had never experienced before.

To wit, the Java editor offers completion on class names, method names, and even argument names. It detects typos as they are made, underlines the offending statements, and offers corrections, e.g. creating a previously undefined method or class. It auto-imports classes when needed, and can flag useless import statements. Fill-in code templates are tailored to the current context, and save on typing efforts.

To summarize, the Eclipse environment leads code writers with an expert hand, and increases productivity by providing immediate feedback about the code.

The title threw me off a little at first. Eclipse relies on a Java Virtual Machine (JVM) to run Java Code. That is, Eclipse doesn’t run Java code in any form, interpreted or not. As Renaud discusses in his post, the Eclipse Java development tools (JDT) does indeed interpret Java code to make the editing experience better. By interpreting the Java code, JDT can provide great things like syntax highlighting and very intelligent code-assist. And it’s just gotten better. Code assist is way smarter than it was four years ago. It now features even more advanced features like null reference analysis and hyperlink debugging; these features are made possible because Eclipse can actually make sense of the code.

It’s natural that Renaud’s list is very focused on the JDT; four years ago, JDT was the schiznit (and in fact still sets the standard for language support). Eclipse continues to grow, supporting numerous languages. The C/C++ Development Tools (CDT) project released version 4.0 sporting huge advances in functionality as part of the Europa release. Europa also includes support for Ruby and TCL development thanks to the Dynamic Languages Toolkit (DLTK) project. DLTK also provides support for Python. Add PHP support to list (courtesy of the PHP Development Tools (PDT) project). The list of languages now supported by Eclipse is huge (and growing). The potential for Eclipse to support a virtually unlimited number of languages (with Mylyn integration) is realized with the DLTK project.

I’ve never gotten quite as comfortable developing with the debugger as Renaud suggests. The hot code replace features in Java are still nowhere near as flexible as Smalltalk, so I find that I tend to fix relatively little code in the debugger (though I still do it occasionally). The code completion functionality, templates, quick fix/assist, and hyperlink stepping features just seem to keep getting better and I’m well beyond the point of being able to live without them. What’s even better is that the same sort of functionality is being offered for other languages as well.

And incremental compilation just plain rocks. Plus the ability to run code that contains errors is very handy during development. I wonder why other folks haven’t tried to copy that?

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Interpreted Java

  1. Pingback: Eclipse hints, tips, and random musings » Blog Archive » Team Development

Leave a Reply

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

You are commenting using your 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