A Comparison of Eclipse, IDEA and NetBeans

This article is an in-depth comparison of Eclipse, IDEA and NetBeans, the three major JAVA integrated development environments

Introduction

Eclipse and IDEA are definitely the best java IDEs around, and nobody can deny that. Now about the two of them, a flame war is going on, similar to Unix vs. Windows, VI vs. Emacs, Java vs. .Net.... NetBeans on the other hand, wasn't a very bright product in the past, but version 5 (beta) has a decent set of features that makes it almost a serious competitor for Eclipse and IDEA. Which one is the best? Which one is the best for you? What's the value and the subtle differences between all those cryptic features that seem all the same on paper? Hope this article will help clarify some of these questions and more importantly, help you choose.

Code writing assistance

Code writing assistance is one of the most important features in today's modern java IDEs. It's what helps you gain time, lets you concentrate on the logic instead of searching for the name of that method you need to call, helps you analyze the code, reorganize it, make it more readable and maintainable.

Code completion

Code completion has been around for many years, in many development environments, not just JAVA ones. So the obvious question is: what could possibly get better about this? Well, you'll be surprised..

All three IDEs I'm examining here offer some form of code completion. If you type a few letters and then you press CTRL+SPACE, the IDE will offer you a set of choices: class names or variable names. The most advanced code completion features are offered by IDEA. The big difference when compared to the others is that IDEA's code completion is context aware. This means that options that are offered to you when you initiate code completion are filtered with respect to the code fragment where the cursor is located. Indeed, instead of proposing you all the classes of the universe - the universe being your project class path :-) - IDEA will only offer you a reduced, less confusing, set of choices which in 95% of the situations will result in compiling code and in 85% of the cases they'll promote on top of the suggestions list the entity that you're actually looking for. They call it smart code completion and it's not an exaggeration.

How does smart code completion work? For example, if you have int variables a, b, c, d and double x, y, z and you type a = CTRL+SHIFT+SPACE, IDEA will only propose you only b, c and d. Definitely not x, y or z and definitely not class names or other entities. For return statements: if your method returns Person, if you type return CTRL+SHIFT+SPACE IDEA will only propose you variables of type Person or its specializations and methods that return instances of Person. Same thing goes for throws statements: when activating code completion after a throw statement IDEA will only propose you instances of the exceptions that are declared to be thrown by the method which you edit.

Smart code completion also works very well when instantiating objects: in assignments, return statements or throw statements, when you activate code completion after the new keyword IDEA will propose you only suitable constructors, as previously explained. The detail level is pushed to limits never seen anywhere else. For example, suppose you have a variable called count and you want to initialize it by calling a method on a class. If that class has a getter that contains "count" in its name - such as getCount() or getObjectCount() - that returns the type of the variable, IDEA's smart code completion will pre select that method for you. All you have to do is press ENTER t select it.

One of the most important features regarding smart code completion in IDEA is that it can be activated without typing the first letters of he text you want to complete. This is very time saving features as in most cases it prevents you from having to scroll to the beginning or the end of the class to remember how that variable or method is named. IDEA will efficiently look up all variables and methods that match the type of the assignment or of the parameter you're looking for and propose only those. Same thing when you want to cast a reference to an object. Type ( CRTL+SHIFT+SPACE in front of the object you want to cast and IDEA will automatically insert the REQUIRED class name.

IDEA expands the concept of code completion by transforming it into an efficient code querying mechanism, which is ready to serve the right variable, parameter, method or class names whenever you need it, with respect to the context in which you invoke the functionality. And it also does a very satisfactory job in guessing which variable, parameter or method you wish use and pre selecting it for you. Plus, it's extremely easy to use. You don't have to learn many keyboard shortcuts. Whenever you need assistance when writing code, press CTRL+SHIFT+SPACE and you'll be surprised how well it works.

