3 ms·
Import, classes, and default parameters have a very strong resemblance to CoffeeScript. In fact, Osmani expresses succinctly -- better than I could have -- why
by doublerebel 14y ago
Import, classes, and default parameters have a very strong resemblance to CoffeeScript. In fact, Osmani expresses succinctly -- better than I could have -- why I love Coffee so much over JS syntax:
Classes in ES.next are there to provide a declarative
surface for the semantics we're used to (e.g functions,
prototypes) so that developer intent is expressed
instead of the underlying imperative mechanics.
The Observables are so much like MVVM in KnockoutJS or SpineJS. (Plus, Spine is written in Coffee, and includes makeArray and a module pattern). I know many developers can't see the advantage to Coffee, but if you are interested in ES6 features you can use them right now by compiling Coffee to JS/ES5. Osmani didn't mention array comprehensions (ES6/JS1.7) or generators (ES6/JS1.8) but they are in Coffee as well.
So please, if you are interested in the future of JS, take another look at Coffee. And bring on ES6!
- yuchi 14y agoWhile comprehension is, generators are not part of Coffee-script.
- doublerebel 14y agoI should have been more specific. The generator expressions specified in Harmony [1] are the exact same syntax as in CoffeeScript. [1] http://wiki.ecmascript.org/doku.php?id=harmony:generator_expressions http://wiki.ecmascript.org/doku.php?id=harmony:generator_exp...
- masklinn 14y agoThat would be because both are lifted from Python. And it is not the exact same syntax (Harmony uses `for (e0 of e1)` paralleling its for-of iteration syntax and semantics), and more importantly the semantics are completely different. Finally, the syntactic similarity would already be covered by the array comprehension mention. Thus, there's nothing even remotely close to generator expressions in coffeescript at this point, as far as I know.
- doublerebel 14y agoWell, I suppose downvotes are what I get for commenting at 6 in the morning at 35,000 ft. Correct, as the article mentions Harmony takes many cues from Python, as does Coffee, and Coffee cannot magically create features that aren't supported by the underlying JS. However, it is possible to get a near-equivalent of generators (albeit with more overhead) using Continuation Passing Style and Iced CoffeeScript await/defer or another CPS lib. There are many who have explored this concept before myself, and I am now inspired to create an example to demonstrate IcedCS's ability with such a concept once I'm through the holiday.
- yuchi 14y agoActually, using ICS and CPS to build generators forces a reversed approach. With generators is the called function to own the process, in await/defer is the calling context which knows about the "generator like" functionality. And you're completely right about Coffee not able to implement ES6 generators.