News for hackers. Stuff that matters.
Re:Fogus: Node.js should become its own language by wladimir on Tuesday April 12, 2011 @09:48AM (#2437139)
My most common annoyance about Javascript is the lack of bound methods like in Python Ruby etc. When you specify callbacks, you always have to provide the value of 'this' as well. If you forget, it's basically random and you're in for some heavy debugging.
Re:Fogus: Node.js should become its own language by Cushman on Tuesday April 12, 2011 @09:56AM (#2437178)
You should also try CoffeeScript.

  dosomethingasync =>
      #etc
will automagically bind the closure to the current value of this.
Re:Fogus: Node.js should become its own language by demallien on Tuesday April 12, 2011 @11:11AM (#2437516)
'this' is evil in Javascript. The very first line in any constructor function that I write is: var that = this;

From then on, I use 'that' instead of 'this', relying on closure magic to make things work. You never have to worry about how the function is bound thereafter.

Re:Fogus: Node.js should become its own language by wladimir on Tuesday April 12, 2011 @11:51AM (#2437716)
Thanks. I think I like that solution, as it's extremely simple. Are there any drawbacks?

CoffeeScript is cool, as it is basically "Python in JS" but I have some resistance against languages that convert to other languages. I'm not so sure why.

Re:Fogus: Node.js should become its own language by demallien on Tuesday April 12, 2011 @12:01PM (#2437771)
No, no drawbacks that I'm aware of. You're basically using a closure to bind the object to the callback, instead of using Javascript's weird 'this' binding rules, that's all...