Saturday, January 03, 2009

IDE: NetBeans

After trying out Komodo Edit I decided to give NetBeans a whirl. Here's the summary: NetBeans is a pleasant to use, reasonably well-polished IDE that mysteriously seems to be missing certain key features that even Komodo Edit has. If I were to put my finger on it, I'd say that NetBeans is better at being an IDE (doing things such as code completion, code tips, etc.), but has a worse editor (for instance, it lacks a rectangle selection mode and it has no option to rewrap a multi-line comment block).
From the Web Site
Here are some high-level bits from the web site along with some of my own comments:
In addition to full support of all Java platforms (Java SE, Java EE, Java ME, and JavaFX), the NetBeans IDE 6.5 is the ideal tool for software development with PHP, Ajax and JavaScript, Groovy and Grails, Ruby and Ruby on Rails, and C/C++.

Discover the joys of Python programming with the NetBeans IDE for Python Early Access. Enjoy great editor features such as code completion, semantic highlighting, and more. The EA release also includes a community developed Python debugger and offers a choice of the Python and Jython runtimes.
Python is only supported in the early access release. I expect Python support to improve over time.
The NetBeans editor for Python supports Smart Indent, Outdent, and Pair matching, additional to syntactic and semantic highlighting, code folding, instant rename refactoring, mark occurrences, finding undefined names, and Quick Fixes. Code completion is available for local function and variable names as well as Python keywords. The editor also assists you by inserting and fixing import statements.
All that stuff seems to work. I opened a file. It gave me a PyLint-like warning that said, "The first argument to a method should be self or cls. I was using klass. I right clicked on klass and said rename. It renamed all the occurrences. Easy.
With the NetBeans IDE for PHP, you get the best of both worlds: the productivity of an IDE (code completion, real-time error checking, debugging and more) with the speed and simplicity of your favorite text editor in a less than 30mb download.
The IDE stuff works well. However, it definitely can't touch the speed of my favorite text editor ;) The fact that the download was only 25mb (109mb uncompressed) was indeed quite impressive in comparison to Eclipse.
The PHP Editor in NetBeans IDE 6.5 supports all standard features such as code completion, syntax highlighting, mark occurrences, refactoring, code templates, documentation pop-up, code navigation, editor warnings and task list.
The documentation pop-ups are amazing. The documentation for JavaScript even includes browser compatibility notes, and the documentation for HTML is straight from the DTD. Furthermore, the code completion isn't pre-baked as it is in Komodo Edit. If you register a new JavaScript library, it can do code completion on that too.
The NetBeans IDE has the JavaScript tools you need: an intelligent JavaScript editor, CSS/HTML code completion, the ability to debug JavaScript in Firefox and IE, and bundled popular JavaScript libraries. Your favorite JavaScript framework will get you 80% of the way, NetBeans IDE will help you with that last 20%.
Yep, all that stuff seems to work. It was even able to do code completion on CSS content when I was in a PHP file. You probably shouldn't put CSS blocks in PHP files in general, but the fact that it could still parse it and do code completion is impressive.
The Good Parts
First of all, let me say that NetBeans is stable. It hasn't crashed on me yet. It's also pleasantly attractive. I like the rounded corners, fonts, and icons. I don't feel overwhelmed by NetBeans like I do by Eclipse. Also, the training videos were very well done.
The Bad Parts
If I have a multi-line Python comment, there's no way to rewrap the lines. In Emacs, this is M-q. In Vim, it's gq}. I generally consider that a must-have editor feature.

It doesn't seem to support rectangular selections or column editing (i.e. cntl-v in Vim). I always say that that's one of the features that separates the really good editors from the mediocre ones (Vim, Emacs, Nedit, and Komodo Edit all have it). It's such a useful feature. When I searched for "column" in the documentation, one of the search results was how to add a column to a database. That really underscores my point that NetBeans is a great IDE, but not necessarily the best editor.

There are no Vim or Emacs key bindings. That's sort of a bummer. To be fair, no one ever gets Vim key bindings perfectly right anyway. Nonetheless, the IDE is decidedly mouse heavy. Many common editor tasks that deserve a key binding don't have one.

