What JavaScript’s Object Prototypes Aren’t

I think you probably mean python's lack of java-style private etc? Yes, python mostly has _conventions and a bit of __ugly name mangling at the class level, not real private, but I'm not sure that's really what he was getting at in the first place - note the "(member variables)" bit. Python is relatively normal there: A foo.bar instance attribute is not going to be the same as baz.bar unless you do something fairly outlandish*. In contrast, a javascript foo.bar will be looked up along the prototype chain of foo, of course.

(* Actually, python is slightly weird there - people coming from other languages sometimes naively assume that if you do class Quux(object): bar = 0 that bar is declaring an instance attr bar that will exist in instances of Quux, but that's not at all how python works - but still, it also has instance attributes, but they're not set up with that syntax)

Anyway, they're not "private" in the java sense, but they're still independent little bits of state from eachother.

Javascript, even with the new class syntactic sugar, still has the weird prototype stuff going on. Note I said weird, not bad or wrong. But almost by definition, it doesn't support member variables in the way we expect. Now, that could be said to be simply because our expectations are colored by countless classes-and-instances OO languages and maybe three prototype ones at (javascript, self and lisp garnet), but it's still different.

My first impression of the new javscript class syntax sugar was that it borders on just being unhelpful obfuscation that makes it look too much like something "conventional" is happening when it really isn't, and you'll still have to understand the prototype stuff going on underneath to write javascript code properly. But I haven't really had cause to work with it yet.

/r/programming Thread Parent Link - medium.com