Live data from Hacker News

Closure Compiler in JavaScript

developers.googleblog.com

21–30 of 115 posts

Re: Closure Compiler in JavaScript

#24

    > 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.

Re: Closure Compiler in JavaScript

#27
post #19

Why would I use this over babel?

The 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-tuto...

In my experience Babel minified better than Closure Compiler with less maintenance of the externs on my part.

Re: Closure Compiler in JavaScript

#28

Earlier post: 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.)

I 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.

Re: Closure Compiler in JavaScript

#29
post #15

Earlier quoted context omitted.

It makes a completely self-hosted ClojureScript compiler possible.

clojurescript still requires clojure for macros, no?

No, 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.

Re: Closure Compiler in JavaScript

#30
post #19

Why would I use this over babel?

The 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-tuto...

Dead code removal relies heavily on writing JS in a style that allows for static analysis. Dynamic requires, heavy usage of closures, knowledge of external/global variables are all things that prevent a lot of commonjs code from being removed. https://developers.google.com/closure/compiler/docs/limitati... has more information if you're interested in the assumptions that the compiler makes.

Interestingly, we're finally starting to see these ideas get more mainstream as people adopt es6 modules and publish bundled code with explicit externs in tools like Webpack 2 and Rollup.

Post reply on HN