Live data from Hacker News

Intro to CoffeeScript

aseemk.com

71–80 of 95 posts

Re: Intro to CoffeeScript

#71

Why 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.

Re: Intro to CoffeeScript

#72

Is CoffeeScript used much outside of Rails? If not, wouldn't it be a better idea to focus on mastering javascript so it applies globally?

I would recommend against using any CoffeeScript before you're proficient with JavaScript. It can be a great boon to productivity, but if you don't understand what it's doing underneath you'll shoot yourself in the foot a lot.

I like CoffeeScript but I agree with this.

Also, yes, plenty of people outside of the Rails community use CoffeeScript (I'm one of them)

Re: Intro to CoffeeScript

#73

Earlier quoted context omitted.

1. That's missing the point, but since you asked, Emscripten and Native Client. 2. I disagree that CS's user experience is only "very slightly" better, but that's very subjective. Tooling is a somewhat valid complaint but it's a young platform and it's improving (source maps, etc). Semantics aren't quite identical (scoping, implicit return values, "fat arrow" functions). How does CS have more dependencies than any ot…

> 1. That's missing the point, but since you asked, Emscripten Has LLVM grown an assembly frontend? Emscripten is more or less an LLVM backend. > and Native Client. These are no more web applications than writing firefox extensions at this point. > Semantics aren't quite identical (scoping, implicit return values, fat arrow functions). For the most part, this is minimal syntactic sugar, not significantly different se…

> Has LLVM grown an assembly frontend? Emscripten is more or less an LLVM backend.

I don't know, probably, but LLVM's IF is essentially machine independent assembly anyway.

But again, missing the point.

Re: Intro to CoffeeScript

#74

Is CoffeeScript used much outside of Rails? If not, wouldn't it be a better idea to focus on mastering javascript so it applies globally?

After you load up the CoffeeScript module in your app.js (server.js etc) you can actually write an entire node.js app in CoffeeScript.

(Or just run the .coffee with "coffee" instead of "node")

Re: Intro to CoffeeScript

#75
post #3

Is CoffeeScript used much outside of Rails? If not, wouldn't it be a better idea to focus on mastering javascript so it applies globally?

The presentation is very well put together, but CoffeeScript is a hack built on top of JS in order to use Ruby semantics. You're correct in that it's not really used outside of Rails, and not knowing JS proper (not that I personally recommend using it for much more than jQuery and a couple other libraries, when you absolutely must) poses a problem for when someone runs into the 97% of code that is JS.

Pretty much everything in this comment is wrong (though I do recommend learning JavaScript before CoffeeScript)

CoffeeScript is no more of a "hack" than any compiler. Compilers take one language and turn it into another.

I think you mean Ruby syntax, not semantics. CoffeeScript's semantics are much closer to JavaScript than Ruby in almost every way.

It may have it's roots in the Ruby world, but I'd wager more non-Rubyists use CS at this point than Rubyists. I'm one of them.

Re: Intro to CoffeeScript

#76
> Indeed, I, too, dismissed CoffeeScript when I first saw it. But now that I’ve actually learned it and used it, I see how wrong I was: CoffeeScript truly is more powerful than JavaScript.

My experience was exactly the opposite. When I first saw CoffeeScript, I loved it, I started using it in my projects, it was really nice. But once I learned to use it, I stepped into all the annoyances caused by a bad use of significant whitespace, the many ways of doing the same thing, the tooling overhead, and the lack of readability.

In the end, I realised that there was a negative balance of good and bad things introduced by CoffeeScipt. It wasn't worth it. JS wasn't a bad language after all, and the improvements of CS were minimal if you know JS well.

Re: Intro to CoffeeScript

#77
It's funny to see some of the comments on this thread (or the comments on any thread about CoffeeScript), demonstrating exactly what Aseem is writing in his post. Delicious irony, that.

To make a different point, and one which can easily get missed -- the other unsatisfactory argument I hear somewhat often is: "I love the idea of CoffeeScript, except for X feature, which is terrible, so I won't try it." Where X can stand for scoping, classes, optional parentheses, and the like...

One of the big goals with the CoffeeScript compiler -- despite all of it's flaws and imperfections -- was to annotate and make accessible the source code, and to keep it tiny (I think still somewhere ~http://coffeescript.org/documentation/docs/grammar.html#sect...

Re: Intro to CoffeeScript

#78

Earlier quoted context omitted.

1. Since when can you write web applications in assembly? 2. Languages built upon assembly generally have better user experience, better tooling, better semantics and effectively no more dependencies than assembly. CoffeeScript has very slightly better user experience, worse tooling, identical semantics and more dependencies than javascript.

1. That's missing the point, but since you asked, Emscripten and Native Client. 2. I disagree that CS's user experience is only "very slightly" better, but that's very subjective. Tooling is a somewhat valid complaint but it's a young platform and it's improving (source maps, etc). Semantics aren't quite identical (scoping, implicit return values, "fat arrow" functions). How does CS have more dependencies than any ot…

Look, I think masklinn very clearly got your point. It just happens that your point was expressed in an unconstructive fashion, and then you keep (again, unconstructively) repeating "you don't get the point" without following up with a clearer explanation of what your point is (notwithstanding that I think we all understand your point).

Re: Intro to CoffeeScript

#79
post #5

> The explanation for most people’s dislike of CoffeeScript is probably our natural resistance to new things and our comfort in what we know. This is a mildly insulting, as is the invocation of Blub. CoffeeScript doesn't have a ton of exotic features. String interpolation, list comprehensions, and class definitions (!) are all familiar to programmers from other languages. I'm guessing that a lot of people have weighe…

What overhead? If you mean performance, there's actually basically no runtime performance overhead in most cases. In fact, if you use CoffeeScript's "for" loops have a performance advantage over JavaScript Array's map()/forEach() methods. I used to have a similar opinion but was forced to use CoffeeScript on a project and haven't looked back.

Other people have answered this for me, but I mean the overhead of another moving part in the tool chain. Sometimes this is worth it (i.e. your example of C v. assembly down thread), but I don't think it's the case here.

I don't mean to suggest CoffeeScript is without value. I just don't think it has hit the requisite "escape velocity" to make me want to integrate it to my tool chain.

Re: Intro to CoffeeScript

#80
for me its upto the developer to choose between JS or CS. I used CS for some time and i liked it. But still i preferred to switch back to JS only to not to waste my time in correcting CS syntax issues and play with JS.
Post reply on HN