Opening up files is a bit painful. I really missed tab completion like in Vim and Emacs. What's worse is that Apple-o isn't the key binding for opening up a file. In general there are a lot of places where NetBeans follows the standard OS X conventions such as Apple-x to cut, but there are some strange places where it deviates from those conventions.

It doesn't support editing a file remotely using scp.

I don't see a way to tell it to run "make test". Komodo Edit let me run "make test" and then click on file names if there were errors in the output.
Other Commentary
I created a new project from existing sources. On the downside, this created a new folder in my project. On the upside, that folder was only 8k worth of data. I definitely don't feel like I have to make everyone on my team switch to NetBeans before I can start using it. It says that it can synchronize with Eclipse projects, but I don't actually need that feature. During the project creation wizard, it expected my source files and my tests files to live in different trees. That was sort of weird. I just told it to use the same directory for both.

It says it can do JavaScript debugging in Firefox and IE, but I didn't get a chance to try that out.

It supports code snippets, if you're into that sort of thing.

For PHP, it can do code completion of symbols in other files. It also shows you the documentation that you wrote. I tested it, and it worked for Python too.

For PHP, it will warn you of uninitialized variables.

It does have version control support built in. The graphical diff utility was very nice. Committing code changes was painless.

As you would expect, it does provide a line at column 80. As I mentioned before, that was a pain for me in Vim.

The code folding support works very well. Functions are automatically recognized as something you can fold. Better yet, it understands HTML well enough to fold blocks of HTML.

When I opened a Python file, there was a widget that showed me an outline of the file, including all the classes and methods. It worked pretty well in PHP too.

It said that "from __future__ import with_statement" was an unused import. I think that's a sign that its Python support is still pretty young.

There's a margin to the left of the code that shows me what lines I've changed. It's like the diff is built into the editing experience.

In general, the code completion is pretty good. However, it got confused when I typed "from a import b; b.something". I think it didn't understand that I was importing an entire submodule.

The code completion for "self." was pretty helpful. It even showed me my own docs.

If I type "from a import ", it shows me a list of things I can import. That worked pretty well. However, when I picked something, it included the argument parameters like "from a import b(c)", which was sort of a weird bug.

When I'm calling a function, it tells me what arguments that function accepts. That works for builtin functions or functions in the current file, but it doesn't seem to work for functions in my other modules.

It recognizes JavaScript syntax errors, even if I'm in an HTML file. It knows that 10p is not a valid value in CSS for the border field, however 10px is.

When typing HTML, it's very helpful about adding closing tags, indenting within tags, etc. If I put my mouse on a tag, it shows me the closing tag.

The "Find Within Project" feature (i.e. project-wide grep) was powerful and friendly.

There was a menu item called "Insert a Method". It just dumped a code snippet at my current cursor location without even bothering to indent it properly. However, the "Insert a Property" menu item was truly helpful. It knew the correct idiom for creating properties (the one where you use locals() and **).

There are a ton of things in the Source menu that don't seem to work yet or at least don't work as I would expect them to.

The Python console is exactly as you might expect. I wonder when the IDEs are going to discover that IPython rules. Seriously, it doesn't matter that the shell is integrated into the IDE. If it isn't IPython, I'm not going to use it. By the way, I hit cntl-d in the shell, and it stopped responding ;)

If you open up a CSS file, you can use the CSS Builder and CSS Preview widgets. The CSS Builder is basically a point-and-click GUI for creating CSS. It's helpful, but not overly intelligent. For instance, I wanted the "margin" to "All" be 1px. It added four separate lines for margin-top, margin-bottom, etc. The CSS Preview widget is indeed helpful, although I'm not sure how well it will work as soon as you start getting multiple CSS files in the mix. Thankfully, Firebug helps out a lot for this problem.

When I closed the CSS file, the CSS Builder and CSS Preview widgets didn't go away as I would have expected them to. This probably suggests something deep about Eclipse's support for "Perspectives" which are sets of widgets useful for the task at hand. (There's a perspective for Python and there's a perspective for HTML and CSS.) Of course, perspectives are one of the things that make Eclipse feel overwhelming to me.

You can "undock" an editor window to put it into a new top-level window. I know Emacs fans are proud of this feature in Emacs.

It's possible to split the editor window to edit multiple files side-by-side. However, I must admit that I couldn't figure out how until I looked in the documentation.

