BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

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

by Mirko Stocker on Nov 28, 2011 |

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 scala-lang.org, 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.

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

A resurgence in meta-programming by Faisal Waris

Google has certainly shown the way with GWT but languages that intrinsically support meta-programming (e.g. LISP, Clojure, F#, etc.) make meta-programming much easier. Without meta-programming support in the language (e.g. Java, Scala) one has to work with source code which is messy and cumbersome.

For example, the F# code snippet "<@ 1 + 1 @>" will not give you 2 but rather the Abstract Syntax Tree (AST) of the code text. The code within "<@ … @>" is type checked but not compiled as normal code; it is instead handed over as an AST. Sophisticated language facilities make it easy to traverse the AST and transform it as needed.

WebSharper has exploited F# meta-programming well so that now they have integration with many javascript frameworks such as jQuery mobile and Sencha Touch (the exhaustive list is here: www.websharper.com/extensions).

Microsoft’s Rosalyn project (compiler-as-service) is bringing meta-programming to C# and VB (presumably to more easily do what GWT does).

Alan Kay makes a good case for meta-programming in his talk Programming and Scaling.


</@></@>

Re: A resurgence in meta-programming by Serge Bureau

I might be wrong, but it seems easy to implement as a DSL in Scala.

Of course if it is already provided natively, then less work ;-)

Good news by Serge Bureau

Thank you for that !!! I am loking forward to the upcoming soon of version 0.1

Re: A resurgence in meta-programming by Steve McJones

Isn't that what Scala is pretty much doing right now in the latest source?

Re: A resurgence in meta-programming by Faisal Waris

as far as I am aware the scala language does not have any meta-programming capilities in the language itself. I believe that they are taking source code and converting it through external tooling.

In F# you can do meta-programming as part of the language and can therefore easily mix 'programming' and meta-programming. LISP/Clojure is even more capable in this regard.

Re: A resurgence in meta-programming by Mirko Stocker

Hi,

No, Scala does not have the same kind of meta-programming capabilities, but there's a research project that adds some macro facilities. But what Scala has right now are plug-ins for the compiler, which lets you add things like String interpolation, or new back-ends like the one for GWT or .NET.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

6 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT