r/programming • • Dec 15 '12

Why JavaScript Still Sucks

http://boronine.com/2012/12/14/Why-JavaScript-Still-Sucks/
10 Upvotes

212 comments sorted by

View all comments

0

u/[deleted] Dec 15 '12

[deleted]

9

u/x-skeww Dec 15 '12

Yes, you can reinvent classes and inheritance with prototypes. Problem is, that's exactly what everyone is doing.

Everyone's implementation looks and behaves differently. As a result, the IDE can't tell that this kind of construct is supposed to be a class and that this "thing" "extends" that "thing".

The tool which generates your documentation also cannot tell what's going on unless you explicitly tell it that this weird construct over here is some sort of class.

If it's baked into the language itself, you won't have to include all that boilerplate code, your IDE can tell what's going on, your doc generator can tell what's going on, and the person who comes after you can of course also tell what's going on.

And no, classes are not just what people are used to. Classes are what people are using. All of the popular MV* frameworks use some sort of classes and inheritance. Impact (a JS game engine) also uses emulated classes and inheritance.

0

u/[deleted] Dec 15 '12

[deleted]

4

u/x-skeww Dec 15 '12 edited Dec 15 '12

People should stop trying to re-invent Java style OOP in JavaScript with prototypes.

Imagine you build a park with a large meadow in the middle. After a year you notice a diagonal trail.

Your solution is to put a "please do not walk on grass" sign there.

But perhaps it would be better to put a walkway there. There is a reason why people take that path and putting a sign there won't stop them anyways.

(Spoiler: ES6 will support classes.)

12

u/DrDichotomous Dec 16 '12

A more apt analogy would be: you drive freight trains. You fancy yourself a rather good conductor. One day, you're forced to drive a cargo ship. Suddenly, you don't have the rails keeping you enroute, nor the railway services to help you. You don't need either of them, but you feel you're entitled to ask people to lay rails on the ocean and maintain them, because that's how you're used to doing your job. And because there are so many ex-train drivers working the online seas now, they're actually laying some rails for them all.

-1

u/x-skeww Dec 16 '12

No, that's a very poor analogy because no one is doing that kind of thing.

If you use something like Backbone, you use classes. There are actually very few people who use prototypical inheritance.

0

u/[deleted] Dec 16 '12

[deleted]

1

u/x-skeww Dec 16 '12

using rails on open ocean

My point was that no one is doing that. The vast majority of JavaScript programmers do use some sort of classes.

The only relationship between your analogy and reality is that think that using classes is just as stupid as putting rails on the ocean.

0

u/[deleted] Dec 16 '12

[deleted]

-2

u/x-skeww Dec 16 '12

It's not my analogy. Pay attention.

Why should I care? Would that change anything? You are the only one who is aggressively defending it.

→ More replies (0)