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
Poll: Have you moved from JavaScript to CoffeeScript?
111–120 of 178 posts
Re: Poll: Have you moved from JavaScript to CoffeeScript?
#112Initially, 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?
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?
#113Re: Poll: Have you moved from JavaScript to CoffeeScript?
#114I 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.
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?
#115Positive 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?
#116Earlier 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…
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?
#117Re: Poll: Have you moved from JavaScript to CoffeeScript?
#118Re: Poll: Have you moved from JavaScript to CoffeeScript?
#119Coffeescript curates the good parts of javascript for you and adds the syntactic sugar that cleans up the gnarliness of javascript.