4 ms·
I can handle that. First off, it gets a lot of (undeserved) hate from the Java-type people who think they know what OO is, but don't (because Java isn't OO, or
by qwertyuiop924 10y ago
I can handle that.
First off, it gets a lot of (undeserved) hate from the Java-type people who think they know what OO is, but don't (because Java isn't OO, or so says Kay, and even if it is, there's a whole lot of rubbish mixed in. For that matter, I don't think JS qualifies either, by Kay's definition, but it's closer). These are the people who say things like, "How can it be OO if it doesn't have classes?" and, "where are my Refactoring tools?" or "Design Patterns!" and implement a bunch of java-esque "classes," and proceed to write IteratorStrategyFactoryManagerService (speaking of which, if you have any actual "classes" in JS with the word "Strategy" in the name, indicating they implement the GoF Strategy pattern, you should stop now. And feel bad about yourself. But that's another story).
With ES6, we have "classes," so these people can stop complaining, but it's still bad, because they're actually syntactic surgar over prototypes, so you still need to understand prototypes (to say nothing of how "this" works, a genunine mess in JS, but a necessary one), but it's no longer obvious that that's what's happening, so you might think that you don't.
The more significant complaints are about Javascript's famous weak typing (quick, what's []+""? What about ""+[]? And {}+[]?), ASI (which is why if you're returning an object/array, you can't put the openbrace or openbracket on the next line, and why semicolons only sometimes matter), and general quirkiness (the aforementioned this, and so on).
These are actually legitimate reasons to dislike JS, but in my experience, they're not as severe issues as they're made out to be. If you really can't take it, though, TS or Flow can help you.
- Roboprog 10y agoOne of the main benefits of OOP is of course "polymorphism" (abstract base classes, interfaces), so naming any concrete class a "strategy" does seem a bit redundant. From what I have read by/about Kay, it sounds like his vision of OOP was very much about the actor (message queue) model, rather than (just?) a Simula 67 interface/protocol method table structure. As for the goofy "nonsense evaluation" in JS, it is a bit unfortunate, but I guess I must just write less nonsense than some others, as this doesn't seem to be a real problem for me :-) In fairness, the JS I write is client side, and it usually doesn't take very long to get to a state to test new code, as opposed to a long batch process.
- qwertyuiop924 10y ago>One of the main benefits of OOP is of course "polymorphism" (abstract base classes, interfaces), so naming any concrete class a "strategy" does seem a bit redundant. There are no abstract classes in JS: there doesn't need to be. Anyways, that's not what I mean: I was talking about the Strategy design pattern, which is actually a way of implementing higher order functions in languages that don't have them: thus, implementing classes for it in JS would be very silly indeed. As for Kay's vision of OO, it involves not only everything being an object, but extreme late binding. Java has neither.
- Roboprog 10y agoOK, gotcha. Somehow, I thought "strategy" was more general than just a single method/function to plug in. (confession: I have the GoF book, but don't remember every section) I think one of the best points PG (of YC) ever made was about programmers thinking in a particular language. "If Blub doesn't do it, you don't need it" (paraphrasing). Convincing the C++/Java/C# fans they need other features sometimes is quite hard.