13 ms·
Closure Compiler in JavaScript
- xntrk 10y agoDoes anyone know what this means for clojurescript?
- yegortimoshenko 10y agoIt makes a completely self-hosted ClojureScript compiler possible.
- reitzensteinm 10y agoIt already is, except for the final Closure Compiler pass.
- pitaj 10y agoAnd that is precisely why this makes a completely self-hosted compiler pass possible.
- xntrk 10y agois java a requirement though? or was it only a requirement because of google closure?
- matthewbauer 10y agoJava is no longer required.
- Skinney 10y agoclojurescript still requires clojure for macros, no?
- swannodette 10y agoNo, ClojureScript has been bootstrappable since late summer 2015. Everything already runs in JavaScript. It's just that now the final optional optimization pass can also run in JavaScript.
- deleted 10y ago[deleted]
- espeed 10y agoI created a ticket and posted this to the ClojureScript discussion group a few mins ago: https://groups.google.com/d/msg/clojurescript/jMSQChpCdhg/p72sKYiRBwAJ https://groups.google.com/d/msg/clojurescript/jMSQChpCdhg/p7...
- swannodette 10y agoNothing. Zero benefits here for typical usage of ClojureScript. Potentially interesting for 3rd party bootstrap efforts like Planck, Lumo, etc.
- espeed 10y agoTrue, but it helps fix the TTFX metric -- "Time to First XML" ;-) -- Derek Slager made a case for this in his talk at the Conj: "ClojureScript for Skeptics" https://youtu.be/gsffg5xxFQI?t=20m9s https://youtu.be/gsffg5xxFQI?t=20m9s The remaining bit of Java is like "a little piece of kelp that's stuck to the hull, and even though it's little, you don't want anything stuck to the hull" (http://www.tv-quotes.com/shows/the-west-wing/quote_14096.html http://www.tv-quotes.com/shows/the-west-wing/quote_14096.htm...). TTFX 1: http://clojurescript.org/guides/quick-start http://clojurescript.org/guides/quick-start
- brucehauman 10y agoTo be fair, the XML is listed at the very bottom as the last of the options for getting your dependencies.
- valw 10y agoZero technical benefits for sure, but it may help with ClojureScript's marketing. I've seen many JS developers outright dismiss ClojureScript / Closure because they don't want anything that involves Java - which is completely irrational, but a reality still.
- dr_win 10y agoOld news, article dated Wednesday, August 31, 2016
- dang 10y agoInteresting stories that haven't had significant attention yet are welcome here.
- SquareWheel 10y agoI'd appreciate if titles at least mentioned when this is the case. I thought this was an update to the Closure Compiler they released months ago.
- grzm 10y agoOften that is the case. If you see one (such as this), and suggest adding a date (such as 2016-08) in a comment, it's often updated. Even having such a comment, while not visible from the front page, can be useful in and of itself.
- dr_win 10y agoOld news, article dated Wednesday, August 31, 2016
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- SpencerWood 10y agoWhy would I use this over babel?
- icholy 10y agoThey do different things.
- aeosynth 10y agoyou like lisp
- vikeri 10y agoThe advanced compilation mode does some pretty powerful dead code removal and minification [1]. I guess that is available from plugins in Babel as well but Google has been using it for Gmail, Google.com etc, so it's quite battle tested. [1]: https://developers.google.com/closure/compiler/docs/api-tutorial3 https://developers.google.com/closure/compiler/docs/api-tuto...
- base698 10y agoIn my experience Babel minified better than Closure Compiler with less maintenance of the externs on my part.
- cromwellian 10y agoOnly possible in simplified mode. I highly doubt Babel comes close with full optimizations turned on in a nontrivial codebase.
- AgentME 10y agoWith what plugins? Babel without any plugins or with the common ES2015 plugins doesn't do any minification.
- randomguy7788 10y agosee http://www.syntaxsuccess.com/viewarticle/tree-shaking-in-javascript http://www.syntaxsuccess.com/viewarticle/tree-shaking-in-jav...
- wehadfun 10y agoofftopic: googleblog.com vs blog.google?
- triangleman 10y agocould be a security measure.
- desdiv 10y agoThey're both currently in use by Google.
- manishsharan 10y agoCan anyone comment on the state of Typescript - Google Closure integration ?
- msoad 10y agoTsickle isn't that great, Webpack plugings are not not letting CC do the bundling. In general it's not good!
- evmar 10y agoI commented elsewhere in this thread, but: tsickle is mostly the work of one person (me) who also has other responsibilities. I'd love some help on it, particularly in integrating it into the world of webpack etc. https://github.com/angular/tsickle/graphs/contributors https://github.com/angular/tsickle/graphs/contributors
- nojvek 10y agoWhat do you mean by Typescript Google closure integration? Typescript understands most of closure comment syntax. They should throw typechecking errors which they currently aren't doing.
- evmar 10y agoTypeScript understands some of the comment syntax, but the type systems are different, the module systems are different, and a ton of other stuff is different. Look through the test cases in https://github.com/angular/tsickle/tree/master/test_files https://github.com/angular/tsickle/tree/master/test_files to see the difference between TypeScript-annotated code and Closure-annotated code.
- nojvek 10y agoThat's a pretty awesome project. Didn't realize something like that existed. In this case, I think closure should start to understand typescript syntax. Or typescript needs to borrow ideas from closure on minifying and dead code removal.
- jashkenas 10y ago> 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.
- Cyph0n 10y agoI'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?
- swannodette 10y agoFar less glamorous and way more old school, it's the later case - GWT can compile Java to JavaScript.
- komali2 10y agoWait, 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.
- JCoder58 10y ago^F JVM on this page: https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js https://github.com/jashkenas/coffeescript/wiki/list-of-langu...
- magicalist 10y ago> but I don't understand how something framed on desktop OSs could compile to JS, a browser language GWT compiles Java to JS. If the Closure Compiler is mostly Java code, you only need to implement a few native code things (like replace file loading with just giving it source code as strings) in JS to do a cross compile to javascript.
- paulddraper 10y agoEarlier post: https://news.ycombinator.com/item?id=12415512 https://news.ycombinator.com/item?id=12415512 (PS Is it possible to have a biased account? I see a lot of articles I had posted, later posted by someone else make it to the front page.)
- grzm 10y agoI think it's mostly just a timing issue. To make it to the front page a submission needs to garner enough upvotes at a specific rate, and it's competing with other submissions at the same time.
- leeoniya 10y agoperformance 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.
- paulddraper 10y agoI'm sure it's just the Java-on-Node overhead. 3-4x isn't awful considering.
- andrethegiant 10y agoI'd love to see benchmarks comparing Closure Compiler JS, UglifyJS, and Babili.
- swannodette 10y agoSome benchmarks here https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/ https://nolanlawson.com/2016/08/15/the-cost-of-small-modules...
- sunkencity 10y agoWow! The center of the maze. Now it's just a matter of time before clojurescript is self hosted and the Eschaton is Immanentized.
- johnhenry 10y agoThis 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...
- dafrankenstein2 10y agoYeah I was trying to figure that out..haha
- minxomat 10y agoWe need to go deeper...
- strictfp 10y ago... which is JIT-compiled with their JavaScript-to-machine-code compiler.
- paulddraper 10y agoI'm not sure this is what Gosling had in mind when he said "compile once, run anywhere" :P
- kevincox 10y agoTo nitpick they are compiling separately for the js version ;)
- paulddraper 10y agoThough if you consider JS the universal runtime (Node, Nashorn, browser), then it is just once.
- moolcool 10y agoIt's 2016, the mantra now is "Compile thee times, run slowly in a handful of web browsers"
- 10y ago
- tomseldon 10y agoSo this is a shameless, inexcusable plug but as it's relevant to the blog post... If you're using Google Closure with Gulp in your work flow, you may find gulp-gjslint useful (https://github.com/TomSeldon/gulp-gjslint https://github.com/TomSeldon/gulp-gjslint). It's a gulp wrapper around gjslint, I. E. a Google Closure linter. :)
- nhatbui 10y agoThanks! I'm fairly new to JS. I introduced a new dependency on a node module and for some reason gulp-uglify isn't working on production mode. I'm going to give this a try.
- sigjuice 10y agoWhat's with all these similar and confusing names; Closure Compiler, Clojure, Clozure CL?
- focusaurus 10y agoSo "Closure" is a real comp sci word used to describe variable scope lifetimes in languages includes JavaScript and others. So when google named their project, they basically took a word from JavaScript/CompSci that starts with the same letter as "Compiler" (plus other similar sounds). I don't think there's much more to it than that. "Clojure" is a programming language again based on the regular word "closure" but with some twists: The "j" is a tip of the hat to Java and the JVM where clojure is designed to run. This also has the nice property that the "zh" sound of the "s" in closure is also used with "j" sometimes (I think due to French). Thirdly I believe the "CL" letters of clojure are a tip to Common Lisp. I'm not familiar with "Clozure CL" but the history is here: http://ccl.clozure.com/history.html http://ccl.clozure.com/history.html
- ptx 10y ago> So when google named their project, they basically took a word from JavaScript/CompSci that starts with the same letter as "Compiler" (plus other similar sounds). I don't think there's much more to it than that. Isn't it because it can optimize the output so that it only includes those dependencies that the program references, i.e. the whole program is like a closure that closes over its dependencies?
- iLemming 10y agoI heard that Rich Hickey chose Clojure because it has both `CLR` and `J` - initially he thought Clojure will be adopted in both - .Net CLR and JVM
- kencausey 10y agoI may be reading more into 'initially he thought' than you meant but Clojure CLR is real and has been around for years: https://github.com/clojure/clojure-clr https://github.com/clojure/clojure-clr
- mrcactu5 10y agoconfusingly, ClojureScript compiles to JavaScript which is compatible with Google Closure -- thereby coming full circle. http://clojurescript.org/ http://clojurescript.org/
- deleted 10y ago[deleted]
- victorvation 10y agoInteresting to see what the use case for this will be - will removing the JVM dependency really outweigh the increase in compilation time?
- tadeegan 10y agoFor portability and use within the node/npm ecosystem? Yes I think so.
- austincheney 10y agoBah. It still requires a build step. I will stick with Pretty Diff and its "correct" option.
- nothrabannosir 10y agoThis is fantastic. I never thought I'd be celebrating yet another "now-in-JS" release, but clojure being Java was a constant pain in the CI gonads. Wonderful to finally be able to include this in generic npm packages without any crazy extraneous build steps.
- jjdveifb 10y agoAlso probably 10x slower, at least! Still cool because JavaScript I guess
- nfriedly 10y agoClosure compiler is awesome, and the need to spin up a JVM to run it is really my only knock against it. This should lead to a nice boost in its usage.
- intransigent 10y agoClojure or Closure? What language are they talking about?
- grzm 10y agoAs mentioned in the article, this is the Google Closure Compiler, which is used for compiling JavaScript. There is also the Closure Compiler (for compiling JavaScript) written in Java. As the title indicates, this is about a new implementation written in JavaScript.
- antouank 10y ago> As this compiler runs in pure JavaScript, the compiler cannot load or save files from your filesystem directly. Why? Node.js has the fs library for that. Why do I have to use gulp?