开发者

Can Scala be used to write GWT applications?

Can Scala be used to write GWT applications?

(NOTE: Java/Scala novice here.开发者_如何学JAVA..)


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.


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.


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.


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.


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.


Yes!

It haves Scala+GWT Project, scalagwt. Quick status (my opinion of course): one step before production usage.

Detailed status from scala-lang.org

The Scala to Javascript project is a research project and not yet what we could call a product. You can have fun, but it's not quite at the bet-your-job on it stage yet. There are bugs. We need quite a bit of work on documentation and smoothing the edges.

Github

The Scala+GWT project aims to compile Scala code for the browser via the GWT toolchain. You can fork scalagwt project on github here

Scala + GWT | GoogleDevelopers

See nice presentation and a lot of explanation on Youtube here


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