JavaScript Introducing ES2015 Classes Structure of Class

M Glasser
M Glasser
10,867 Points

What makes something a "true" object oriented language?

Guil mentions that JavaScript is not a "true" object oriented language, like e.g. Java.

What does he mean exactly?

What things can't you do with JavaScript that you can with a "true" OOP language?

1 Answer

Steven Parker
Steven Parker
177,845 Points

The classic definition is that there are 4 major principles that make a language object-oriented: Encapsulation, Data Abstraction, Polymorphism and Inheritence.

Some people consider that since JavaScript's objects use a prototype paradigm rather than the more common class paradigm disqualify it, but that's not universally agreed. And the argument isn't so much about what you can do, but how it is done since the approach can be quite different in the two paradigms. Nothing in the formal classic definition says the language must use classes.

Recent language additions (ES2015/ES6) have closed the gap bit by introducing keywords and syntax much like class-paradigm languages, but there still are differences including the lack of abstract classes.

Another common complaint is that JavaScript does not enforce object-oriented constructs. The developer can choose to use constructs that allow him to create object-oriented code or not. But I woud think the fact that you have the ability to create object-oriented code is more important than if the language itself is "truly" object-oriented.