Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Google developed a cross-compiler from Java to JavaScript. Why did they do this? Does this mean that JavaScript is not good enought for developing advanced web apps?

share|improve this question

closed as not constructive by FrustratedWithFormsDesigner, Adam Crossland, Mark Booth, ChrisF Feb 15 '12 at 15:35

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

I honestly believe Google must answer it. Be specific with the question. – Ubermensch Feb 15 '12 at 14:41
because it is easier to find Java developers then ones for JavaScript. =P – mefisto Feb 15 '12 at 14:45
If JavaScript wasn't good enough, wouldn't they convert to something else? – JeffO Feb 15 '12 at 14:46
I counter your question with "Why not?". – Tyanna Feb 15 '12 at 14:50
Urp... I initally read the title as "Why did Google cross the road?" – Robert Harvey Feb 15 '12 at 18:08

They provide part of the answer on this page:

To start with the basics, why does GWT exist in the first place? The short answer is that GWT exists to make the web better for users. We've infused a slightly longer answer into our mission statement:

GWT's mission is to radically improve the web experience for users by enabling developers to use existing Java tools to build no-compromise AJAX for any modern browser.

In other words, it was a way of getting Java developers to write Ajax-heavy apps.

share|improve this answer
Another relevant quote from the same page: "We chose the Java language primarily because there already are so many great tools out there, not to mention scads of books, articles, libraries, and expertise" – funkybro Feb 15 '12 at 20:51

Because at the time, people didn't see any value in learning JavaScript, JavaScript lacked a large implementation base (though it's got the largest install base out there!), and in general Java programmers seem to prefer programming in Java more than anything else.

share|improve this answer
I still can't get grasp people enjoy writing JS. – Aaron McIver Feb 15 '12 at 14:59
I still can't grasp people enjoying writing Java. – Adam Crossland Feb 15 '12 at 15:01
Different strokes for different folks, I guess. – FrustratedWithFormsDesigner Feb 15 '12 at 15:08
I enjoy writing JS, not because of the language, it is horrible. But considering how much better it can make a web app the results are often very rewarding. – Tjaart Feb 15 '12 at 15:13
I enjoy JS... Many of its critics on the 'net never learned it properly, they would fall apart in strict-mode. Others have their genuine reasons, mostly regarding the prototypal model. Coming from years of Delphi, C# and C++, I honestly prefer the prototypal model over traditional class-based inheritance. JS+frameworks allows me to do big complex stuff really quickly and with simple/small programs. Half my time in Delphi was spent writing boilerplate, given the lack of either generics/templates. – Mark K Cowan Jun 21 '14 at 11:23

Java is a compiled language with a variety of mature tools and a large developer community. It has types, objects, exceptions, frameworks, great tools, community support, etc.

JavaScript has all of these things too - except for the compilation.

If you could compile your code, thoroughly test it in Java and then translate it to something the client can run (i.e. JavaScript - I'm guessing VBScript had no chance here) then it'll reduce the overall development costs. Developing large, complex AJAX applications like GMail is expensive.

There are many "write in one language, run in another" techniques around - but this was a good one.


To clarify my point further, JavaScript is an interpreted language where the parser will check syntax, but not pick up semantic errors such as:

function f(x) {

where neither 'g()' nor 'y' exist. This will only be picked up at runtime.

There are many JavaScript Engines such as V8, Nitro (JavaScriptCore) and Spider/Jaeger/TraceMonkey which will do a fantastic job of parsing and running the parsed code as fast as possible (perhaps by emitting machine code), but won't catch the semantic errors that a full compilation process would. This is often because scripts are delivered to the web browser independently of each other and the JavaScript Engine doesn't have the whole story until all of the required scripts have been downloaded/cached, the DOM has been initialised and any dynamically-generated scripts have been triggered. So the engine normally cannot have the whole source until quite late in the download and render process.

A full compiler will highlight the above code snippet as an error, which is one motivation to use a compiled language, verify correctness, perform unit tests and then use reflection or decompilation to generate the verified-correct JavaScript to run on the client.

share|improve this answer
"JavaScript has many of these things except for the compilation. – Huh? First off, this doesn't even make sense. JavaScript is a language. A language is an abstract set of mathematical rules. Languages aren't compiled or interpreted. They just are. Compilation and interpretation are traits of the implementation, i.e. the compiler or interpreter (duh!), not the language. Every language can be implemented by a compiler and an interpreter. Most languages have both compiled and interpreted implementations. Most modern high-performance implementations combine both. – Jörg W Mittag Feb 16 '12 at 3:17
And secondly: Can you name one, just one JavaScript implementation without a compiler? I don't know of any. At least not a widely used one. Certainly not one of the ones that are shipped with any of the popular browsers, those all have compilers. – Jörg W Mittag Feb 16 '12 at 3:18
Thanks for your comments - I've clarified my answer. – JBRWilkinson Feb 17 '12 at 23:24
JavaScript runtimes are better than statically compiled runtimes in many ways, every one worth using has a very optimized JIT compiler and runtime that has way more potential than any statically compiled system does. Your answer is still wrong, as that may be perfectly fine JavaScript. Also GMail isn't written with GWT. – Jarrod Roberson Feb 18 '12 at 6:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.