Sound Conclusions in Scala

By: on August 1, 2005

Scala is a programming language which tries to mix pure object orientation (data only) and functional programming styles. It currently compiles to Java bytecode but there are plans to enable compilation to the .Net CLR bytecode too. It supports generics/templates within Scala but does not support Java’s generics so you’re back to the pre-1.5 Java mode.

The addition of some nice functional methods, first-class support for functions and pattern-matching makes for some nice-ish looking code. Type inference is very useful and massively reduces the unnecessary information duplication that Java is famous for. The editing environments are a little testing though, the Eclipse plugin can be made to work with some coercion and reading of the mailing list. It would seem that as usual, the academics involved are not interested in the tool chain or editor support so that falls to the PhD students who get so far before having to stop work in order to write up their dissertation. An all too familiar issue.

I’ve been making it work with the Spring Framework. This offers quite a nice implementation of MVC which lends itself nicely to being extended — it doesn’t feel as restrictive as frameworks are known to be. The problem has been that Scala’s map classes do not extend Java’s map classes. As a result, after you’ve built your map and handed it all the way down to your JSPs, the JSTLs can’t manipulate the maps or other basic collections. I have since written a (broken) implementation of Java’s Map interface which wraps the Scala Map classes/traits and this does indeed work, but you would have to do this for every single collection that the JSTLs can understand. The other solution is to rewrite the JSTLs so that they can understand Scala’s collections.

The conclusion (after soundness checks) is that for Scala to work nicely and without pain as a component in a container, the container really needs to be written in Scala too. However, if you’re simply making use of a Java library for some particular function then that way will be less painful.

Share

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*