228 points · by espeed · 10y ago · 104 comments
> 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.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.
Some of us using TypeScript dream of a day when TypeScript emits JavaScript already annotated with type meditations which express as much of the typescript type system as possible in a way that Closure can understand, thereby making it possible for Closure to perform maximally efficient tree shaking and other magic with code that started as TypeScript. Such a thing as necessary and helpful because the addition of this detailed type data makes it possible for Closure to do a much better job that it can do with "just" untyped JavaScript.
https://github.com/angular/tsickle
It's already used within Google to effectively optimize TypeScript apps. However, someone still needs to write the integrations between tsickle and the multitude of public JS build systems and there's not a lot of pressure on me to do it (I have lots of other work to do).
But my dream is that this work could make it back into typescript itself - that a future version could possibly be persuaded to emit Closure type limitations without the help of a parallel/postprocessing pass by a tool.
https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-i...
This may not be the "integration" some are seeking but it's sure a step ahead.
Typescript understands most of closure comment syntax. They should throw typechecking errors which they currently aren't doing.
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.
"ClojureScript for Skeptics" 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.htm...).
https://groups.google.com/d/msg/clojurescript/jMSQChpCdhg/p7...
If 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. :)
"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
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?
In general, I think you should not pick names from the domain where your product/tool operates in. For example, it would be equally confusing if a car manufacturer would brand its cars "Engine" or "Wheel". Such naming is worse than just choosing a fantasy name.
P.S.: As another example, "Java" was a good name. But then Netscape invented a language and called it "JavaScript", which was of course a very poor choice.
(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.)
> 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?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.
[1]: https://developers.google.com/closure/compiler/docs/api-tuto...
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.
Babel can be used in the same toolchain as Closure Compiler, they're not mutually exclusive or redundant as they perform different tasks.
use it with babel by using splittable.js
What language are they talking about?