4 ms·
I also came from a scripting background (Perl) but are you seriously telling real programmers coming to Javascript from C, C++, and the like that they should ch
by jimmytucson 14y ago
I also came from a scripting background (Perl) but are you seriously telling real programmers coming to Javascript from C, C++, and the like that they should change their way of thinking to fit a truly broken system originally used mostly by web designers?
- tikhonj 14y agoPrototypes are not a "truly broken system originally used mostly by web designers". The original idea came from a rather elegant language called Self[1], not designed for web work at all. It really is a good idea fundamentally, and, even if the JavaScript implementation is not great, it's still very useful. [1]: http://ranger.uta.edu/~nystrom/courses/cse3302-fa10/selfPower.pdf http://ranger.uta.edu/~nystrom/courses/cse3302-fa10/selfPowe... Also, people coming from C do not have any preconceptions about OO--C does not provide any OO facilities at all! They would have to change their way of thinking when transiting to any OO or functional language. C++'s model is also not particularly strong. There is a famous quote from Alan Kay (the initial inventor of OO): "I invented the term Object-Oriented and I can tell you I did not have C++ in mind." I personally have not used C++ much, but there seems to be a consensus that it's too complicated (especially in regards to multiple inheritance) and too error-prone. So I think it's more than reasonable to have people coming from C++ change their way of thinking! Whenever you switch to a sufficiently different language, you have to change your way of thinking. This is not only natural but also healthy. Finally, implying that people using JavaScript aren't real programmers is extremely condescending.
- johncoltrane 14y agoYes. Different languages, different paradigms, different designs, different flaws… You are learning a new language, not toying with a broken implementation of your preferred language. JS is not a subset of C++ or Java. Think/act accordingly. I don't use ".prototype" in AS3 or PHP because it doesn't make sense. I don't use "class" in JS because it doesn't make sense. Do it for your own sanity. It's really quite simple but it seems to be hard for a lot of people.
- justincormack 14y agoIt is not broken. First read Steve Yegge's excellent article on the Universal Design Pattern to understand why prototypes are really useful and natural http://steve-yegge.blogspot.co.uk/2008/10/universal-design-pattern.html http://steve-yegge.blogspot.co.uk/2008/10/universal-design-p... Then try to understand that prototypes are more natural in a dynamic language because they are completely dynamic. Classical inheritance is generally static. It might help using a language that has less syntactic confusion than Javascript, Lua is the best known, or Self or Io.