This is Google's JavaScript to JavaScript compiler, originally written in Java, but compiled with their Java to JavaScript compiler so that it runs in JavaScript... fair enough...
Closure Compiler in JavaScript
51–60 of 115 posts
Re: Closure Compiler in JavaScript
#52performance is significantly worse for the simple example, anecdotally feels maybe 300%-400% slower. not sure if it's just bootup time or actual compilation passes, hopefully the former and does not explode exponentially (or even linearly) with code size.
Re: Closure Compiler in JavaScript
#53If you're using Google Closure with Gulp in your work flow, you may find gulp-gjslint useful (https://github.com/TomSeldon/gulp-gjslint).
It's a gulp wrapper around gjslint, I. E. a Google Closure linter. :)
Re: Closure Compiler in JavaScript
#54> How does this work? > > This isn't a rewrite of Closure in JavaScript. Instead, we compile > the Java source to JS to run under Node, or even inside a plain old > browser. Every post or resource you see about Closure Compiler will > also apply to this version. Pretty wild.
I'm really interested in how they did that. Do they have an internal Emscripten equivalent for Java bytecode? Or would it be more like a source code conversion compiler a la Nim or Haxe?
Re: Closure Compiler in JavaScript
#55Earlier quoted context omitted.
Far less glamorous and way more old school, it's the later case - GWT can compile Java to JavaScript.
Wait, how is that a thing? I'm a pure JS developer (for now) but I don't understand how something framed on desktop OSs could compile to JS, a browser language. Does it compile to Node maybe? Which version of JS? EDIT: I'm googling now to learn more but I'm not asking to challenge anybody, I'm asking because probably you guys know more than me and I wanna know how this works.
There's a series of steps to make this happen, but as long as the input can be represented in the output, this should always be possible. JavaScript is Turing Complete.
http://steve-yegge.blogspot.com/2007/06/rich-programmer-food...
Re: Closure Compiler in JavaScript
#56Re: Closure Compiler in JavaScript
#57Earlier quoted context omitted.
Wait, how is that a thing? I'm a pure JS developer (for now) but I don't understand how something framed on desktop OSs could compile to JS, a browser language. Does it compile to Node maybe? Which version of JS? EDIT: I'm googling now to learn more but I'm not asking to challenge anybody, I'm asking because probably you guys know more than me and I wanna know how this works.
There's no intrinsic property of “desktop” languages preventing them targeting “browser” languages. Any Turing-complete language can be compiled to and from any other. And you don't even need to go down to that level of abstraction for Java-to-JavaScript, the two share many commonalities. Java classes can become JavaScript objects, Java methods can become JavaScript functions, Java exceptions can become JavaScript ex…
Re: Closure Compiler in JavaScript
#58Earlier quoted context omitted.
There's no intrinsic property of “desktop” languages preventing them targeting “browser” languages. Any Turing-complete language can be compiled to and from any other. And you don't even need to go down to that level of abstraction for Java-to-JavaScript, the two share many commonalities. Java classes can become JavaScript objects, Java methods can become JavaScript functions, Java exceptions can become JavaScript ex…
So I don't know much about Java, but I was under the impression that it compiles to a binary fie (like C), and thus could do things that directly affect the hardware like malloc. How would Javascript handle something like that? I'm not aware of Javascript being able to perform these kinds of tasks. I guess they just have workarounds, like what you're saying for file access?
As a simple example, if you create an array of numbers in Java, you don't need to worry about how the memory for that is allocated as long as you get an array of numbers in javascript.
The difficulties are more in how you get around where the two languages differ widely and making sure you match the semantics (often subtle) of the source language without tanking performance in the target language.
For that example of a numeric array, Java has very different expectations when it comes to bounds checking and exactly what numeric type is in there, for instance, and that has to be enforced by the code you generate if you are going to have any sort of sanity while authoring in the source language.
Re: Closure Compiler in JavaScript
#59This is Google's JavaScript to JavaScript compiler, originally written in Java, but compiled with their Java to JavaScript compiler so that it runs in JavaScript... fair enough...
I'm not sure this is what Gosling had in mind when he said "compile once, run anywhere" :P
Re: Closure Compiler in JavaScript
#60Earlier quoted context omitted.
Far less glamorous and way more old school, it's the later case - GWT can compile Java to JavaScript.
Wait, how is that a thing? I'm a pure JS developer (for now) but I don't understand how something framed on desktop OSs could compile to JS, a browser language. Does it compile to Node maybe? Which version of JS? EDIT: I'm googling now to learn more but I'm not asking to challenge anybody, I'm asking because probably you guys know more than me and I wanna know how this works.