views:

1657

answers:

5

I want to leverage the Scala's Actor Framework while I develop the user interface in the familiar Swing way.

Is it possible to have a mixed Java - Scala project in Eclipse, NetBeans or any other IDE?

+1  A: 

Have you tried Scala's Swing wrapper? It's very lightweight in the sense that you've always access to the underlying Swing classes but it's very well thought out. I've found it pleasant to work with - the reactions pattern makes event handling so much easier and the actor framework makes event propagation so much clearer than using PropertyChangeSupport

It's perfectly possible to use it with your own custom Swing widgets too.

oxbow_lakes
I tried the sample programs from the Scala book but I found it too different from my years long Swing GUI development experience.
kd304
I've been coding Swing for 10 years - give Scala a chance!
oxbow_lakes
I think it will be enough to learn the scala way of programming and the actor framework, and avoid confusions due the Scala GUI development practice differences as I'm working on several other, Swing GUI-ed projects at the same time.
kd304
+3  A: 

The "official" Scala plugin for Eclipse allows you to add the "scala nature" to any project, alongside the java nature. This allows you to mix and match however you'd wish.

I was playing with scala for the first time last night, using the Eclipse IDE, and it works very well.


Also, I just ran across this article: http://www.codecommit.com/blog/scala/joint-compilation-of-scala-and-java-sources

Seems that scalac knows enough about java to be able to resolve dependencies on java source, without actually compiling them. Very smart.

skaffman
Nice. Does this cooperation work for the javadoc / scaladoc in both direction?
kd304
That's a good question. I suspect not. If there are circular dependencies between java and scala, it might get awkward. That could be a real issue for continuous integration systems.
skaffman
See edit regarding scalac/javac dependencies
skaffman
Thank you. It truly works. Unfortunately, the plugin itself is not that advanced as its Intellij counterpart. Although I very much love the Eclipse way of java development, I would rather use Intellij for this particular mixed task. +1 for your answer.
kd304
+1  A: 

Intellij does a good job of supporting mixed Java / Scala projects. At the moment the Scala support in Intellij seems better to me than the Scala IDE for Eclipse. (I have been a long time Eclipse user, recently trying Intellij on the recommendation of some other Scala coders).

King Cub
Yes, the co-development works. In scala mode I can see the javadoc. Unfortunately in java mode asking javadoc on a scala item shows an error message.
kd304
Although skaffman gave an equivalently good answer I choose this one as the Intellij does seemingly a better job. Thank you.It wasn't an easy decision as I'm not familiar with Intellij. However, for the sake of my task I'll have to learn it too.
kd304
A: 

The Scala plugins for NetBeans are doing well too. With Swing development made so easy with NetBeans, it might just be what you are looking for :)

Amit
Yes, this was one of the meaning of "the familiar Swing way", as not to code manually, but use a GUI builder. But I wasn't sure before, if the actual hybrid project would be possible. Thanks. (I knew Scala for Eclipse but it was a bit disappointing - even the syntax highlight wasn't working correctly/instantly as in Java.) Thank you.
kd304
+1  A: 

I've successfully mixed Java and Scala in my app. It runs in the Goggle App Engine and I use Spring MVC for the UI. (will port to Lift later)

The plugins for Intellij are a great help. Though it is still early days and there are occasional problems. (for instance the Scala plugin compiler does not seem to like JDO enhanced Java classes too much...there is a work around and I am sure this bug will be fixed soon).

The only thing I find a bit tedious about the mix is dealing with Java APIs that return Java collection class in Scala. Its very clunky and you have to jump through hoops a bit.

Feargal