DEV Community

Why not React?

Taylor Hunt on September 17, 2023

This was an internal analysis I wrote when challenged if Kroger.com could do the same MPA speed tricks as my Marko demo, but still using React beca...
Collapse
 
cezarytomczyk profile image
Cezary Tomczyk

Based on my experience, the choice of framework is important, but it is even more important that software engineers understand what they are writing and how they are writing it. The framework organizes work, but does not guarantee a fast and stable application. The people factor is the weakest link here.

Collapse
 
rolanday profile image
Roland Ayala

Great analysis. It doubles-down on what I think most people already know, which is that React is a pig. Nevertheless, I've chosen to stay w/ React despite spending far too much time porting my app to alt frameworks like SvelteKit, SolidStart, and QwikCity. With each alt, I found, despite much preferring the DX, I was not being near as productive. People say React eco is just a bunch of vanilla JS libs wrapped for React. I wish that were true, but it's not. For example, there is no declarative Framer equivalents for vanilla JS, and there are a plethora of mature UI frameworks to choose from for React (I use react-aria). Once a react-alternative emerges w/ critical mass to drive widespread 3P lib support from something more than single-person efforts (that often go abandoned) I'll reconsider a change. If I had huge dev team to fill in the gaps, I might feel differently.

Collapse
 
ingosteinke profile image
Ingo Steinke, web developer

Thanks for assembling a lot of very specific points against React far beyond my initial gut feeling when I first had to use it that it felt wrong and overengineered to use so much client side JavaScript to achieve things most of which should have been plain vanilla HTML and CSS. But web performance is always an important consideration.

Collapse
 
jon49 profile image
Jon Nyman

The personal apps I make are just with MPAs, offline first. I use a little library I made called mpa-enhancer. It works well enough. For really interactive parts of a web page I should probably use a front end framework, or something simple like that. But I have limited time and writing pages in a templating-style is extremely straight forward and easy to work with.

But a lot of these JS libs always fascinate me. Like VanJS, Solidjs, Svelte, HTMX, and Marko. All really neat. But, like I said, with limited time mpa-enhancer does the job good enough.

Collapse
 
appurist profile image
Paul / Appurist

React is not a good framework -- in fact it's supposedly a library not a framework -- but it is the hands-down leader if you want to get a front-end job. But it's one of the worst choices you could make if you have any flexibility. It's full of limitations and workarounds and quirks to the fact that it isn't a framework and was designed with goals that don't match the common use patterns of today.

It was a step forward at the time, and a great learning experience, and a reasonable choice if there weren't better choices. Fortunately, there are many alternatives that are much better choices.

For React developers, the best choice is probably SolidJS, as it will be very familiar, but without the quirks and limitations. It's very similar in syntax and look, but has fundamental differences. State isn't tied to components like in React (breaking MVC-like patterns). It is by definitional optimal, in terms of DOM updates. So much that its performance is roughly tied with vanilla JS, faster than most of the other choices, and much much more performant than React. Components run once, unless you define effects to run on reactive data updates (and only the effect runs). It's simple to understand, everything is just a normal function.

Other reasonable alternatives would include Svelte, or even Vue (although I've gotten a little cold towards Vue in Vue 3 -- it's getting complicated like React). But I think I'd rather use Angular or just jQuery than React. It is a drain on productivity and comes bundled with technical debt and code pollution.

It's time to move towards something better. Solid (or Svelte, or Vue). React is just horrible in comparison.

Collapse
 
adaptive-shield-matrix profile image
Adaptive Shield Matrix

I think svelte addresses all react pain points very well

  • Its the more simpler "mutate directly" approach,
  • without any unnecessary/futuristic features like streaming, ssr, concurrent rendering, etc...
  • -> you don't need any of this if you base app is fast by itself.

To continue your thought - Intention of the creators for creating the framework Svelte

  • if asked that the main advantages of svelte are, or why someone should learn svelte - the creator of Rich Harris answers: just learn react first and see how easy everything is to do in svelte.
  • And I must agree, svelte has build-in methods for every react mechanism (state -> 3-5 different state management solutions, useEffect -> custom dsl with $, etc).
  • I think Rich Harris fully succeeded in creating a better React. Similar to how Google created go to replace java with a more streamlined/simpler/idiomatic language.

My only (and biggest) personal pain point in using svelte is the missing IDE support in Intellij... Thats why I still use React. 2-3X App-Performance gain is nice - but I can't pay for it with a decrease of development speed with more than 25% (the jump from Intellij -> vscode). If you use vscode as your main IDE this does not apply to you.

Collapse
 
adaptive-shield-matrix profile image
Adaptive Shield Matrix

Your link/quotation collection is awesome

Collapse
 
tigt profile image
Taylor Hunt

Thank you

Collapse
 
artydev profile image
artydev • Edited

Thank you

Collapse
 
brucehubbard profile image
Bruce Hubbard

Fantastic analysis as usual Taylor, well done.

Collapse
 
citronbrick profile image
CitronBrick

Thank you. This is the 1st time I'm hearing the term "HTML Streaming". One of my professors called its opposite "The White Screen of Death".

Collapse
 
lexlohr profile image
Alex Lohr

Marko is indeed a fine choice for a lot of commercial sites, but if you want something that looks more familiar to react developers, maybe try Solid.js.

Collapse
 
mb21 profile image
mb21

Astro is an MPA island framework with very similar DX to React.. in fact you can use React islands to slowly migrate away… to Preact or Solid or whatever…