Code completion and parameter guessing in Eclipse are disappointing, which is a shame, because I consider ECLIPSE to otherwise be a fairly good product. Compared to IDEA, what you get in Eclipse is a joke. It's as primitive as it can get. This may seem harsh, but its reality. You type int i = CTRL+SPACE and it will propose you huge list of entities containing all the classes in the class path, all variables, all methods.... After scrolling in that list for a while you will eventually find the entity you need. Smart code completion doesn't exist. It's just raw code completion without any context filtering. This is very frustrating because there are signs that the knowledge to implement smart code completion in Eclipse is there. You can see it with the javadoc code completion feature: if you type @throws CTRL+SPACE it will only propose exceptions that are declared by the method for which you write the comment. If I would be to designate a functionality in Eclipse that needs urgent improvements, this would be it. Code completion is one of the first features a new user comes in contact with. If Eclipse wants to attract IDEA users, the primitive code completion features now in place are a huge barrier. It's the main reason that kept me from adopting it.

Netbeans 5 (beta) offers about the same level of code completion functionality as Eclipse does, but slightly better and easier to use. You get class and local variables on top of the list and classes and packages at the end. That's a small detail but an important improvement already.

Well, the winner in this category is - you must have guessed - IDEA. By far. Netbeans comes in second, followed by Eclipse. Both offer very basic code completion but the functionality in Netbeans is slightly more usable.

Code template expansion

Template expansion is another time saving feature mainstream java IDEs support nowadays. The feature consists in a setting up an abbreviation which when typed and followed by a specific key combination expands to a full featured piece of code. For example, you could set up psf+TRIGGER to expand to public static final. Or sout+TRIGGER to expand to System.out.println. Once you get used to this feature you become addicted. Templates are written in a simpe language, which can do more or less advanced things, depending on the implementation.

IDEA's code template expansion feature is the most advanced, mainly because the template definition language takes advantage of the state of the art code querying mechanism that is built into this IDE. When defining templates in IDEA you can query variables of a certain type, or of certain types.

For example, the following template could expand into while (iterator.hasNext()) { Person person = (Person)iterator.next() } and the cursor will be placed where the END tag is.

while($ITER$.hasNext()){ $TYPE$ $VAR$ = $CAST$ $ITER$.next(); $END$ }

This is cool already, but it gets even better when you notice that you can ask IDEA to replace $ITER$ with variables of a certain type - in this case, Iterator. This can be done by specifying that $ITER$ is a variableOfType("java.util.Iterator"). After doing so, when the code is expanded, IDEA will ask you to choose one of iterators in scope. You can also specify that $TYPE$ should take the value rightSideType(). This takes effect with typed collections in jdk 1.5 - at expansion time TYPE will automatically be replaced with the type of the elements contained in the collection. Regarding $VAR, you can ask IDEA to suggest a variable name, by setting it to suggestVariableName(). If you do so IDEA will propose you variable names based on the contained type. For example, if the type is ImageDescriptor IDEA will propose descriptor and imageDescriptor. All you have to do is choose the name you like most or type your own if your not happy with any of the default ones. Choosing one of the proposed choices, however, tends to result in very readable code.

It's possible and very easy to write your own templates. I wrote one to help me initialize log4j loggers. This is the typical situation where template code expansion is very handy. Initializing a logger is an annoying, repetetive task which doesn't have anything to do with the business logic you write. Here is a small template that helps you deal with the problem:

private static final Logger log = Logger.getLogger($CLASS_NAME$.class);

Then you instruct IDEA to give $CLASS_NAME$ the value className(), register your template under the logdecl abbreviation and you're set. All you have to do from now on is type logdecl+TAB and that IDEA will declare that annoying logger for you.

Apparently Eclipse offers code template expansion too, but I haven't been able to make it work. Just couldn't find it. But apparently it's there. But if I can't find it it's just like it wouldn't be.... hmmm......

Netbeans offers code template expansion with almost the same features as IDEA - it's slightly less flexible though. You can define your templates, define shortcuts - I have the feeling there are less options then in IDEA. On the other hand, I've not been able to change the activation key - which is SPACE, by default. Also, the activation sequence is kinda weird: the template is only expanded if you press SPACE just after the abbreviation. If you type the abbreviation move your cursor, then come back and try to expand, it doesn't work. Have to delete the last letter, retype it and quickly press SPACE . I haven't been able to change the activation key - the config dialog let's you change it, SPACE doesn't work any more, but the new key doesn't work either.

The winner here is IDEA again, with Netbeans comming in second and Eclipse third.

Getter / Setter / Constructor generation

