tags:

views:

1801

answers:

6

Can Scala be used to write GWT applications?

(NOTE: Java/Scala novice here...)

+2  A: 

If you mean Google App Engine, the service for hosting web applications, the answer is yes.

If you really mean Google Web Toolkit, the tools for compiling Java into JavaScript to run in the browser, I pretty sure the answer is no. GWT does all kinds of code analysis when compiling to JavaScript and this relies on having Java source files as well as .class files.

Dave Webb
no I mean GWT, not GAE.
jldupont
In which case, the question is better phrased, "Does GWT run on Scala code?" And, of course, the anwer is "no, only Java."
Randall Schulz
+6  A: 

Short answer is GWT can call into a program written using Scala. The most popular web framework written in Scala is Lift - http://liftweb.net/ and would be an alternative to GWT if you wanted a pure Scala solution.

GWT is a web framework written using Java. The client side is written in the Java Language and compiles into JavaScript and the server side is written in Java and can use any resources available in the Java JVM. Scala is a language that compiles into bytecodes that are executable on the JVM and can interact with standard Java programs as well.

Ryan K
hmmm... compiles to bytecode so effectively preventing an easy GWT integration. I see (I am learning about Scala as we "speak"). Thanks
jldupont
+4  A: 

The GWT compiler works with Java source code because that provides the most visibility to allow for optimisations when compiling into Javascript. There has been occasional discussion about working with the bytecode, but the issue always ends up being that a lot of optimisations will be lost if the compiler works with byte code and not source code.

Nevertheless, there is an interesting thread about supporting Scala. However, the priorities for the GWT team at this point seem to be more focused on the Java language compiler.

Arthur Kalmenson
+4  A: 

As already said... BUT to be exactly not yet! This project should enable GWT to support client-side Scala code. Also the project is backed up by Google engineers.

Alexander Orlov
A: 

Interesting. In that case if I want generated javascript for nice Web 2.0 w/ Ajax I will move to python and pyjamas which was originally a python port of GWT. It also has some other interesting properties like generating code to run as platform independent desktop app. I am not fond of writing POJO much less POJO constrained for conversion to something else.

Samantha Atkins
this "answer" appears to be more like a comment and, as such, should be entered as a comment not an "answer"
jldupont
+1  A: 

I am aware of two projects that are addressing this issue.

Jribble(pronounced dribble) is a special form of java that does not have some of the human constraints of java so that it can be used for scala byte and still provide GWT with the information it needs to generate efficient javascript. They mention a github project called scalagwt-sample (http://github.com/rfc2616/scalagwt-sample) that seems quite active.

Another article I read had a guy using j2js(part of GWT) to cross compile scala to javascript. They won't let me put more than one Hyperlink but here is the url:

(http://www.j2js.com/scala-demo/scala-days-2010-paper.pdf)

I have not had time to try either yet but hope to soon.

ozone