Re:Prototypes Are Not Classes
by colept on Sunday January 19, 2014 @11:11PM
(#7087507)
It felt like the author was using the post as a cathartic persuasion for why prototypes differ from classes. JavaScript functions are a prototype of a class. Prototyping in JavaScript is an analog to class extensions, with elaborate definitions for private/protected variables. It's a debate over semantics and syntax, and it's useless because the analog to a object oriented class can be done with JavaScript's syntax.
Long story short, the class analog is semantically no different than the JavaScript prototype when done correctly.
[ Parent
| on HN ]
Encapsulating instance state us not the point, encapsulating the class behaviour is the point. So, if you can make the prototype itself private and modify the prototype with class methods, you have something that prototypes by themselves do not express.
The analogy is not to a private instance variable in Ruby, the analogy is to a class method in Ruby Dutch as define_method.