I typed "getenv" and told NetBeans to add the import line. It did it correctly. It even added it to the correct block of imports, but that might have been by coincidence. Personally, I think this feature is overrated. Perhaps it's more critical in Java.

It told me that I was using an undefined variable when I used a global that was defined in another function. It doesn't know that in Python, you only have to use the global keyword if you want to rebind a global. It's not necessary if you merely want to read the value of a global.

In PHP I defined a function called f and then tried to call it. It was not able to autocomplete the name of the function. However, it was able to autocomplete on PHP builtin functions and to give me their parameters.

When I'm typing a multi-line comment in PHP (using "//") and hit enter, it adds "//" at the beginning of the next line. However, it doesn't do that for "#" in Python.

If I remove a colon from the end of a for loop or the end of a def, it doesn't
complain. That's a bit of a bummer since that's by far my most common syntax error.

Installing the PHP plugin was so easy. There was a list of plugins. I picked one and installed it. To be fair, I think this is more complex in Eclipse because Eclipse lets you install plugins from all over the web. In contrast, there are only about 100 different plugins for NetBeans. I'm guessing there are far more for Eclipse. I liked the fact that I could filter the plugins by the term I was looking for (in this case PHP).
Conclusion
I think I'll continue using NetBeans for a while. It's frustrating that it lacks advanced editor features, but that's not as heinous as the stability issues that Komodo Edit seems to suffer from. That's too bad, because Komodo Edit does a lot of things really right.

27 comments:

Fuzzyman said...

Wow, nice detailed review. Thanks.

Wade Chandler said...

If you like vi you should try:
http://jvi.sourceforge.net/

which is a NB plugin which makes the editor act like vi. It also does some things vi doesn't do and doesn't do some things it does, but does a huge amount of those things.

Ian Kallen said...

Nice thorough review, thanks. I'm pretty well established with my PyDev + subclipse setup but it sounds like PyDev is soon to be eclipsed by NB (pun entirely intended). I'll have to carve off time to test drive NB soon. Does NB have good subversion and git support?

mixedpuppy said...

Cool review.

Komodo also scans code. The 'pre-baked' functionality you refer to is there to make completions better than static parsing is able to do.

Also curious what stability issues you are referring to.

Regards,
Shane - ActiveState

Shannon -jj Behrens said...

> Wow, nice detailed review. Thanks.

Wow, a compliment from the Fuzzyman was worth the eight hours of effort ;)

Shannon -jj Behrens said...

> If you like vi you should try:
http://jvi.sourceforge.net/

My jaw just dropped. That's so frickin' awesome!

Shannon -jj Behrens said...

> Does NB have good subversion and git support?

I see Subversion, CVS, and Mercurial. I don't see Git either built in or in the plugins list.

Hmm, looks like they're working on it, and it has high priority: http://www.netbeans.org/issues/show_bug.cgi?id=131531

Shannon -jj Behrens said...

> Also curious what stability issues you are referring to.

I really like Komodo Edit, but it crashed on me three times within the couple of days I was playing with it. I wrote about that here: http://www.activestate.com/komodo_edit/. It freezed up so badly on my buddy Ben Bangert that he couldn't use it again until he logged out and back in again. I'm not sure how that could possibly be.

I'm using Komodo-Edit-5.0.3-2767-macosx-x86 on Mac OS 10.5.

Denis Fuenzalida said...

"There are no Vim or Emacs key bindings."

I managed to set Emacs-alike key bindings on Tools > Options, then select the "Keymap" tab, then select the "Emacs" option on Profile. Then you can also add key combinations for lots of tasks.

"Opening up files is a bit painful."

See Help > Keyboard Shortcuts Card. On the default (NetBeans) keyboard profile, Alt-Shift-O lets you type the part of a filename, and select any source file which matches. Pretty useful.

Kind regards,

Denis

Jeff said...

There are more recent builds here: http://deadlock.netbeans.org/hudson/job/python/. The __future__ imports is fixed, code coverage is working, and quite a few other issues have been eliminated.

Mark said...

