Image for post
Image for post

What JavaScript’s Object Prototypes Aren’t

Richard Kenneth Eng
May 8, 2016 · 2 min read

I am so sick and tired of hearing JavaScript proponents go on and on about how wonderful object prototypes are, along with prototypal inheritance (whether it’s concatenation or delegation). Let’s set the record straight…

We’ll begin by remembering why JavaScript was created. Brendan Eich wanted a light, breezy, scripting language for the web browser that was flexible and forgiving. It was never intended for serious software engineering. The qualities that make it flexible (e.g, object prototypes and loose typing) are the same qualities that work against good engineering. For all of ECMA TC39’s efforts, this has not changed.

Think of prototypes as the basic building blocks for an object-oriented programming model. In and of themselves, they are not a particularly high-level abstraction. They are, indeed, light and flexible. This is what makes JavaScript fun and easy to use.

JavaScript experts like to tout object prototypes as a superior means of doing object-oriented programming (OOP), but the truth is, the IT industry has roundly ignored prototypes, and for good reason. No other notable language created in the past quarter century has adopted object prototypes, except for 23-year-old Lua. The industry has shown a clear preference for class-based OOP, because while classes do have their problems, there is (currently) no better way to organize large-scale application code (say, in the hundreds of thousands of lines). Object prototypes would fall flat on its face here.

Languages like Smalltalk and C++ are capable of writing programs as big as a million lines of code. JavaScript would be hopeless in these situations. Apparently, ECMA recognized this and tried to accommodate the popularity of classes.

However, the latest ES6 class feature is only a half-assed implementation of class-based OOP. It’s just syntactic sugar over object prototypes. It still doesn’t support private state (member variables) in the way we expect. Member variables must be “faked” through a variety of workarounds such as programming convention, capturing normal variables with closures, and employing WeakMaps. ES6 is not a proper class-based OOP language like Smalltalk, C++, C# and Java.


Leave object prototypes where they belong: as a means of experimenting with ideas and prototyping applications. But when you get down to the brass tacks of engineering, you must use higher level abstractions that help you organize your code better…such as classes.

JavaScript Non Grata

Just say no to this abomination

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store