United States (change)
Shortcuts: Downloads Fedora Red Hat Network
Issue #18 April 2006
As a long-time Emacs™ user, and a typical command-line-oriented UNIX® person, I was skeptical when I first heard about Eclipse™[1], an extensible open source integrated development environment. Even when I was working[2] to make Eclipse run when compiled with GNU gcj[3], I used it primarily as a smoke test for the compiler and GNU Classpath[4] libraries.
However, I saw quite a bit of Eclipse, and I frequently heard it described as the premiere open source integrated development environment, especially for Java. So, seeing that I work on GNU Classpath, which is mostly written in Java, I decided that I would give it a serious try.
The best way I could think of to do this was an experiment: for two weeks, do all of my Classpath work in Eclipse. (Naturally I wasn't so rash as to shut down Emacs--after all, that is where I read my email.)
I won't bore you with all the details of setting up GNU Classpath so that it would build properly in Eclipse. Because Eclipse is reasonably flexible, we were able to make it work. However, because none of the Classpath hackers were Eclipse experts when we started, it did take a while to iron out the problems. (This is to be expected when integrating any project's existing build setup into an IDE. The process is much simpler if you are starting fresh.)
The result works quite nicely. First, parts of Classpath's autoconf-based build are run. This is needed because some Java source files in Classpath are built by 'make.' For most of the build, however, we rely on Eclipse's internal Java builder; the benefits of this will be discussed shortly. Following this, the native code in Classpath is then built, again using 'make.'
Developers today can simply check out Classpath and have a completed build in minutes[5].
My experiment began with a plain Classpath build, which let me explore the basic functionality of Eclipse, both general and Java-related.
The most interesting aspect of this, for me, was that by using the built-in Java builder in Eclipse, we got to take advantage of Eclipse's excellent built-in compiler. What I found here surprised me: Eclipse's compiler is not only quite fast--it can build the one million lines of Classpath in under a minute while remaining incremental.-- This function means that many compilations are complete and the results ready to be run as soon as I've saved my changes. This is not just cool, but also supremely practical, as it eliminates one of the main causes of waiting (and thus loss of mental flow) while programming.
The compiler also builds an internal model of your Java program and uses this model to support refactorings. Many different refactorings are supported; a simple example is that Eclipse can change the name of a program entity (field, class, package, etc.) and update all its users without accidentally updating a part of your program that uses the same name but actually refers to something else.
This model also lets Eclipse provide a number of features which rely on knowledge of your program. So, for instance, you can change a class to implement an interface and have Eclipse provide stub implementations of all the newly-inherited abstract methods. Or, for daily use, things like completion are completely context-sensitive. For instance, when trying to complete the name of a method in an invocation, Eclipse will only offer names which are actually methods available in the qualifying type.
The Eclipse SDK has some awesome technology in it. But how useful is it on a daily basis? Here I walk through some tasks frequently needed when hacking on GNU Classpath.
Eclipse is not a panacea, and, despite the marketing, it also isn't a universal tool. It still has shortcomings compared to the traditional UNIX environment.
In addition to the editor's problems, scripting in Eclipse is nonexistent. On occasion in Emacs I will write some Lisp code for a particular task; the one time this occurred with Eclipse I wrote a program externally and used it instead.
Eclipse uses a lot of memory, partly because it is enormous, and partly because it does keep a model of your entire program in memory. It runs comfortably on my 1G machine--but was sluggish when I had 512M. (Remember when we thought Emacs was huge?)
The Eclipse GUI is a bit strange and could benefit from the attentions of a GUI designer. Some things like adding builders or importing existing projects are a bit idiosyncratic. Also, Eclipse more or less assumes that projects have a single implementation language. So, for instance, we treat Classpath as a "Java" project, even though it includes a fair amount of C code.
Since my experiment, I've done all of my Classpath hacking in Eclipse. I think that my general productivity has risen as a result of this switch, the mark of a good tool. In particular, I find that Eclipse has removed much of the drudgery of daily development--waiting, futzing with build scripts, and writing boilerplate.
Eclipse isn't perfect for Classpath development. There are a number of problems we've discovered which we would like to have resolved. Also, Eclipse doesn't really handle native methods in Java code at all right now; this area could use a major overhaul.
I've also noticed that moving from developing Java in Eclipse back to developing C or C++ in Emacs is fairly painful. The C/C++ tools are ripe for improvement, following the model laid out by Java: incremental compilation, incremental linking, eliminating waiting during development.
Tom Tromey is an engineer working on gcj at Red Hat. He has worked on many free software projects over the years, and co-wrote GNU Autoconf, Automake, and Libtool.
[1] http://www.eclipse.org
[2] http://lwn.net/Articles/43096/
[3] http://gcc.gnu.org/java/
[4] http://www.classpath.org/
[5] http://developer.classpath.org/mediation/ClasspathHackingWithEclipse
[6] http://www.sourceware.org/mauve/