

Closure Mode for CoffeeScript - bolinfest
http://bolinfest.com/coffee/

======
fortes
As a heavy user of Closure Compiler and a fan of CoffeeScript, I love love
love the potential here.

@jashkenas -- any thoughts/concerns with this? How likely is it to hit main
branch?

~~~
jashkenas
Not likely to hit the main branch, as it requires everyone who uses the
language to also to use the Google Closure library, as well as the Closure
compiler. But as a fork, I think it's brilliant.

~~~
fortes
It's an optional mode via command line, no? Opt-in won't require anyone to use
closure.

~~~
jashkenas
Fair enough ... it's definitely worth considering seriously. I'd probably wait
until it's "finished" according to Michael, and then look at if it's possible
to add enough hooks to the compiler for it to be implemented as a plugin.
Ideally you'd be able to emit different annotations depending on your use
case, for example: lots of other folks have requested automatic JSDoc
annotations.

~~~
withjive
What's the chance of also getting optional Type Annotations into CoffeScript
core as well?

As this would greatly help the closure compiler do optimisations, and since it
is opt-in to add the typed parameter and would only produce a javascript
comment above said variable.

For example....

foo <: String = "hey"

/* @type {String} */ var foo = "hey"

I don't think this is deviating from CoffeeScript's aim to keep things pure?
Is it?

~~~
jashkenas
It is deviating pretty far from compiling to readable, standard JS, but again
... as a fork or a plugin, I'm all for it. The reason why the entire
CoffeeScript source is annotated is to make variants like this easier to
accomplish.

That said, statically marking your variables with "types" (where types are
incredibly weak and limited in JavaScript) isn't going to be of much use to
you, performance-wise. Modern engines like V8 already unbox local variables
where possible, and do "hidden class" analysis to give a "type" even to
regular unstructured JS objects.

~~~
withjive
What I'm after for typed annotations is integration with the closure compiler
to give me static checking, so in large codebases I get that type safety, even
in javascript.

Thanks anyways though

------
jashkenas
More complete information seems to be available here:
<http://bolinfest.com/coffee/features.html>

------
stratospark
Interesting. With this and ClojureScript, I might need to take a deeper look
at Closure.

------
astrofinch
Google Closure: How Not to Write Javascript

[http://www.sitepoint.com/google-closure-how-not-to-write-
jav...](http://www.sitepoint.com/google-closure-how-not-to-write-javascript/)

~~~
julius
I commented on this blog post a long time ago here on HN. So did many other
HNer.

Whatever you might think about Closure, please do not make up your mind about
it from this article. The author does not seem to be an experienced javascript
developer (at that time).

------
ladon86
This is huge! How stable is it currently?

~~~
poliphylus
If you've been looking at the latest commits, effort is being done on adding
type annotations to the Coffeescript grammar. Once these are completed, the
resulting Javascript should be directly usable by the Compiler in advanced
mode (to get the most optimized code with the Closure Compiler you will need
type annotations for objects, function parameters and "typecasts"). I'm glad
the effort is being focused on type annotations rather than Closure Library
idioms (e.g. those under goog.array) at this stage. As someone who has to
write lots of boilerplate code to leverage the power of Closure Library
components I cannot thank this enough (and don't forget plovr!). Just the
Coffeescript class declaration sugar that's working right now is quite
powerful in terms of reduced noise in your code.

EDIT: wording.

