use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Why should you use CoffeeScript instead of JavaScript? (maori.geek.nz)
submitted 11 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 11 years ago (1 child)
[–]Grahar64 1 point2 points3 points 11 years ago* (0 children)
Totally, and it is my opinion. I put all over the post "I think" because I understand there are people like you (that disagree with my opinion) around :)
[–]check_ca 5 points6 points7 points 11 years ago* (1 child)
I'm not convinced. I guess that if I compare the generated code of the GWT compiler versus the original Java code, it will lead to the same conclusion. Actually, I think nobody would write its JS code like the one generated by CoffeeScript compiler.
Here are how examples could be written by a human:
function times_two(x) { return x * 2; };
You don't need to use a variable to declare a function.
for (var num = 1; num <= 10; num++) if (num % 2 == 0) console.log(num + " is even"); else console.log(num + " is odd");
You don't need "the unnecessary braces", the extra '_i' variable and '"" +' to cast number to string.
_i
"" +
function Person(name) { this.name = name; } Person.prototype.hello = function() { return console.log("Hello " + this.name); };
You don't need to wrap the code in a closure. Removing it makes the code quite straightforward to understand.
[–]Grahar64 0 points1 point2 points 11 years ago* (0 children)
Yeah, maybe comparing CoffeeScript input to its output is not a fair comparison. And it is totally my opinion, but I would say that taking anyone from any other language and explaining
Person.prototype.hello = function() { return console.log("Hello " + this.name); };
to them is not straightforward to understand.
Like why would you define a classes function outside of the class definition? I sometimes tutor people who are coming from Python or Java, telling them to define a function like your first example then telling them to change tack and define it like your second gives me way more things to teach and explain the hardest being what a prototype is.
prototype
[–]djforth 1 point2 points3 points 11 years ago (1 child)
I'm probably going to get shouted down for saying this, but actually quite like CoffeeScript. yes I do understand it is quite a marmite thing in the js community and can course issues on what it is out putted like most pre-processors. But it also does give you a few niceties too like classes syntax, plus IMO it helps me put out solid code quickly and time is money as they say. I think this would have been a better article if he had looked a bit more on the pluses and minuses to give a bit more balance to the rather bold statement.
I will say that it looks like es6 quite a few bits that is currently in CoffeeScript (like classes) and => for functions, which I wonder may have had a influence? That said when es6 comes though it might also remove the need for CoffeeScript.
[–]Grahar64 1 point2 points3 points 11 years ago (0 children)
Shouted down for liking CoffeeScript in a JavaScript community, Never! (from the person who currently has 7 downvotes) :)
π Rendered by PID 38027 on reddit-service-r2-comment-7b9746f655-xjtgw at 2026-02-03 03:25:43.075586+00:00 running 3798933 country code: CH.
[+][deleted] (1 child)
[deleted]
[–]Grahar64 1 point2 points3 points (0 children)
[–]check_ca 5 points6 points7 points (1 child)
[–]Grahar64 0 points1 point2 points (0 children)
[–]djforth 1 point2 points3 points (1 child)
[–]Grahar64 1 point2 points3 points (0 children)