Sunday, February 23, 2014

IntelliJ IDEA vs NetBeans IDE

Since November 2013 I have tried and tested IntelliJ IDEA Ultimate (version 13) and NetBeans (version 8.0 beta and some builds pre and post beta. Please keep this in mind when you read the following as things may have improved in the final release).

I chose IDEA because many of my friends tell me it is the best. NetBeans because that was the first IDE I used (way back around when Eclipse 2.0 was king) and the one I used almost exclusively until late 2007 where I started using Eclipse or rather SAP NetWeaver Developer Studio. Hence there is some nostalgia in choosing NetBeans but also the fact that is a free polyglot IDE weighs in.

I have used the two IDEs on a Maven based project containing around 4000 Java files and 500 jsp and a lot of JavaScript. Frameworks used are Spring, Hibernate and various other. To be clear from the outset I have been more involved in NetBeans as I volunteered to be part of the NetCat for NetBeans 8.0. I thought that was a good way to learn the IDE. To be fair against IntelliJ IDEA it should be stated that what I focus on in this blog entry is not tied to the Ultimate edition.

There are obviously many parts of both IDEs that I have not used. However what I have used is the basic stuff that any decent Java developer will use.

Here are my findings:


General findings:

IntelliJ has ctrl-w and Netbeans has alt-shift-period. Both commands select the syntactical element the caret is placed at and pressing w or period multiple times will expand this selection (you can also decrease the scope using other commands). When editing Java files the two are equally good but when editing JSP/html and JavaScript files IntelliJ is far superior. I have added an enhancement request to NetBeans.

NetBeans code refactoring tools are not the best. For instance introducing a new variable does not  give you an easy way to change the type  of the new variable (in IntelliJ this works). I have filed an enhancement request for this in NetBeans. I also experienced another problem with NetBeans not being able to extract a method but in fairness to the NetBeans team it should be stated that they promptly fixed it.

I have also experienced some strange problems in NetBeans, for instance that running a Spring Boot project will not shut down the Tomcat process that fires up when stopping the project from running. This means that the Tomcat port will be taken when you rerun the project (this is Mac specific). Doing the equivalent in IntelliJ or Eclipse for that matter takes down the Tomcat process (also on a Mac). I also experience exceptions that the NetBeans team say is caused by the JDK (1.8 which they recommend) but that they won't/can't fix or work around. Maybe Mac and NetBeans are not a match made in heaven because have also reported another bug that is related to Mac and that can't be solved.

Slowness issues:

Running unit tests in Netbeans is very slow compared to IntelliJ (my workflow is the usual TDD flow where you make some tests, make code change, run test and so on). It seems to me that Netbeans is noticeably rebuilding everything via Maven to run a single test, whereas IntelliJ must have a better model or does something in the background as you code as it can run the tests immediately (turning compile on save on or off in NetBeans does not change this).  I have filed an enhancement request to NetBeans.

Alt-F7 in NetBeans and IntelliJ means the same thing: finding usages - something I do a lot. However, finding usages in the two IDEs is very different. In NetBeans finding usages takes some time (you acutally have to wait while the IDE searches) whereas the usages pop up immediately in IntelliJ. This must be due to some superior indexing in IntelliJ. Also simply finding files or types in the two IDEs show that IntelliJ has better indexing and it gives you instantaneous results.

Debugging in NetBeans and IntelliJ also leaves you with two very different user experiences. NetBeans is annoyingly slow at showing the variable values.  I often have to sit and wait for long enough to notice that I am waiting.

When you import a Maven project into NetBeans, it will try to update its Maven index (at least on the first run, but I experienced it often, also simply when adding new dependencies in the pom files). This is a very painful experience as it takes a lot of time to process the index files that it downloads (+10 minutes where the IDE is practically unusable - but I least I get to hear my fans fire up).

NetBeans IDE has a slowness detector which will report an exception if an operation takes more than 5 seconds. I think 5 seconds is a long time to wait and that should probably be down to 2 seconds for IDE operations (of course if you ask it to do a Maven build, you can't blame the IDE for Maven being slow).

Final words: 

To be honest I started out the investigating hoping that NetBeans would be better. But IntelliJ is simply a better IDE. But don't take my word for it, try it yourself. That said, is was fun to be part of the NetBeans community, finding and filing bugs (of which I have filed +40 in the last two months) and seeing them get fixed so I will probably give NetBeans a try again later which might be when I have to pay for a personal license for IntelliJ :)


I have fixed some cut and paste errors and typos after publishing this entry.