Let me try and sum up where things are.

Regarding manpower, I spent a month or two spending 20% time on this,
following all of the threads discussed in this email.  From where
things are, I would estimate a 3-week full time effort to get a basic
version working that, for example, translated function literals the
same way that inner classes are translated.  Getting structural method
calls to work would take a little while longer, but they aren't used
that much in most Scala code.  Getting Scala function literals
translated to JavaScript function literals would require updating
GWT's IR analogous to what Max describes, and nobody has really
thought through a specific plan for that.

If anyone wants to work on this, I can give all the relevant Scala and
GWT pointers.  Just let me know.  It would involve writing some Scala
code, but would not require any deep knowledge of compilers.

Let me now update all the subthreads I see on here with what I found.
Please ping if I have overlooked something.

Decompilation does not work on Scala.  I tried all the ones I could
get my hands on, and they all fail.  It's been about a year, so if
anyone knows of a decompiler breakthrough in that time, it might be
possible now.  However, it would take large changes.  The decompiled
output I looked at was fine for 90% of the code, but the remaining 10%
included some really big problems that needed solving.

Generating Java source code from scalac might be possible, but it's
terribly difficult.  Java source code does not want to be a target
language.  Java rejects all kinds of code that are logical but that
wouldn't make sense to write by hand.  When I started on this path, I
enumerated all the problems I knew of and found a solution to all of
them.  However, along the way, more of them popped up.  None of them
were ever fatal by themselves, but there are a bunch of them.

A better tactic would be to define a modified Java source language
that does not have the restrictions.  It would be pretty much the same
as Java, but with a few changes.  A partial list of changes would be:

1. There is no rule in constructors about calling the super()
constructor as the syntactically first thing in a constructor.
2. There is a comma operator expression just like in JavaScript.
3. Any expression can be used in an expression statement, even useless
things like literals.
4. The types would all be Java erased types.
5. Probably imports would be removed.
6. Overloading and overriding would be as in Java byte code, including
override on return type.
7. That probably implies that method calls are also as in Java byte
code, and specify the full method signature.

This plan has the huge advantage that everything in the chain is under
our control.  The Scala compiler could generate this language, and GWT
could read it.

Also, per John's comments about decompiling Java, note that we could
plan to update this language to support more source languages than
just Java.  It should be much easier for them to emit what they mean
than for GWT to reverse engineer what their bytecode intended.


Lex Spoon

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to