For example:
> CoffeeScript classes have attributes and properties that
> are encouraged to be mutated by reference so a language
> contrivance was devised (@) to allow OO style encapsulation
> while still trying to provide Functional referential
> transparency in anonymous contexts… wrap your head around that.
What? Instances of CoffeeScript classes are just like any other JavaScript object with a prototype -- just like any old string or function or array. The "language contrivance" `@` symbol is simply an alias for `this`. Nothing more and nothing less. `@name` in CoffeeScript is just `this.name` in JavaScript -- I'm not sure how you wind up with "functional referential transparency in anonymous contexts" from there ... but I'll have a little of whatever Leon's smoking ;)There's many other things in the essay, but the core boils down to this: There are a bunch of folks who are used to ignoring prototypes in JavaScript because they hand-roll objects by manually adding properties or using Crockford's "module pattern". For them, CoffeeScript's `class` keyword feels like it's adding something alien to JavaScript because it makes prototypes accessible. It's not. Using prototypes and objects lies at the core of JavaScript, and it's only the difficult and fragile syntax that leads people to manufacture new instances like this:
var makeDog = function() {
return {
bark: function(){},
run: function(){},
...
};
};
Instead of the far more efficient: new Dog;
Finally, CoffeeScript isn't encouraging you to do anything in particular. If you truly don't like using prototypes in JS, feel free not to use `class` in CS. > Jeremy Ashkenas, whom I do not know but would
> LOVE to have a drink with (alcoholic drink or
> otherwise) and pick his brain ...
Ping me the next time you're in NYC. Always happy to grab a drink and talk shop.