80 column mark. There seem to be a couple approaches. A nice one is column-marker.el
(http://www.emacswiki.org/emacs/ColumnMarker)
which provides, e.g.,
C-u 80 M-x column-marker-2
for a cyan highlight at column 80.

Also, auto-indent modes are nice for catching missing colon bugs in python (at least, this is how I usually catch them).

Mark said...

Oops, the top of the previous comment should have been:

For those playing along in Emacs,

rectangle select:
C-x rk = kill rectangular region
C-x ry = yank rectangular region

Shannon -jj Behrens said...

I wrote about jVi: http://jjinux.blogspot.com/2009/01/vim-jvi.html

Shannon -jj Behrens said...

> There are more recent builds here: http://deadlock.netbeans.org/hudson/job/python/

That's very strange. When I originally downloaded NetBeans, it was only like 25mb. However, just the Python plugin is something like 50mb.

Shannon -jj Behrens said...

> See Help > Keyboard Shortcuts Card.

Great tip. Thanks!

Shannon -jj Behrens said...

Actually, a really great way to open files is to type in the name of the function or class you want to change in the quick search field on the top right and then tell it to open the file. I think that's like Spotlight on a Mac.

Shannon -jj Behrens said...

> Actually, a really great way to open files is to type in the name of the function or class you want to change in the quick search field on the top right and then tell it to open the file. I think that's like Spotlight on a Mac.

Hmm, that doesn't work for functions :(

Wyatt said...

I've used NB a bit for Java projects and found it to be more "inviting" than Eclipse. After reading this review of NB, I decided to give it a whirl for Python. I'm already using Wing IDE Pro, but it doesn't support languages other than Python well (or really at all beyond syntax highlighting).

An important (crucial really) feature for me is being able to select the Python executable for a project. This feature seems to be missing from Komodo Edit, but it's there in NB. The only problem is, changing the default to a virtualenv executable has caused NB to hang twice. I'm running the latest Ubuntu and Sun Java.

Given that this is an "early access" release of the Python plugin, I guess this is no big deal. Otherwise, NB is looking pretty good for Python/Web development.

OTOH, if I could set a per-project Python in Komodo, I'd probably go with that.

Shannon -jj Behrens said...

My feeling is that WingIDE is going to be better for pure Python development. Those guys really know what they're doing. For instance, it's possible to debug a server running on a remote machine with WingIDE. Once you can do that, all the other things you mentioned seem easy in comparison.

Personally, I'm so used to using pdb in a shell that if using NetBeans as a debugger doesn't work out, it's no skin off my back.

Thanks for the comment! It's nice to hear that I'm not the only one who finds NetBeans less overwhelming than Eclipse.

Abdul said...

SCP/SFTP Support
http://blogs.sun.com/netbeansphp/entry/sftp_support_added.

Very good review, buy!

Shannon -jj Behrens said...

Eggggsellent!

Wyatt said...

A quick follow up on NB. I'm liking it more and more. Keeping in mind that my baseline is Wing IDE Pro & Komodo Edit, the built-in SVN and database support in NB is very nice.

Also, I'm not sure why I had problems with using a per-project virtualenv Python at home, but it works just fine at work on the same OS.

One thing that bugs me about Wing is the way SVN commit messages can get lost if you click back on an open file. NB pops open a separate window and allows you to easily view diffs of each file, choose files to exclude, etc. Also, the message input is set to 80 cols by default, which is a small feature but a big deal (for me, at least).

Another thing that's handy is being able to connect to various DBs through the IDE. Before, I'd be running Oracle's SQL Developer; now I can stay in the IDE (and it does everything I need it to do so far).

There's a whole lot more. Maybe I should post something on the ol' blog...

Shannon -jj Behrens said...

Thanks for the update, Wyatt. If you do decide to blog about it, add a link here so that we'll know to read it :)

Shannon -jj Behrens said...

Here's a couple more things I like. When my cursor is over a variable, all the other instances of that variable are also highlighted. That's strangely helpful.

I can right click on a function from the standard library and say "go to declaration" to read more about what it does if I'm unsure of the details.

Shannon -jj Behrens said...

I created a retrospective after six months of using NetBeans:
http://jjinux.blogspot.com/2009/07/ide-netbeans-after-six-months.html

Maria said...

Thanks

Men's Suit said...

Dude thanks for this post, It help me a lot,thanks for fixing for us.