Is React Naked?

3 years ago

“Nobody gets fired for buying IBM." It's a phrase that bounced around in the 1990s when IBM was the dominant force in the computing industry and middle managers everywhere were struggling to come to grips with the need to integrate computing into their organizations.

That assumption proved to be 100% correct – right up until it wasn't.

Emperor React

Today, software development managers everywhere are struggling with staffing teams to match a chosen front-end web framework to reliably deliver applications. In this environment, the zeitgeist might as well be summed up as: "Nobody gets fired for choosing React."

The problem with the mindset underlying that phrase is that it isn't about delivering quality services/products, on time and on budget. It's about the protection provided by the herd. If a choice is popular in the industry, the talent pool will be comfortably large. If the technology choice undermines a project to the point of failure, you can readily blame the circumstances surrounding that choice instead of the choice itself. "It can't be IBM. We just didn't implement it right." Either way, management sleeps well at night.

Dissent Among the Ranks

At this point, you might be expecting a jump into a technical dissection of React and why it might not be everything its popularity is implying. However, that's been done before, and by folks with more experience and credibility in React than I have. (I've never written a line of React code and likely never will. I've been using Vue since version 0.6 and will continue to do so for the foreseeable future.)

So, instead, I refer to one of the best, recent discussions along these lines: React I Love You, But You're Bringing Me Down (related discussions at Hacker News and Reddit)

The article comes across as a thorough, level-headed, and fair treatment of various issues with modern React – with these two notable and ominous comments:

[I]f a library requires me to go through dozens of pages to use it properly, isn't it a sign that it's not well designed?

and

[T]his is lipstick on a pig. [...] Seeing you wear more and more makeup everyday is a constant reminder of what you're trying to hide.

Which leads to my own take on React.

All of This Has Happened Before

The origins of most modern GUI frameworks relate back to the Model-View-Controller (MVC) concept. I use "concept" here because quite a few variations on the general idea of MVC have been developed over decades, with various JavaScript frameworks based on them. But the general form of MVC-based GUI frameworks tends to: 1) address each of the concerns related to Model (data), View (presentation), and Controller (input) and 2) favor an object-oriented approach that is well suited to organizing, encapsulating, and managing the large amount of state typically required in a GUI.

In light of this, it's remarkable that React is often mistaken for a full GUI framework. In reality, React is commonly referred to as a "View library," meaning it is intended to address only the View part of MVC. I think this focus has two unfortunate effects:

First, React's approach is templating-oriented, which is not surprising given the fact that its developers are employees of Facebook – likely the largest PHP shop on the planet. The result is a component / widget approach that feels less like a traditional MVC / object-oriented solution and more like templating macros with a dash of state management sprinkled over them.

Second, ignoring Model and Controller concerns doesn't make them go away. They are an integral part of what makes a GUI function. React proponents make the case that decoupling Model and Controller from View allows for more flexibility and choice of solution – which it does. However, I believe the history of MVC frameworks makes clear that the best solutions are those that address all three concerns in the same context, with careful engineering balancing numerous tradeoffs.

Over the lifetime of React, I've repeatedly ended up concluding that it is somewhat half-baked and places too much responsibility on the developer to deal with its weaknesses. And that conclusion has been validated by observing people over years recounting their experiences working with React.

Technically, it competes with all comers. It just doesn't do it all that well. And when it comes to building complex GUIs, it's pretty important to not "bring a knife to a gun fight."

The Mouths of Babes

The criticism leveled in the article referred to earlier comes from a credible source that is heavily experienced with and invested in React. Judging from the assenting comments and discussion surrounding the publication of that article, this could portend an "emperor has no clothes" moment for React. If React's inherent weaknesses have finally caught up with it and that idea indeed takes hold, a slide in React's popularity could be unstoppable if and when the herd decides to turn in a new direction. And no herd travels in one direction forever.

In other words, "Nobody gets fired for choosing React" – until they do. Management may be in for some sleepless nights over the next few years.