Polyglott Programming On The AVM2

Take some time and think about this tweet for a moment. It took me a while to realize that Joel Hooks is right. I was embaressed of myself. How could I forget about that? But I had also a big smile on my face at the same same time. Let me explain why.

The Java to SWF compiler does not compile Java sourcecode but JVM bytecode to ActionScript bytecode. This means I do not have to teach my program the Java language. It only understands JVM bytecode. This seems like an akward decision on the one hand since working on the bytecode level implies lots of problems. But it turns out that this was a really cool decision on the other hand. “Java to SWF compiler” is maybe the wrong description. “any language that compiles to JVM bytecode to SWF compiler” is maybe better.

So what does any language mean? Here is a list of JVM languages. Now you feel maybe like I did after reading that tweet. And I am really looking forward to get Scala up and running.

Some problems still exist. Threading is one issue and I will basically have to do what Scott Peterson did for Alchemy. But reflections, annotations and method overloading have to be solved as well. Some glitches may exist even after figuring everything out. Stacktraces will look pretty weird. However I think this is a really cool project.

Update: I forgot to mention something important. Java supports native code. This means you can build a library that works with OpenGL for instance. Those native methods can not be converted. There are also some other things that do not work. File access is just one of them.


  1. Posted Nov 16, 2009 at 1:29 pm | Permalink

    That’s exciting!

    What about a revise, compiles AVM bytecode to JVM bytecode? Although I don’t know if it will be useful :P

  2. Posted Nov 16, 2009 at 1:56 pm | Permalink

    Awesome stuff Joa! Can’t wait to be writing Scala on both sides of the wire. :)

  3. Posted Nov 16, 2009 at 2:25 pm | Permalink

    Andy Li: Possible but problematic since AcitonScript is not statically typed and has some features that Java does not support like runtime namespaces. I also do not think it would be that useful.

  4. Posted Nov 16, 2009 at 4:25 pm | Permalink

    The killer flaw to such ideas is debugging. Can figure out how to get the debug info it the SWF, so that it maps back to the Scala etc code? Then can you devise a debugger that understands the original language and supports breakpoints, variable value inspection etc? Without these, such language converts are little use, unless you never need to debug your code of course…

  5. Posted Nov 17, 2009 at 12:42 pm | Permalink

    You have a very valid point David. There are two options in order to solve the issue you are talking about:
    – Debug in the language of your choice before converting (if possible)
    – IDE features which can be implemented but require (a lot of) work.

    Converting the debug information is possible. But one has to make use of it of course.

  6. Posted Dec 3, 2009 at 8:37 am | Permalink

    what about garbage collection and compilation time? on Rhino [http://en.wikipedia.org/wiki/Rhino_%28JavaScript_engine] they stopped using JVM because of both reasons. cheers.

2 Trackbacks

  1. […] This post was mentioned on Twitter by joa ebert, Bastien Levasseur. Bastien Levasseur said: RT @joa: Polyglott Programming On The AVM2: http://bit.ly/3Zcu72 […]

  2. By uberVU - social comments on Nov 17, 2009 at 5:08 am

    Social comments and analytics for this post…

    This post was mentioned on Twitter by joa: Polyglott Programming On The AVM2: http://bit.ly/3Zcu72