Getter / setter / constructor generation features are comparable in IDEA and Eclipse. Both products offer quite complete features and there is nothing much to say on this matter. Netbeans has a slightly different approach on getter / setter generation: the feature is not available under the "source" menu, but under "refactoring", and it's called "encapsulate fields". A little weird - I wouldn't think about this as refactoring - but hey, the feature is there. If I had some trouble finding the getter setter generation feature, I was totally unable to find an action to let me generate constructors. This is not a very good point for Netbeans, as constructor generation is a very widely used feature. The feature may be there but if I need more the 5 minutes to find it, it's just like it's missing. So the winners in this category are IDEA and Eclipse with similar and equally easy to use features with Netbeans coming in third, offering hard to find, not so easy to use functionality.

Usage finding

Usage finding is an extremely useful feature when needing to evaluate the impact a specific change in code would have have on the rest of your project. Most used such functionalities are to search for usages of a variable, a method, an interface or a class. For example, if you plan to add a new method to an interface, you can search for all classes that implement that interface and evaluate the work effort required to implement that method. Or you can search all the usages of a class or just of a method of a class in order to determine how much it is used in the system, in order to evaluate the risk involved with changing it. The more frequently it is used, the more critical it is, and the more careful you should be about modifying it, as a defect or a performance issue introduced in a heavily used entity may have repercussions on the entire system.

IDEA and Eclipse offer good quality, similar usage searching features. While IDEA offers a unified access point to code analysis via the default ALT+F7, Eclipse offers the same set of features but not in a centralized way. Implementing classes / derived classes can be searched for via the hierarchy view while method / class / variable usage can be searched for using the "References" contextual menu, different scopes being proposed, just like in IDEA. Eclipse has a special little feature: when set, when you place the cursor on a java element (class, variable, parameter, etc) it will highlight the positions in the code where that element is used. I'm not a big fan of it as I feel it kinda pollutes the screen and therefore I disable it every time I use Eclipse, but many people love it. IDEA, on the other hand, implements a more precise method usage search, letting you find methods that implement an interface method or an abstract method in a class or methods that override a method of a class. I haven't been able to find a similar functionality in Eclipse.

What about Netbeans? Well, the feature in Netbeans looks a hell of a lot similar to the one in IDEA. It's called "Find usages" and it's even accessible using CTRL+F7 (it's ALT+F7 in IDEA :-) ). Apart it's look and feel being a 98% identical copy of what IDEA offers, the feature itself seems quite reliable and complete, keeping up to the standards set by the competition.

The score is very tight in this category, with all products offering strong, quality features. IDEA offers a little bit more accurate method usage searches, while Eclipse has a few small useful features such as on the fly usage highlight. Netbeans copies on IDEA on the functionality and manages to offer a feature of comparable quality.

Multi-module project support

So what's this all about? Well, when you develop a bigger project you most definitely end up defining more then one logical modules, which correspond various architectural layers.. For example you mau have a presentation module - dealing with user interfaces, a data model layer, a business logic layer and a persistence layer. Of course you want to keep the four modules well isolated, with a clear dependency schema in place: presentation layer depends on business logic and data model and business model depends on persistence layer and data model. Persistence layer depends on data model which doesn't depend on anything. Keeping the modules isolated is a good idea for many reasons, most important being clearly identified roles for each component, you get a more easy to develop and to maintain architecture, it's more easy to identify and fix issues, and so on....

This is why multi module project support is really important. The main features required to obtain a reasonable functionality are: 1) be able to configure isolated logical modules with separate source code directories, separate libraries and separate class destination directories, 2) be able to define dependencies between modules and 3) be able to build each module independently.

IDEA and Eclipse offer similar multi module project functionalities, but the terminology is a little bit different.

IDEA offers true multi-module project support. Modules are easy to set up and configure. IDEA also offers specialized modules, such as EJB modules, WEB modules or simple java modules.

Eclipse doesn't have multi-modules projects, but it has an equivalent feature. In eclipse you can define many work spaces. Each work space can contain many projects. Each project has its own source code tree, its own libraries dependencies can be defined between projects of the same workspace.

Netbeans doesn't have the slightest support for this feature, and this is one of the major reason for which netbeans is not well suited for managing bigger projects.

The winners in this category is are clearly IDEA and Eclipse, which offer a complete and very usable feature. Netbeans is falling far behind.

VCS integration support

Smooth integration of versioning control systems is critical. All three systems offer the feature, however there are enormous differences in provided usability and functionality.

