Hacker Newsnew | comments | ask | jobs | submitlogin
CoffeeScript2 - A Redesign of the CoffeeScript Compiler (github.com)
74 points by netbyte 683 days ago | comments


jashkenas 683 days ago | link

Very much looking forward to seeing how this turns out. To view a list of some of the public-facing things Michael wants to change, take a look here:

https://github.com/michaelficarra/coffee-of-my-dreams

-----

TazeTSchnitzel 683 days ago | link

He wants to remove semicolons except where absolutely necessary?

Is he nuts? The compiled output shouldn't be relying on an error-correction feature. Especially since it might break minifiers and validators.

-----

ajross 683 days ago | link

I recognize the minifier significance. But wait, there are validators (!?) that choke on valid (!) syntax?

-----

TazeTSchnitzel 683 days ago | link

Lacking semicolons is an error, most validators error on it unless you tell them to ignore it.

-----

mistercow 682 days ago | link

Also, any minifier that turns valid javascript into invalid javascript is broken, full stop.

-----

ajross 682 days ago | link

Yes yes, but some do, it was a giant flame war, and I'll admit that it can be a practical issue (if not a correctness one) for javascript to rely on automatic semicolon insertion if it means you can't use your minifier of choice.

But trying to use a "validator" that validates a languages other than the one you are writing is just plain insane.

-----

michaelficarra 683 days ago | link

That would just be a default in my fork. Since the output will be massively configurable, you can use any style you can imagine, including a single line with all the braces and semicolons and whitespace you want. See http://oai.cwi.nl/oai/asset/10876/10876D.pdf for a resource on defining grammars for AST to CST transformations.

-----

mistercow 683 days ago | link

I'm not sure I agree that ASI is an "error-correction feature". Die-hard always-semicolon advocates certainly would like to paint it that way, but I think that may be rewriting history a bit.

-----

tomku 683 days ago | link

The ECMAscript standard[1] and the creator of the language[2] are pretty clear about it. From what I know of parsing, anything phrased in terms of adding tokens post-lexing in order to make an invalid parse tree valid as opposed to encoding the semantics in the grammar itself is most definitely an error correction method.

I think that a lot of the confusion comes from taking the term "error" personally. Nobody wants to be told that their programming style relies on "error correction" to be parsed, but it's just an implementation detail of the parser, not some kind of qualitative statement about your programming skills. Changing the name does not change how the parser works, and does not make anyone involved a better or worse programmer.

[1]: http://www.ecma-international.org/publications/files/ECMA-ST... (PDF) , section 7.9

[2]: http://brendaneich.com/2012/04/the-infernal-semicolon/, specifically "The moral of this story: ASI is (formally speaking) a syntactic error correction procedure."

-----

mistercow 683 days ago | link

Fair enough, but a statement like "compiled output shouldn't be relying on an error-correction feature" is only (self-evidently) true if we're using the informal, taking-it-personally connotations of "error correction".

-----

michaelficarra 683 days ago | link

I just want to make sure people know that those changes are bound for a fork once I reach full compliance with the current compiler. The project's one and only goal is to implement the language exactly as Jeremy's compiler does, but be prettier underneath (more extensible, versatile, configurable, robust, etc).

-----

GeZe 683 days ago | link

For those who don't want to wait, most of the public-facing changes listed there are already in LiveScript (http://gkz.github.com/LiveScript/) - though with a few more (in my opinion well justified) incompatibilities.

-----

pistoriusp 683 days ago | link

I don't think it's fair that he should be allowed to use the name "CoffeeScript 2."

I feel that it implies that it's an official project, but it's actually a re-implementation and separate project.

And if they're not backwards compatible it could lead to a ton of confusion and a fragmented language.

I think if you want your own project then you should at the very least get your own name.

-----

mistercow 683 days ago | link

I would be surprised if he didn't have Ashkenas's blessing on the name, since he's been the second biggest contributor to the main CoffeeScript project.

-----

michaelficarra 683 days ago | link

Fear not. The re-implementation will be completely backwards compatible. It just a smoother compilation pipeline, and adds some output configurability. But regardless, Jeremy and I have decided it would be best to change the name.

-----

jQueryIsAwesome 683 days ago | link

I will suggest a few alternatives: Winescript, Caffèscript, Browniscript, Shortscript and Rubyscript.

-----

michaelficarra 683 days ago | link

The names I suggested were "CoffeeScript: Reloaded", "CoffeeScript Episode II: Attack of the Clones", "The CoffeeScript Supremacy", and "Live Free or CoffeeScript Hard". Technically, right now it's "CoffeeScript II: The Wrath of Khan". Jeremy suggested CoffeeScript Redux. That's probably the best choice, though a little boring.

-----

YmMot 683 days ago | link

> "Live Free or CoffeeScript Hard".

That would be the fourth version of CoffeeScript. The 2nd version would be "CoffeeScript 2: Script Harder" which is much more awesome.

-----

a-priori 683 days ago | link

Might I suggest "CoffeeScript II: Electric Boogaloo"?

-----

almost 682 days ago | link

Maybe a name that distinguishes this compiler for CoffeeScript from CoffeeScript-the-language would be better? There may be other CoffeeScript compilers int the future, should they really all have the same name and be numbered? "CoffeeScript 2" (or any whimsical name that contains "CoffeeScript") would be confusing, it implies that it's the second version of the original CoffeeScript compiler, which it isn't.

-----

FuzzyDunlop 682 days ago | link

I'd personally suggest 'CoffeeScript vs Predator' too.

Since naming after desserts and alliterative animals has already been done, I wholeheartedly support action film naming conventions.

