Live data from Hacker News

Closure Compiler in JavaScript

developers.googleblog.com

101–110 of 115 posts

Re: Closure Compiler in JavaScript

#101

So 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 ). It's a gulp wrapper around gjslint, I. E. a Google Closure linter. :)

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

Re: Closure Compiler in JavaScript

#102
post #93

Earlier quoted context omitted.

We are working on this here: 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).

Oh yes, I've been following this, at least the bits of information that emerge publicly. 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.

I wonder if that would that change your workflow in any way? Usually people use typescript compiler to compile TS into JS and usually it's being executed by some runner (grunt, gulp, bazel...). Adding tsickle + closure compiler to the process should be essentially just adding couple of lines in the build process. I agree that it may be slower and have bugs - is that the worry?

Re: Closure Compiler in JavaScript

#103
post #40

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

You're going to bust an internal organ when you check out Emscripten. :-)

Re: Closure Compiler in JavaScript

#104
post #98

Earlier quoted context omitted.

It's java source to javascript source compilation(/translation/transpilation), so you only need to follow the semantics of the language, not the actual implementation. 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 langu…

>...so you only need to follow the semantics of the language, not the actual implementation. Wouldn't you need to follow the syntax and not the semantics? Aren't the semantics what the syntax is abstracting? (I'm genuinely curious, not trying to flame.)

Not OP, but I'm pretty sure you care more about the semantics here.

The syntax is really just one way to express an intention. What you care about are the intensions--the meanings. That's exactly what the semantics are. For example, the semantics of this statement in Java

    int foo = 1 / 0;
are very different from the semantics of this statement in JavaScript:

    var foo = 1 / 0;
even though the two are syntactically rather similar.

(In the former, Java will throw an ArithmeticException, whereas in JavaScript it will return Infinity.)

So you want to ensure that your translation is meaning preserving, that is, that the source code and the generated code are semantically the same.

Re: Closure Compiler in JavaScript

#105

What's with all these similar and confusing names; Closure Compiler, Clojure, Clozure CL?

So "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 wi…

Thanks for explaining, but it remains confusing! And it seems so unnecessary.

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.

Re: Closure Compiler in JavaScript

#106

Earlier quoted context omitted.

So "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 wi…

Thanks for explaining, but it remains confusing! And it seems so unnecessary. 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 l…

Right? Keep that in mind when you name your next language or project :)

Re: Closure Compiler in JavaScript

#107

Can anyone comment on the state of Typescript - Google Closure integration ?

I just tested moving my Typescript/React template to Google Closure using a webpack plugin. It came in at 148KB with UglifyJS, and 102KB with Google Closure running after Typescript did the ES5 conversion.

This may not be the "integration" some are seeking but it's sure a step ahead.

Re: Closure Compiler in JavaScript

#108
post #106

Earlier quoted context omitted.

Thanks for explaining, but it remains confusing! And it seems so unnecessary. 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 l…

Right? Keep that in mind when you name your next language or project :)

I call dibs on "Cloxure."

Re: Closure Compiler in JavaScript

#109
post #2

Does anyone know what this means for clojurescript?

Nothing. Zero benefits here for typical usage of ClojureScript. Potentially interesting for 3rd party bootstrap efforts like Planck, Lumo, etc.

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

Re: Closure Compiler in JavaScript

#110

Earlier quoted context omitted.

So "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 wi…

I 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

I 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
Post reply on HN