Monday, December 11, 2006

Another NetBeans+Ruby Preview

WARNING: This blog entry was imported from my old blog on (which used different blogging software), so formatting and links may not be correct.

There have been several great releases lately, and I'm remiss in covering them. However, they've been covered in great detail elsewhere. First, NetBeans Visual Web Pack shipped on schedule, bringing Creator functionality to NetBeans, along with new support for Java EE 5. Second, Mustan... ^H^H^H^H Java SE 6 shipped today. It's a great release. The number one reason I install it whenever I get to a new system is that I need the improved font aliasing built into Java2D - and of course, the gray-rect-fix. However, there's another reason I crave the release even when I'm on OSX: @Override. Yes, @Override has been there since Java SE 5, but in Mus... Java SE 6, you can use it to indicate that a method should implement an interface method, not only a method inherited from a super class. (Which arguably @Override should have meant all along.) Now if only Apple could ship an update to its dated September pre-release...

Anyway, I have an excuse for being late to blog. In addition to some work on JSR 273 which is coming along nicely, I've been coding away to get more Ruby tools support for NetBeans.
Charles and Tom will be demoing JRuby 0.9.2 (which just shipped, congratulations!) at JavaPolis this week, and showing the NetBeans tooling in the process.

I thought I would share another screenshot with you at this point. This shows the new language embedding. Notice how there's Ruby inside string literals, rdoc tags inside comments, string escape codes highlighted specially, and so on.

This is all made possible by the new Lexer API in NetBeans. It's really nice to build on top of it; writing incremental
lexers is a snap. This is part of NetBeans 6. If you've been using recent milestones, you might have noticed that all our javadoc is highlighted in your Java files. This is not done through hacks in the Java lexer - it's done through embedded sections where the Java comment tokens are then sub-tokenized by a Javadoc lexer. It's not just done for javadoc - if you look at your String literals you'll notice the same String-sequence highlighting that I'm showing for Ruby above. It only changes the font to bold, so it's a bit subtle. Perhaps something we should tweak before the release.

In Charles' pre-review of the Ruby support,
he wrote some very nice things about me ("Tor Norbye is a programming machine", etc.) Thanks Charles! While it's nice to get all the credit, I really want to point out that this is all made possible
because of the tremendous work on the editing infrastructure for NetBeans 6, by a number of
great NetBeans engineers. Not just the Lexer, which I've described above, but all the other things I've relied on, such as the
infrastructure for semantic highlighting, asynchronous parser task scheduling, and so on. I would love
to give individual credit here, but I'm not sure exactly who to attribute all the work to, so I'd rather credit
all of you rather than snub anybody. Not to mention the fact that I have an excellent Ruby AST to work with, thanks to JRuby!

Several of you asked after my last screenshot where or when you can download the code for this. It will show up in NetBeans soon, but since the work started in closed source, I have to follow the established open-sourcing process. It's in progress, but I can't make specific predictions about when it will be done.


  1. Clearly some pretty interesting stuff going on there with NB6. Given that you are parsing tokens by divide-n-conquer, do you still uptain a full AST (allowing for future semantic checking at pre-compile time) or is it purely for syntax highlighting purposes?

  2. There is full semantic analysis using the JRuby AST. IF you look carefully at the screenshot you can see that regexp1, regexp2 and expr are all shown in gray; that is because these are unused local variables. Unfortunately I don't show you any used local variables (since this is a contrived example) so it's hard to notice that these colors are different (although there are local vars in the older screenshot). The semantic analysis is done in a separate phase from pure lexing obviously - this is the "asynchronous parser task scheduling" part I was referring to.

  3. Just 3 words: I can't wait !
    I hope Ruby refactoring tools will be as good as it is for Java. Is there a debugger for seen?