Live data from Hacker News

Poll: Have you moved from JavaScript to CoffeeScript?

news.ycombinator.com

111–120 of 178 posts

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#111

Earlier quoted context omitted.

You may have been misinformed -- the values of direct, raw, fast code are a big part of the reason why CoffeeScript works the way it does, and why many scripts can end up running faster after getting ported to CoffeeScript. The golden rule of CoffeeScript is to avoid adding any library code to the runtime, and to avoid introducing any special calls, to the greatest extent possible. Many folks rely on a "forEach" (or…

I'd write that snippet the following way: for (var i = 0, ii = list.length; i Or: for (var i = 0, ii = list.length; i There are ways to make normal JavaScript not look ugly ;) EDIT: fixed minor oversight

And where do you get item from?

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#112

Initially, coming from a Python background, I looked at Coffeescript as a fix for all of JS's woes. In particular, I mistakenly though the fat arrow syntax would mean I never have to do any 'that = this' hacks again. In practice, though, I frequently need/want to call a method as a callback. And inside that function, I might want to get something from whatever initiated the callback, and save it to the object I'm a m…

Do you have an example of a real-world piece of code that wants to access both the lexical and dynamic "this" ... and isn't a jQuery callback?

> Do you have an example of a real-world piece of code that wants to access both the lexical and dynamic "this"

Yes.

> and isn't a jQuery callback?

No :^). And I wish JQuery ran the callback with a parameter too, so I could access 'this' to refer to the class and use the argument to refer to the object I'm going to run the callback on.

You're totally right that would be neater. Alas Coffeescript is a lot newer than JQuery, so despite technical neatness (or lack thereof in JQuery), Coffeescript has to work with JQuery to grow in popularity.

PS. Thanks for making Coffeescript. It's got me excited about JS again and I absolutely love it.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#114
post #50
post #20

I evaluated CS but ended up using Script# in my latest project at my day job, mainly because we are Microsoft shop and it will be easier for other C# developers to jump in if the need arises without learning a new syntax.

Trying to use a language that's vastly different to JavaScript to compile to JavaScript is an impedance mismatch that is destined to create more problems than it solves.

So far I’ve been very happy with how the project is turning out and I already see a lot of productivity gains; there seems to be much less run/test/debug cycles. The tooling/intellisense is so much better than the plain JavaScript and a lot of the typos and errors are caught at the compile time. Plus, writing C# on client and server is such a nice change.

Anyway, CS would be my second choice but that’s just because I work in .NET environment.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#115
I'd like to use CoffeeScript. Since it's just dabbling, I haven't actually managed to install it. I got caught up on the whole 'watch out NPM is capable of hacking you be wary!' part of the node/coffee install process.

Positive about it, though. I'll be using it in the future but not quite the 'next opportunity'.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#116

Earlier quoted context omitted.

Do you have an example of a real-world piece of code that wants to access both the lexical and dynamic "this" ... and isn't a jQuery callback?

> Do you have an example of a real-world piece of code that wants to access both the lexical and dynamic "this" Yes. > and isn't a jQuery callback? No :^). And I wish JQuery ran the callback with a parameter too, so I could access 'this' to refer to the class and use the argument to refer to the object I'm going to run the callback on. You're totally right that would be neater. Alas Coffeescript is a lot newer than J…

You're in luck then. This is precisely what the fat arrow in CoffeeScript is for: creating a function where the value of "this" is bound lexically. So:

    class Widget
      render: ->

        $(".widget-title").click (e) =>
          # `this` is still the Widget instance. 
          # `e.currentTarget` is the DOM element.

Re: Poll: Have you moved from JavaScript to CoffeeScript?

#119
I love coffee script. With coffee script and backbone I've been able to take an extra step in creating manageable complexity on the client side. I was never the greatest javascript programmer, and coffeescript allows me to not worry about all the things that tripped me up (prototypical inheritance and all the different ways to implement classes/inheritance) and concentrate on the problems I'm trying to solve with a clear set of rules.

Coffeescript curates the good parts of javascript for you and adds the syntactic sugar that cleans up the gnarliness of javascript.

Post reply on HN