Skip to content

Scala as a second language? Not for long

July 4, 2010

I really feel like we’re within 6 months of my ability to abandon Java for Scala permanently.  Let’s rehearse why Scala’s currently my favorite language: cross-platform, type-safe, reasonably fluent, and interoperable with anything on the JVM.  But, there’s another reason: pace.

The people behind Scala are smart, and they listen and learn.  While they’re not afraid to change things, they don’t just leap on every nutty idea either.  I just started using some of the features in 2.8.0, and discovered much to my surprise that they’d captured most of the missing essential fluency benefits that I’d come to love working in C# for a while.  Bless named parameters.

I don’t have any serious beef with Java other than that it’s totally showing its age.  Seriously, can we really debate the wisdom of adding closures to the language for a friggin’ decade?   (Odersky’s wings-to-an-elephant comment is what won me to Scala in the first place) Dear Java: when Microsoft seriously outpaces your rate of change and growth, it might just be time to hang up your spurs.

Now, as to why I don’t actually write very much Scala for-real at-work yet:

The IDE support has been pretty wack.

While it’s all cool at hackathons to show off my vi-fu and build with sbt, for-real at-work I need a solid IDE.  I’m working on multi-participant projects most of the time, and I need things like code completion, jump-to-declaration, and so on.  Yes, I can be really clever and do it with TextMate.  No, I don’t want to.  I want Eclipse or NetBeans (preferably Eclipse) to just work.

Solved: The Scala IDE project’s output is getting quite good.  Eclipse 3.5.2 has a serviceable 2.8 Scala plugin that doesn’t crash too much.  It does mixed Scala/Java pretty well now.  If only it worked on Helios, I’d be ecstatic.

Making OSGi plugins with Scala has been hard.

For about 2 years, I’ve been able to demonstrate that it’s possible to create an OSGi plugin with Scala, if you stand on your head, squint, and repeat some magic incantations.  (e.g. build it all with ant and some custom classes, fudge around with the .project file in Eclipse, etc.)

I’m not the only one who cares about OSGi and Scala — have a look at ScalaModules for a really ambitious project.  Still, not quite …

Almost solved: It’s now a simple matter to add the PDE nature to a Scala project in Eclipse, and nothing blows up.  But the builder still doesn’t work right — you get source .scala files instead of classes in your exports.  You can include /bin in the definition as a quick workaround, and the bundle works, but it’s sloppy and still contains source.

I’m hoping it’s … well, not trivial, but achievable … to mutate the Scala builder to do the right thing for a PDE build.  I’m also hoping the Scala IDE guys won’t mind a patchset that lays out an sbt/Maven-style project AND still does the right thing under the Eclipse Scala builder.  I’d like something that Hudson could build with sbt and a human developer could build with Eclipse export.

You can’t use Scala in GWT.

Well, you still can’t, but we’re solving that.

You can’t use Scala code on Android.

There are two problems here — getting the code compiled, and linking to the Scala libraries.  Somebody on the Scala-IDE wiki has got a pretty ingenious solution here.  The documentation kind of vanishes near the end, so I’m not sure if it actually works, but it looks like it might.  I’m wondering if we won’t have to do something analogous with Scala+GWT, as there’s a fair bit of the Scala standard library that would end up getting slurped into any non-trivial Scala+GWT application.

Once we wrap these last two issues, I feel like I can banish Java from my life altogether and just write Scala code.  I’ll be happier.


From → Technology

One Comment
  1. Michel Kraemer came up with a way to invoke the PDE builder correctly on a Scala project:

    Now we just need to get that bolted into the Scala IDE.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: