Live data from Hacker News

Prototypes Are Not Classes

raganwald.com

1–10 of 46 posts

Re: Prototypes Are Not Classes

#3
post #2

Never get why people are so excited with atomization, that necessity of decomposing everything in atomic parts...

Some people just want to watch the world burn.

Others are curious. What is fire? Is electricity fire? What's the smallest thing That can be on fire? How can you make something burn faster?

We make up little explanations about how knowing the answers to these questions makes us more productive world-burners, but in the end we're just curious people.

Re: Prototypes Are Not Classes

#7
post #2

Never get why people are so excited with atomization, that necessity of decomposing everything in atomic parts...

I think the decomposition is important but not necessariy that you have to continue that process until you have atomic parts.

Understanding the decomposition allows you to internalize the behavior of a complex entity and thus understand and predict how it will behave in different (i.e. previously unseen) contexts.

If you avoid decomposition and instead view each entity as a one-off with its own unique behavior patterns then you are limited to memorizing the behavior on a case-by-case basis. Any extrapolation or prediction of behavior would be as effective as random guesses.

Re: Prototypes Are Not Classes

#8
post #5

I guess before learning JavaScript, developers need to be sent to a Self learning camp.

I'm not sure that's a good idea, because then they'd be made very sad by constructors, by prototypes being something completely different[0], by not having mixins[1], by single-inheritance, by dynamic inheritance[2], by the lack of blocks (and non-local returns), etc…

Essentially, by javascript not being a very good Self.

[0] IIRC in Self the prototype is the object you copy, objects linked through parent slots are either mixins or traits.

[1] although it doesn't have a lobby, which makes the difference between traits and mixins, js's prototypes are probably closer to self's traits.

[2] that's being added in ES6, yay. But still single, boo.

Re: Prototypes Are Not Classes

#9
post #8
post #5

I guess before learning JavaScript, developers need to be sent to a Self learning camp.

I'm not sure that's a good idea, because then they'd be made very sad by constructors, by prototypes being something completely different[0], by not having mixins[1], by single-inheritance, by dynamic inheritance[2], by the lack of blocks (and non-local returns), etc… Essentially, by javascript not being a very good Self. [0] IIRC in Self the prototype is the object you copy, objects linked through parent slots are e…

MI still sends shivers down my spine, having spent time in the C++. Just say no.

Re: Prototypes Are Not Classes

#10
This sort of realization is the first step to realizing that you really shouldn't be writing javascript like java/C++. It makes things feel a lot nicer when you start really thinking in JS. I'd recommend checking out Crockford's "Crockford on Javascript" series for some good intro on thinking about Javascript (http://www.youtube.com/watch?v=JxAXlJEmNMg). Section 3 is where you really start talking about JS.

For a good counter-example, check out a lot of google's JS libs (in all their giant module goodness).

Post reply on HN