-----

adito 683 days ago | link

+1 for Caffèscript

-----

pbiggar 683 days ago | link

The phrase "proper compiler-design principles" really gets on my nerves for some reason. It instantly makes me doubt the ability of the person saying it. It seems to say "I've heard of Lex/Yacc and once glanced at the Dragon Book".

Anyway, I gather the OP is a coffeescript core contributor, so my default opinion is probably wrong in this case, hopefully.

-----

sirclueless 683 days ago | link

Forgive me for being skeptical, but it seems to me that CoffeeScript is going the way of Lisp: a language by hackers for hackers, with way too many incompatible implementations because each implementer has their own pet features that must be included.

-----

jashkenas 683 days ago | link

Whoops -- I think you're missing a big part of the point of compiling into "standard" JavaScript. Not only is CoffeeScript code fully compatible with any JS library ... it's also compatible with code generated by any version of the compiler, and with code generated by alterna-compilers like Coco, and eventually this project as well. The semantic compatibility exists at the "plain 'ol" JS level.

-----

streptomycin 683 days ago | link

That only solves part of the problem. It's still a big pain to have different syntax dialects and different tools that have to be used for different projects that are ostensibly written with the same language, even if they are compatible after you compile them to JS.

-----

yuchi 683 days ago | link

There's already a production ready transpiler, and a big bunch of production code to test against every new transpiler. Why do you think this is going to be a reason for fragmentation?

And, by the way, coffeescript is not intended to be a language for hackers (I mean, only for hackers) but for Ruby programmers moving to javascript, JS programmers looking for a more terse syntax and programmers with an eye for terseness.

In my opinion it has only two big flaws that need to be targeted by new transpilers: 1) for --> each 2) parens free chainable syntax.

-----

mistercow 683 days ago | link

Well, one reason that it could go that way is that the attitude that the maintainers has had toward feature-creep is "just make your own fork!" That's why we now have more dialects than we can shake a stick at, but it has kept the main branch from becoming PHP.

-----

charliesome 683 days ago | link

Please stop saying 'transpiler'. The CoffeeScript compiler is no less deserving of the term than any other compiler.

-----

mistercow 682 days ago | link

"Transpiler" is a subset of "compiler", so it can hardly be a demeaning term. A transpiler is simply a compiler that translates code from language A to language B where A and B have roughly the same abstraction level. It is true that CoffeeScript is slightly more abstract than JavaScript in a few features (although JavaScript's inheritance model is more abstract than CoffeeScript's classes, for example), but any difference in abstraction level is tiny compared to the difference between, say, C and assembly.

-----

yuchi 682 days ago | link

Exactly what I wanted to reply.

-----

tferris 683 days ago | link

This and nine more CoffeeScript derivates* from people who rather like to fragment a landscape with marginal improvements instead of supporting the leading pack are the reasons that CoffeScript hasn't reach critical mass and will fail as a standard.

* https://github.com/jashkenas/coffee-script/wiki/List-of-lang...

-----

johnfn 683 days ago | link

CoffeeScript hasn't attained critical mass? It's the 10th most popular language on github[1], over a decade younger than all the other contenders, and growing quickly.

Even if CoffeeScript was as niche as you argue, I'm not convinced that that would have any bearing on its success. CoffeeScript doesn't need a wide community to achieve success because it compiles to and is completely interoperable with JavaScript, the most popular programming language.

[1]: https://github.com/languages

-----

tferris 683 days ago | link

Regarding the front end side the CoffeeScript adoption is high and mainly driven by Rails but if you look at the back end it's different: CoffeeScript could not established with Node (most npm packages are in plain JS) and mixing Coffee and JS on the backend does not really work out (it's possible though).

-----

desireco42 683 days ago | link

I am ok with anything @jashkenas blesses.

Thanks Groupon and others for supporting this, I would agree with commenters that name is confusing.

-----

kristianp 683 days ago | link

Here is a relevant groupon blog post: https://engineering.groupon.com/2012/javascript/looking-forw...

How about multiple backend support? Perhaps then someone could add a dart or NaCl backend.

-----

almost 682 days ago | link

CoffeeScript relies heavily on the underlying JavaScript semantics (which is one of the main reasons it's so useful: It's Just JavaScript) so other backends would most likely be a lot harder to do than the JS one.

-----

michaelficarra 683 days ago | link

I hadn't seen that blog post. Thanks for that.

-----

rjd 683 days ago | link

So... I hope this isn't the future of updates to open source projects... crowd fund us or we won't do it... starting to see a pattern projects using this technique (albeit none are out rightly saying them won't its just implied)... not sure its a healthy development myself.

-----

tinco 682 days ago | link

It is an excellent development. It means developers can finally start to live from _independent_ open source development. This is not and never will be a replacement for hobby opensource, because that is done by developers who just want to do it, it would not make sense for them to threaten to not do it if we don't give them money. This is for the people who contribute to opensource, but also have a day job developing low-impact closed source commercial software, who don't have time or energy for large refactorings and rewrites.

"Crowd fund us or we won't do it" sure is a lot better than "We won't do it".

-----

emp_ 683 days ago | link

When I saw the empty repo (just with the README) and before reading the kickstarter page or comments here, I thought it was another vapor.js-like joke as a compliment to the original compiler, which IMO does it very well.

-----

chime 683 days ago | link

This looks like a great project. Wish I would have known about the Kickstarter campaign for it sooner. Can't wait to try it out.

-----




Lists | RSS | Bookmarklet | Guidelines | FAQ | DMCA | News News | Feature Requests | Bugs | Y Combinator | Apply | Library

Search: