3 ms·
I wouldn't tag CoffeeScript as 'make your code prettier', it brings so much more.
by emp_ 15y ago
I wouldn't tag CoffeeScript as 'make your code prettier', it brings so much more.
- BasDirks 15y agoAlthough I agree, I'd like to see you back that up. What (for you) makes it more than syntactic sugar?
- ryanfitz 15y agoI was recently at a sproutcore meetup where Yehuda Katz presented and mentioned one of the reasons he suggests using Coffeescript is because it can (as in now or in the future) generate more efficient javascript code than the typical javascript developer will write.
- wavephorm 15y agoLike what? From what I've seen it brings an alternative syntax without reducing any complexity. And before you say it, no, removing braces does not reduce complexity.
- bauchidgw 15y agowell, you definitly didn't use it.
- exogen 15y agoIt reduces complexity by making semantics that many programmers expect a part of the syntax. For instance, methods always being bound to their instance (=>). To use one striking example, it turns this: class Widget render: => alert "Here I am!" class Button extends Widget ...into this equivalent JavaScript: var Button, Widget; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; Widget = (function() { function Widget() { this.render = __bind(this.render, this); } Widget.prototype.render = function() { return alert("Here I am!"); }; return Widget; })(); Button = (function() { __extends(Button, Widget); function Button() { Button.__super__.constructor.apply(this, arguments); } return Button; })(); I'd say that's more than sugar. That is complexity reduction.