However, TypeScript is perhaps the better long run alternative to plain, boilerplate laden JavaScript. Bringing type safety into the mix is pretty compelling, going to check out TS at some point.
Intro to CoffeeScript
81–90 of 95 posts
Re: Intro to CoffeeScript
#82Earlier quoted context omitted.
I love CS myself. To me, in terms of aesthetics, CS is to JS what Scala is to Java. I have been bitten by the whitespace issue that you mention though. I don't recall the circumstance but an indent that was off just a bit did not cause the compiler to complain, but did cause it to generate code that I did not intend. It took some debugging of the JS output to find that one, and it certainly gives one pause to think h…
Compilers/interpreters complain about code that's invalid. Since the code is valid it shouldn't interfer, the problem is in the language's syntax design that's prone to shooting yourself in the foot. The design lets you mix indentations, something that Python won't let you do. A very simple scenario where hell is a keystroke away: hello = woot: 1 yay: 2 funfunfun: (x) -> x + 1 hello2 = woot: 1 yay: 2 nowthatsfun: (x)…
Re: Intro to CoffeeScript
#83> What I find sad, though, is that most people who dislike CoffeeScript don’t truly know it. They haven’t taken the time to really learn it, or even try it. Their reactions are usually knee-jerk, or based on fallacies. [...] The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know. Oh, wow. I've been using CoffeeScript for about a year…
I originally found it very appealing because I wasn't well acquainted with Javascript or its prototype class system, and so I didn't have that life-saving knee-jerk reaction about CS at all. I dove right in and used it extensively. After getting used to both JS and CS, I've realized that Coffeescript is at best a Javascript obfuscator.
I understand the use of some layers on web tech. SASS is great. It introduces constructs that you legitimately can't get in CSS, like functions and variables. Coffeescript on the other hand is just a toy for the Python devs that are too lazy to properly learn Javascript.
Re: Intro to CoffeeScript
#84Why does everybody compare CoffeeScript against vanilla JavaScript? I find using underscore makes my code sufficiently elegant that I've never felt the need to switch to CoffeeScript.
var newArray = _.map(_.filter(array, function(item) { return item % 2; }), function(item) { return item + 1; }); vs newArray = (item + 1 for item in array when item % 2) Uh huh.
var newArray = _.chain(array).filter(function(item) {
return item % 2;
}).map(function(item) {
return item + 1;
}).value();
I often use CoffeeScript + UnderscoreRe: Intro to CoffeeScript
#85Is CoffeeScript used much outside of Rails? If not, wouldn't it be a better idea to focus on mastering javascript so it applies globally?
Re: Intro to CoffeeScript
#86> What I find sad, though, is that most people who dislike CoffeeScript don’t truly know it. They haven’t taken the time to really learn it, or even try it. Their reactions are usually knee-jerk, or based on fallacies. [...] The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know. Oh, wow. I've been using CoffeeScript for about a year…
In what circumstance is it appropriate to consider the CoffeeScript ecosystem to be distinct from the JavaScript ecosystem?
> [...] and every JS solution and example out there
It seems impractical to regularly code in CoffeeScript without being fluent in JavaScript.
FWIW I agree with you about CoffeeScript being a little finicky about the syntax. There's the bit a seemingly unimportant (non -leading) space char generating dramatically different results, and also things like:
if foo and bar is x
not grouping the way you'd (or at least I) expect.Re: Intro to CoffeeScript
#87Earlier quoted context omitted.
var newArray = _.map(_.filter(array, function(item) { return item % 2; }), function(item) { return item + 1; }); vs newArray = (item + 1 for item in array when item % 2) Uh huh.
You could also do it with chain , which could make the first example a bit simpler to read and write. It is something like: var newArray = _.chain(array).filter(function(item) { return item % 2; }).map(function(item) { return item + 1; }).value(); I often use CoffeeScript + Underscore
Re: Intro to CoffeeScript
#88Earlier quoted context omitted.
var newArray = _.map(_.filter(array, function(item) { return item % 2; }), function(item) { return item + 1; }); vs newArray = (item + 1 for item in array when item % 2) Uh huh.
You could also do it with chain , which could make the first example a bit simpler to read and write. It is something like: var newArray = _.chain(array).filter(function(item) { return item % 2; }).map(function(item) { return item + 1; }).value(); I often use CoffeeScript + Underscore
var newArray = _(array).filter(function(item) {
return item % 2;
}).map(function(item) {
return item + 1;
});
Personally, I find this quite readable. And honestly, my comment was more about comparing CoffeeScript to its compiled JavaScript output, as is done in the slides. The compiled output is incredibly verbose and gives the false impression that JavaScript is always complicated.Re: Intro to CoffeeScript
#89Yes, let me learn this domain specific language for a domain specific language so that I can learn another domain specific language whenever this one stops trending.
If you know Javascript, learning Coffeescript is easy. I became proficient in Coffeescript in a few hours, and I sure don't feel like a genius, so other people can probably do the same. It's just a more convenient way of writing Javascript, with a nicer syntax and some really pleasant features.
It's an inherent phenomenon that DSLs will change and come and go at an incredibly fast rate. I just don't find it worthwhile to write code that is dependant on the DSL du jour and pigeonhole myself and whatever unlucky sole has to maintain the legacy code in the future. Imagine being dumped on a mountain of ColdFusion legacy code.
I just find it kind of absurd is all.
Re: Intro to CoffeeScript
#90Earlier quoted context omitted.
While I understand your sentiment... I have to disagree with a few assumptions. I feel that it's perfectly fine to write a project, or even a module in coffeescript. If you look at the NodeJS/NPM ecosystem, you will find a lot of modules will use, or be used by other modules that will be in either JS or Coffee respectively. While CS supports some features with different syntax than JS, it really isn't THAT hard to pi…
"If you look at the NodeJS/NPM ecosystem, you will find a lot of modules will use, or be used by other modules that will be in either JS or Coffee respectively" The big thing for me with Node.js was you could have whole application in one language. Apparently it's not possible anymore because you have to deal with CoffeScript.