DEV Community

Discussion on: 🧐Most Confusing Part Of JavaScript.

Collapse
 
peerreynders profile image
peerreynders

Quote:

The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."

On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.

By moving from classes to hooks React simply moved from one stateful system to another - from objects to closures.

Deep dive: How do React hooks really work?

Interestingly the Elm community has pretty much come to the conclusion that "components" don't work in a functional system - i.e. Model, Update, and View are three separate systems. While each can be broken down into smaller units, it's a mistake to throw a little piece of model, update and view into an aggregating whole.

So React's claim to being functional is only skin deep - at its core it's still object-oriented even if it prefers to use closures.