The best functionality is offered - not much of a surprise here - by Eclipse and IDEA. The competition is really tight here: on one hand, with Eclipse offers a user experience far better then IDEA's, on the other hand IDEA offers out of the box integration with more systems then Eclipse does.

Eclipse offers CVS integration out of the box - and a fine integration that is!!! It is the best I've ever seen, best functionality, best usability. Eclipse does a really great job in hiding the details of the VCS backend that is being used behind the scene. The Team Synchronizing perspective instantly shows you what files you modified and what files have been modified on the server. Files that need merging are highlighted. If you choose to update your sources from the server, a three way merge utility is invoked whenever necessary. New files are automatically added to source control, even those files were created when working disconnected. This may seem as a detail for most of you, but it's extremely important to me, because I'm a commuter and I work on train - read: no network connection - 2 hours every day. This is where Eclipse kicks IDEA out of the ring: with Eclipse, it doesn't matter if you're connected or disconnected: you work the same way: you create some new files, delete some obsolete ones, you do all the refactoring you want - including renames and moves. Later - like when you get to the office - you connect to the network, go to the team synchronization perspective and synchronize your source. Ecipse takes care of everything: adds new files, removes files that must be removed and at the end of the process, in just a few mouse clicks and no headaches, your project is correctly synchronized. The best thing about VCS integration in Eclipse is that until the moment you decide to synchronize, you can forget about it, it's transparent, it' just like it wouldn't be there. And this is what I call good integration.

Not such a smooth ride with IDEA, I'm afraid. With IDEA, if you use a VCS system in your project, then you definitely know about it. IDEA does and excellent job reminding you of it. At each operation you perform on your files, IDEA wants to know if you want that operation to be applied to the VCS, like I'd configure VCS systems on a project just to make my day a little bit more complicated.. Seriously: you create a file, IDEA kindly asks if you want to add it to the VCS.... you delete a file, IDEA wants to know if you want to remove it from the VCS.... If you use CVS and you perform a rename or move refactoring, IDEA want to know if a) you want to remove the former files from CVS and b) if you want to add the renamed file to CVS.... It ends up really getting on your nerves.... Well, you'll say, what keeps you from checking that checkbox in those annoying dialogs that says not to ask any more, just perform the VCS operation automatically? Well, nothing, I'd say, except that if you work disconnected - and if you have a laptop, you often work disconnected, even if you don't commute - IDEA will try to connect to that VCS server every time you make a move. IF you have that annoying dialog popping up, you can at least say: don't add to CVS, don't remove from CVS, and the next day, at work you can spend like about an hour trying to fix up the mess in your project: figure out which files you must delete from CVS, which files you must add, and you must do so manually. IDEA has a "check project status" option in the VCS menu, but it's nor very useful, it just gives you a few indications... You still have to clean up the mess manually. And trust me, you learn very quickly what a bad idea it is to refactor your code when you're disconnected. You also end up with a lot of TODO annotations like: // TODO: rename this class when back at the office. And of course, if you have checked that option to tell IDEA to just do whatever it want with the VCS without asking you, it'll try to connect each time, and it'll block for a few seconds every time, and all this turns very quickly into a usability nightmare.

So, is IDEA really so bad when it comes to working with VCSs? Well, it's ok if you work on desktop systems which are always connected. If you ever get disconnected - like your router breaks or some other defect renders the network unusable, then it becomes very difficult to stay calm. Once you've seen how VCS integration works in Eclipse, you keep asking yourself, why can't IDEA do the same thing? after all, Eclipse is copying on them big time, why don't they copy back on this one?

Otherwise, IDEA offers out of the box support for five VCS systems: CVS, Subversion, Visual Source Safe, StarTeam and Perfoce, while Eclipse and NetBeans only support CVS out of the box. This is a good point for IDEA, especially with Subversion becoming more and more mainstream. For Eclipse you can find plugins for most of the most of the VCSs out there, but you have to install it, and sometimes it gets tricky to install plugins in Eclipse, and you may not get the same quality of integration as for CVS. I'm not sure if it is possible to plug a VCS other then CVS in netbeans.

Both IDEA and Eclipse let you define different VCS configurations for each module (or project). Since Netbeans doesn't support multiple modules per project, this feature doesn't apply.

all content (c) 1998 - 2005 Emil & Maria Kirschner