Good idea: Java and Groovy with Netbeans 6.5M1
In my previous blog I forgot to mention the most important benefit of Netbeans 6.5 - the ability to seamlessly mix Groovy and Java within the same project (zero developer effort required). Whilst this is a property of Groovy/JVM, Netbeans removes all the hassle of buildscripts, library management, classpaths, ever growing command lines, etc. The support for calling Groovy from Java is excellent - with full code completion (and includes things like automatic getter and setters you don’t need to write in Groovy).
The real win here is that you can write in Groovy and then optimise elements of your project in Java, without needing to do anything other than ‘New Java file’, and then code up the relevant Java class in your project. Whilst people still debate the speed of Java (vs C++) it’s undeniably faster than Groovy.
In the past using Python I’ve come across times where you simply need to move out of Python to improve performance. In Python that’s always been a major investment in developing C modules and its’ that a real it of pain:
- C/C++ isn’t as productive as Python - longer to write, more to worry about, more lines of code (I know, all these are debatable but giving specific examples will prove anything about any language);
- The need to input from and output to Python API objects makes for ugly C code (at least around the edges);
- Memory management issues between Python and C (this is well treated in the Python APIbut still something you need to keep in mind);
- Larger development, deployment and testing workload to ensure cross platform support (obviously C compiles to platform native code).
I pick Python here from familiarity, but this obviously applies to many (most?) other similar languages (and indeed to Java). Thankfully the JVM saves us from that with Groovy/Scala/JRuby/Java etc.
The equal status of Groovy and Java in Netbeans projects is real move from treating dynamic languages as embedded scripting languages (with painful APIs to integrate). Now, I can create an interface and then choose whether a particular implementation in my project would benefit from ’safe compile time static typing’ or ‘groovier concepts’ - sooner or later, I’ll probably also be able to say if it would be easier to program using a functional style in Scala. Also I can still take advantage of the Netbeans IDE support desgined to ease Java development, for example for UI creation in Matisse. In short, you really can mix and match to use the best language for the job at hand.
To try this you just need to download Netbeans 6.5M1 Java SE version, and then through the Tools > Plugins menu to install the Groovy support (under the Available Plugins tab). Depending on your environment you will also need to point Netbeans to your Groovy/Grails installation folders, which you do through Tools > Options > Groovy area. This will also enable the Grails project in Netbeans.
To start mixing Java and Groovy just create a Java application project, and then create a new Groovy Class or Source file. Done!
Just for good measure - Netbeans also support JRuby, PHP, Javascript, C/C++ and has plugins in development for Python, Scala, and more no doubt!
Posted in Blog