3 ms·
So it's almost identical, but with worse (IMHO) syntax! It's all a matter of taste, but I can't see this as being more tasteful than js. Also it's comparing t
by axod 17y ago
So it's almost identical, but with worse (IMHO) syntax!
It's all a matter of taste, but I can't see this as being more tasteful than js.
Also it's comparing to crappy js.
For example
// Splats:
race = function race(winner) {
var runners;
runners = Array.prototype.slice.call(arguments, 1);
return print(winner, runners);
};
Could be rewritten
race = function race(winner) {
return print(winner, Array.prototype.slice.call(arguments, 1));
}
- zefhous 17y agoThe JavaScript examples don't show what you would write in JavaScript, they show the compiled JavaScript output when you write it in CoffeScript.
- jashkenas 17y agoThere's no question that the generated JavaScript is never going to be as pretty as handwritten JS. But that said, choosing splats as your example of bad syntax isn't the best choice, because there isn't a syntactic equivalent in JavaScript. This CoffeeScript: send_letter: (name, addresses...) -> # more code... Where the array of addresses can be referenced and used as many times as you like within the function body, would need to be translated as this JavaScript: var send_letter = function send_letter(name) { var addresses = Array.prototype.slice.call(arguments, 1); # more code... }; Which is both a good bit more to type, as well as more work -- you need to figure out the index from which to slice. The only difference with the generated JS is that the variable declaration is on a separate line -- a feature that allows all assignments to be used as part of a larger expression.
- jrockway 17y agoYou hate everything. Maybe you should just not read this type of article.
- axod 17y agoYeah you're right. I'll try hard to ignore the "language syntax sucks/rocks/is so important" articles.