Wednesday, July 11, 2012

When somebody tries to explain JavaScript's prototype system

4 comments:

Arcane Sentiment said...

It would be less confusing if JavaScript followed Self's terminology instead of redefining "prototype" to mean "traits".

patrickdlogan said...

The dude inventing it should have just said to himself, "I am clearly out of my league here. I will provide first-class functions and allow people to roll their own object systems."

Not ideal, but enormously better than every web developer on the planet going through the contortions of that poor soul in the post.

Arcane Sentiment said...

The dude inventing it did so in great haste, and under the strange constraint that it needed to look like Java. It used its OO features heavily, so leaving them as an exercise for the user was not an option. The resulting Self-disguised-as-Java is an excellent general-purpose-language-as-DSL; it looks bad only because it became popular before its bugs could be fixed.

patrickdlogan said...

it not only looks bad, it is horribly designed. there is no good excuse. there just isn't. contemplate "this" for a moment.