News for hackers. Stuff that matters.
Re:Building a single page app with Backbone.js, underscore.j... by ryandotsmith on Friday October 29, 2010 @07:43PM (#1849521)
"Also, since JavaScript has no formal classes there is no self-evident approach for structuring an entire application."

Really? http://javascript.crockford.com/prototypal.html

Re:Building a single page app with Backbone.js, underscore.j... by jashkenas on Saturday October 30, 2010 @12:23PM (#1851162)
Please don't just quote Crockford as gospel truth.

Crockford's prototypal revelation is only a slight alteration of the standard constructor pattern, and not a particularly useful one. You still have a class (the object that serves as a prototype for every instance you create), it doesn't add any particular flexibility, and it's quite slow. I encourage you to run the tests yourself:

http://jsperf.com/object-create-vs-crockford-vs-jorge-vs-con...

For me, that test clocks using Crockford's pattern to instantiate objects as 80% slower in Safari and Firefox, and 95% slower in Chrome, when compared to a standard use of JS prototypes.

Re:Building a single page app with Backbone.js, underscore.j... by natevw on Friday October 29, 2010 @09:06PM (#1849718)
Care to explain what you mean? Given that...

- Crockford originally thought it worthwhile to emulate classical inheritance

- so many, many other frameworks (and technique essays) provide various flavors of class-based inheritance

and that:

- even embracing true prototypical inheritance requires additional helper functions (or at least did in EcmaScript 3)

...I'm a little confused that you disagree that "there is no self-evident approach" for dealing with JavaScript's 'conflicted' (as the linked article correctly states) way of being a so-called prototypical language.