

Mug: A New JavaScript compiler for the JVM - timcameronryan
http://timcameronryan.com/post/2684769192/mug-javascript-compiler-for-the-jvm

======
marijn
Pro tip: Go straight for ECMAScript 5, don't waste your time on 3. With CL-
JavaScript (<http://marijnhaverbeke.nl/cl-javascript>) we also thought 3 would
be easier, but now we regret our decision:

\- The ECMA5 document is (slightly) easier to read.

\- Most 'extra' ECMA5 features can be added later, piecemeal, so initial
development doesn't have to be more complicated.

\- People will want ECMA5 eventually anyway.

\- It is a waste of time to work through two ugly standards when one would
have sufficed.

------
bokchoi
Isn't Oracle also working on a new JS implementation on the JVM? I saw a job
posting a while back.

Found it:

<http://robilad.livejournal.com/71787.html>

------
CoffeeDregs
Awesome. Question: I was under the impression (perhaps mistakenly) that it
would be impossible (or very hard) to statically compile a highly dynamic
language like Javascript. Yes, No? Are there shortcuts Mug takes or disallowed
coding styles?

How would Mug handle the following RuPyScript pseudocode:

for i in 1..10; eval "def function$i; print 'I'm $i'; end"; end

~~~
stingraycharles
I think, by definition, eval () will be impossible in a statically compiled
environment.

~~~
CoffeeDregs
Right, right, but then how useful would Mug be if the dynamic stuff in JS
can't be used?

~~~
JonnieCache
Munging strings and then eval()ing them is the _worst_ way to write dynamic
code. Hopefully its not common in most js libraries.

Missing eval() is a feature.

~~~
latortuga
As a follow up in case anyone is curious about the why behind this assertion,
consider a line of code like this

    
    
        eval("myObject."+functionName+"()")
    

Not only does it make it difficult to track down the calls to this method, it
is now impossible to minify this chunk of code, something that is very
commonly done in javascript. This is why javascript includes things like
apply() and accessing members of an object in multiple ways (obj.attribute ==
obj['attribute'], for user-defined values of attribute).

------
tlrobinson
Interesting benchmark idea: run JavaScript benchmark suites through Mug then
GWT, compare to original.

~~~
pjscott
I'm guessing that Mug produces bytecode very different from that which you
would normally want to run through GWT, and therefore might not be a very
representative benchmark.

------
al_james
This is very exciting. Will be interesting to benchmark and see what the
performance is like. It would be great if you dynamically compile JS to java
classes at runtime (store procedures in JS etc).

------
onteria
Why is all the content flushed to the right? It's making it hard to read the
content and actually get a sense for what Mug is all about.

~~~
pohl
Seriously? There's only 4 paragraphs total. How hard can it be? It's strange
that it would make it hard to read. Typographic manuals usually suggest
roughly 60 characters per line, favoring narrow columns over wide columns.

