Thursday, February 19, 2009

NetBeans

In a totally unwarranted diversion from the job at hand I decided to have a "quick" look at NetBeans.

Download and install were easy and quick.

A minor quibble was that it asked me to register and I would have, but it just took me to a web site to create an account. No thanks, I've got better things to spend my time on than creating yet another account.

NetBeans can import Eclipse projects so I had my project open in no time.

I ran all my tests and ... one failed! It complained that I was using the wrong assertEquals to compare floating point numbers. I didn't actually want to compare floating point numbers - I had used Math.signum instead of Integer.signum. Easily fixed. Strange that Eclipse didn't catch that. Maybe a newer version of JUnit.

This was a good opportunity to use NetBeans' out-of-the-box Subversion. Or not. It told me my Subversion client was too old and refused to do anything. So much for out-of-the-box.

As with Eclipse, there appear to be different ways to connect to Subversion. One of them is with JavaHL - part of Subclipse. Another is through the command line client.

I updated my plugins but that didn't help.

I tested the command line client and it was indeed old. (Apple seems to like to stick to old versions.) One recommendation was to install a newer version from Collabnet. Which meant I had to sign up for a Collabnet account.

Then I had to give NetBeans the path to it. Now my Subversion appears to work. But again, like with Subclipse, it was definitely not as easy as it should be. Presumably every Mac + NetBeans + Subversion user (that hasn't manually upgraded their SVN client) is going to have the same problem.

Another minor quibble is that I didn't like the font in NetBeans (Monospaced) as much as the one in Eclipse (Monaco) but that's easily adjusted in the Preferences. Probably just a matter of what I'm used to.

So I start programming in NetBeans. I add a class, oops, meant to add a Junit test. Try to delete the class (that I just created) and it won't let me. The error message is ultra helpful "cannot delete file". But I can delete it fine from the Finder, and then it disapppears from NetBeans. Very strange but I'm not going to worry about it. (until the next time!)

One feature that I'm missing already is that NetBeans doesn't seem to offer to create missing methods like Eclipse does. This is great for "programming by intention" where you just write your code, calling functions that you haven't written yet, and then go back and create them. (NetBeans will automatically create unimplemented methods from interfaces.)

I do like how Find is a bar at the bottom of the editor, like Firefox, and what I recently added to Suneido. But Replace is still a dialog :-( as it is currently in Suneido (but I am planning to change Suneido's Replace to a bar as well)

Wow! I just realized that the HOME and END keys are working "properly" (i.e. beginning and end of line like Windows) in NetBeans! To get these working in Eclipse I had to customize the keyboard mapping. On the Mac HOME and END normally scroll to the top and bottom, but for programming or even just writing, I more often want to go to the beginning or end of the line.

Despite the messing around I managed to get a fair bit of the parser ported. I'm glad I'm separating the parsing from the code generation so I can work on (and test) one thing at a time. It's also turned out to be quite easy to split the parser into several parts (constants, expressions, statements). This should let me re-use the expression parser in queries. (Suneido's query expression have always been a subset of the language expressions because I never got around to doing everything in two places.)

I looked for a metrics plugin for NetBeans so I could see how many lines of code I'd written today (roughly 300 plus tests) but the only one I found needed to be built from source and I couldn't be bothered right now. There do seem to be more plugins for Eclipse than for NetBeans.

5 comments:

Anonymous said...

I have no idea why you would get "cannot delete file" on a file you just created. The IDE's log (View menu) might give some details.

"NetBeans doesn't seem to offer to create missing methods" - it should be. If you see an error from a nonexistent method, a lightbulb should appear, and using Alt-ENTER or a mouse click you should be able to accept the hint to create a method with that name and an initial guess at a signature.

Mark Phippard said...

In the Wiki post I linked to yesterday, I explained what JavaHL is:

http://subclipse.tigris.org/wiki/JavaHL

It is NOT part of Subclipse, it is part of Subversion. Specifically, it is the "Java langugage bindings". Basically a Java API for using the Subversion native libraries.

Like Subclipse, NetBeans can easily include the Java library you need, but it cannot provide or install the native libraries. There are just too many variables involved.

NetBeans has a little more wiggle room than Subclipse in that they control the whole install process, so possibly could bundle native libraries for each OS and try to install them.

I manage the Subversion packaging at CollabNet, and I can say it is not that easy and I can see why NetBeans would not want to try to take that on.

In the case of Subclipse though, it is even more difficult as all we have is the Eclipse plugin install mechanism and it does not have facilities for installing OS packages.

Andrew McKinlay said...

I'll check the log.

I'll have to test again on creating methods. I tried a few things because I thought the feature would be there, but maybe I missed something.

Sorry, my mistake thinking JavaHL was part of Subclipse - the url said subclipse so I just assumed.

Sorry, I didn't follow the link you provided, but I didn't really want to have to know what JavaHL is. I just wanted to access Subversion. But I guess that's not the current state of affairs.

TortoiseSVN does seem to "just work", but they target a single OS and aren't trying to integrate with an IDE.

Mark Phippard said...

TortoiseSVN is written in C++ and can compile and embed the Subversion code as part of its application.

FWIW, on Windows, Subclipse "just works" too as indicated in the wiki page. But this is just because it is possible to deliver the SVN DLL's to a private location and use them from Java. You cannot do that on other operating systems due to the way native libraries are loaded on those OS.

cyberroadie said...

Creation of the missing method via alt-enter doesn't seem to work if you're in a different subtree of the project.
E.g. When creating a junit test of class Foo (located in 'Source packages', which will appear in the 'Test Packages' named FooTest.
Now if you try in FooTest to write foo.nonExistingMethod() the alt-enter function doesn't work, it jus states cannot find method, without the light bulb.

This is very inconvenient if you're into test driven development, where you write your tests first :-(