views:

351

answers:

3

For example, is it possible to have Scala, Java, and Clojure source all compile/build together properly inside the same project? Or, do I have to do them as separate project libraries then used by whatever I pick as the "master" project?

If neither of those, how's everyone else doing it?

+3  A: 

Unfortunately, while the Java community seems to be very enthusiastic about polyglot programming, the IDE vendors haven't really kept up. They generally do have plugins for Java, Scala, Clojure, Groovy, Ruby, ECMAScript, Python, C++ projects, but mixing multiple languages in one project is generally not supported.

In Ruby, for example, it is quite common to use Swing as a GUI via JRuby. But if you want to use Matisse, the NetBeans Swing GUI builder you must use a Java project, you cannot use Matisse in a Ruby project. However, if you use a Java project, then you can't have a Ruby main executable, you must have a Java main executable. Also, you don't get Rake support and other things that the Ruby project type supports. (The ugly workaround is to write a Java main executable which creates a JRubyEngine instance by hand, loads the Ruby main executable into it and runs it.)

The Eclipse Scala plugin supports a limited amount of polyglotism, but the hoops that they have to jump through are tremendous. Basically, they use runtime bytecode patching to inject Scala Aspects into the Java Development Tools Eclipse plugin, to get type-driven cross-language refactorings to work. The Groovy plugin does similar things, as does AspectJ (in fact, they originally came up with the idea of using aspect weaving to inject new functionality into JDT). So, all of these plugins allow polyglot programming with themselves and Java. But unfortunately not with each other. (Although several of the maintainers have expressed interest in more closely collaborating.)

In general, I fear that the only solution is new IDEs.

Jörg W Mittag
Anyone know where IntelliJ stands on this?
jomohke
Yes! Please see my answer to the question.
Carl Smotricz
A: 

The enclojure plugin for NetBeans supports a mixture of Clojure and Java in a single project in a very feeble way, though I'm sure the behavior is unintentional. You can create a project in Clojure and write unit tests in Java. The editor will put lots of spurious red flags in the Java file and you can't run the tests from the Run/Test Project menu. But you can right click in the Java file containing the tests, select Test File, and they are run and reported as expected.

At least it worked that way this morning on NetBeans 6.7.1, Java SE 1.6.0_16, and enclojure-plugin-2009-09-22-patch1.nbm. I have a small project that demonstrates this at http://kenai.com/projects/binomialstats

clartaq
+1  A: 

Rather late to answer this question, but the answer is that IntelliJ IDEA does a very fine job on polyglot programming. I recently watched a demo where one of their developers did a mixed-language application in 5 (!) languages.

They manage to do multi-language-aware syntax coloring, refactoring and more. They've obviously sunk some effort into this and are justifiably proud.

I was very happy to note that IDEA is now (partly) open-sourced.

Carl Smotricz