Last time I looked at Scala, I quickly stumbled over the nascent support for Scala in Eclipse and found that I didn't have the energy to work with a JVM language that didn't have good IDE support. It's been a while since then, so it seemed like a good time to look at Scala again and see how support for Scala in Eclipse has improved.
Thursday, September 4, 2008
Installing Scala in Eclipse
Installing Scala in Eclipse was pretty easy. There's a documentation page covering it, Eclipse 3.4 (Ganymede) is supported, so I added the update site, installed, restarted Eclipse, and voila, a Scala perspective, as shown on the Scala site:
Following along with either the Eclipse/Scala plugin page or with the default tutorial, I tried creating my first Scala "Hello World", and immediately started hitting minor hiccups again.
First of all, starting strings often highlights the open quote with an error indicator that doesn't go away when you close the string.
Secondly, there's no shortcut for running a Scala application. Alt-Shift-X brings up the usual menu with no addition for Scala. Likewise, you can't "Run As > Scala Application", another normal way to run an application in the Java development tools. Your only option is to go into the run configurations dialog, create a new run configuration under Scala Applications and enter the class to be used.
Further confusion sets in within the Run Configuration dialog, where there's a Browse button to search for a main class, but the HelloWorld object I've created doesn't show up in the dialog that results from pressing this button. As a result, if I type in the fully-qualified name of the object, the run configuration works, but it's fairly painful to reach that stage.
Interaction with Java
Continuing with the tutorial, I start the stage of interacting with Java classes. Although the typed-out examples show import statements, I'm used to these import statements being generated by the IDE in Java, so I decide to omit them. The Date type and getDateInstance methods are highlighted as being not found, although the warning information that appears when you hover over the error is both simpler and uglier than the Java equivalents, and incorrectly sized for the text, so scrollbars appear. There are no quick fixes available, so it seems likely that I'm going to have to enter the imports by hand. I do seem to get autocompletion on the imports, which makes entering these less painful than they might have been.
Having completed the import statements, the Scala editor is now aware of the Date instance, but seems to have failed to notice that getDateInstance() is overloaded; it's complaining that I'm offering up (int.Locale) to getDateInstance(). The code still runs when the run configuration is executed, but the editor is blissfully unaware of the successful compilation of the code, and continues to present the getDateInstance() method as being in error, even when I take it out and put it back in.
Second First Impressions
Well, this is my second time checking out Scala on Eclipse, and my first impressions this time around is that there's still a ways to go before Scala in Eclipse approaches the polish I'd like to see. It's certainly better than when I last looked, but I'd still be tempted to take a look at the support in IDEA and Netbeans before sticking with Scala in Eclipse.