4 ms·
My guess would be that static-typing is what they're trying to add albeit in an OOP form. Javascript is more of a 'Prototype' based language. They call things
by RandyRanderson 10y ago
My guess would be that static-typing is what they're trying to add albeit in an OOP form.
Javascript is more of a 'Prototype' based language. They call things 'Object's but I've seen few portions of JS code that actually use OOP in the traditional sense (encapsulation, polymorphism, etc)[0]. Mostly objects are just used for namespaces for finding vars and functions.
Agreed on the frameworks versus libs.
I would recommend that you work on a large codebase in a statically-typed language for a spell. Duck-typing is great for a shell script or blog post but things may be different when refactoring 100k lines of code, finding references, etc.
[0] Yes I know about the JS 'library' 'pattern'. That's more gymnastics than encapsulation.
- humanrebar 10y agoSorry, but this is one of my technical pet peeves. Polymorphism isn't solely an OOP concept. Every language has polymorphism of some sort. Most have several. Duck typing is an example of polymorphism actually. You probably mean "inheritance", which is a way to achieve polymorphism, not a synonym for it.
- RandyRanderson 10y agoI think something must have a form before you can say it has many. By your definition a cloud is a polymorph instead of a random shape. If you weaken the definition that much, it takes on a lot less meaning.
- humanrebar 10y agoThe wikipedia page lists three types of polymorphism. Duck typing is linked in the page as another kind of polymorphism. I've seen several other types in the wild, such as link-time polymorphism. https://en.wikipedia.org/wiki/Polymorphism_(computer_science) https://en.wikipedia.org/wiki/Polymorphism_(computer_science... The general idea is that you can have one expression dispatch to many different concrete implementations depending on the context. Virtual function calls is one approach, but C uses function pointers, C++ uses templates, dynamic languages use duck typing, several languages use message passing, and so on.