Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Scala+GWT Brings Scala to the Browser, New Documentation Site and Scala Days 2012 Announced

Scala+GWT Brings Scala to the Browser, New Documentation Site and Scala Days 2012 Announced

Leia em Português

Grzegorz Kossakowski has recently released the third milestone version of Scala+GWT. Scala+GWT allows you to write Scala code and then run it in the browser by compiling it to JavaScript via Google's Web Toolkit. This allows you to write statically checked code but with less boilerplate than Java requires.

InfoQ talked to Grzegorz to learn more about Scala+GWT. With the latest release, almost all language features are supported. The release notes mention that some pattern-matching features are not yet available, but will be in the next release. Are there any other limitations? 

Structural types are not supported and won't be without architectural changes in GWT.

InfoQ: Are there any features of Scala (the language or its libraries) that are particularly well-suited for GWT? Maybe Actors could be useful to communicate between the client and the server parts of the application. 

I've pondered a few ideas (including actors) but no work has been done so far on it. I'm deeply involved in compiler work and let other people explore their ideas. Also, integration with frameworks built on top of GWT would be interesting. One example is Vaadin. It's an interesting project and people behind it seem to be enthusiastic about Scala. This might be interesting for Scala because it would give it a better position as a language used to program good looking UIs.

InfoQ: Do you already have users that run Scala+GWT in a production website? 

I don't know about any such users. Actually, I used to deliberately lower people's expectations of Scala+GWT as I knew a bit more work is needed and we used to change internals a lot. That is also reflected in the version numbers I've been using: the latest release is marked as 0.1-M3. I expect the next release to be 0.1 and only then I'll be actively encouraging people to try it for real projects. This release should happen in a few weeks (before Christmas for sure).

In a much more detailed interview on, Grzegorz elaborates on the project's history and also explains how Scala+GWT is transformed to JavaScript. Using Java as the target for the Scala+GWT compiler was not an option because not all Scala programs can be mapped to valid Java code. So they introduced a new intermediate representation named Jribble, which is basically Java with these problematic restriction removed and some patches for GWT to make it understand Jribble input.

Performance is of course an issue with all these intermediate steps, but Scala+GWT also comes with an Eclipse plug-in that makes it possible to use GWT's development mode: 

In the development mode with Eclipse the [compilation] process is different. The compiler generates JVM byte code for the Scala code just as it normally would. GWT then runs this code in a JVM emmulator. When the code executing in the JVM needs to read or change browser state, this is done by sending an RPC to an attached browser which sends the result back to the JVM. When you change a line and recompile only the byte code classes that have been changed need to be reloaded in the JVM, rather than compiling everything right through to Javascript. This is very quick and takes a few seconds rather than minutes for the full server Javascript application build, even for a big application.

Scala+GWT is available on GitHub, and there's a walk-through on Youtube

New Documentation Site

As part of the ongoing effort to improve Scala's documentation, a new documentation website has been launched that serves as the entry point to the API documentation, several tutorials, a style guide, language references, and the official Scala Wiki. Users can also comment on all the pages. For contributions, the Markdown source of the site is hosted on GitHub, so it's easy for anybody to fork it and make additions or corrections. The site is built using Jekyll, a static site generator written in Ruby. 

Scala Days 2012

On April 17-18 2012, the third Scala Days conference will be held at the Barbican Conference Centre in London: 

Scala Days provides a unique opportunity for researchers and commercial Scala users to transfer leading edge research into production systems or share practical know-how on how to get things done more effectively.

More information will follow in the next months, in the meantime, you could watch some of 2011's or 2010's recordings.

Rate this Article