220 points · by prostoalex · 6y ago · 164 comments
I think beyond the technical aspects, the way React evolved over time was really on point. The roadmap has always been very well designed and the literature around new features and deprecated ones top notch.
The way React is used has changed completely, but at no point did I feel upgrading was too costly and ended up stuck with an old version.
Same, but this is also why I feel burnt by create-react-app. There's so many important features the team has simply decided it won't support. One of the biggest issues with the React ecosystem is that there's nothing in between training wheels (CRA) and a motorcycle (rolling your own config). Maybe there's an opportunity for a new project there.
- https://github.com/gsoft-inc/craco
- https://github.com/harrysolovay/rescripts
- https://github.com/timarney/react-app-rewired
- https://github.com/arackaf/customize-cra
No, they're not "officially" supported, and you basically void the warranty by poking the configs manually, but the tools do what you want them to do.
I have the same complaint, but this is definitely possible using e.g. react-app-rewired.
Adding custom webpack loader rules is as simple as replacing the calls to react-scripts with calls to react-app-rewired and adding a .js file with your customizations.
I also think that next.js might have some of what the gp is interested in
AFAIK the "betweens" are Next.js, Blitz.js, Gatsby, Remix, Expo, etc.
Eventually I'll end up maintaining a company fork. It's more work for me but that's life. It's really just the dogmatic attitude of the CRA team that irks me.
You avoid ejecting and benefit from upgrades to CRA, but you can customize anything you like.
There's a `customize-cra` lib that provides useful helpers that you can use to perform the most common operations.
90% of the reason I eject CRA. rewired is essential.
The only thing that really ever irked me is the weird LICENCE clause about patents but that was addressed.
"Alpert, who helped chart React’s rise, doesn’t see an alternative emerging anytime soon."
This is completely ridiculous. Vue, Svelte, LitElement / Web Components, to name but a few. Maddening to see this level of journalistic malpractice.
Certainly there are plenty of great alternatives, each with their own pros and cons – but at this point, none clearly poised to “take over”.
1- It has bridged a previously large gap between FE code and BE code, and hence, made it a lot easier for engineers who aren't FE-specialists to build frontend code. I've found that backend engineers are a lot more willing and able to write React code, since it just feels more like the type of software they're used to writing.
2- It has brought concepts like functional/declarative programming much more center-stage. Prior to React, most developers might get a taste of declarative programming if they used SQL, but not in their day-to-day. They might give something like Scala a try, and either join the cult or turn around and run away screaming. React made these concepts a lot more accessible.
This article also doesn't delve into why Facebook supports React so much. Or why Twitter, Reddit and the rest are switching to React. The answer being that React lets developers make really smooth, really addictive websites. I wouldn't be surprised if there was some studies showing that any flash of unstyled content, i.e. a server render round trip, lowers conversions by x%. Therefore having a client side app is imperative if you care about having your users on your site. Multiply it by Facebook's revenue and paying the few million to fund a team of developers is a really good deal.
React did not bring that. Flux, released a few months later, brought the unidirectional data-flow to it; we were already building similar architectures using event buses, though with looser abstractions. The 'automatic rendering' is a bit deceptive. Unless you manually optimize it, React will simply re-render everything all the time which is the same as calling `App.render()` after every data change.
> React lets developers make really smooth, really addictive websites
As someone who has been doing it for a decade, I don't see an inch of a difference. Browsers got more capable, our tools got more sophisticated, but there is nothing really you couldn't do a decade ago. If anything, React leads to bloated and inefficient SPAs.
> any flash of unstyled content, i.e. a server render round trip, lowers conversions by x%. Therefore having a client side app is imperative
There is no 'round trip' for server render, it is the exact opposite - a client-side app will have no content to show in initial render until it boots in the client. Hence you need SSR + hydration to make it faster.
Do you legitimately see no difference in websites from 2012 and 2020? I'm honestly baffled if that's true. Payments are a massive difference that I've noticed. Every decent ecommerce site these days uses quite a lot of slick tricks to make the purchase flow really easy. Whether it's autocomplete based on Google Maps address data or being able to do everything without any obvious page refreshes, payments are significantly slicker. React definitely facilitates this.
> There is no 'round trip' for server render
Uhh there is a round trip. You click on a link, the new page does a request, loads new HTML, new CSS and paints the new page. Sure, an SPA takes longer to load up front, but you can now ensure that everything past that point is seamless. On a site like Facebook where the initial load won't kill conversions (because people are already addicted), you can take a 500ms hit so that stuff like infinite scroll and seamless notifications keep people on the site.
My understanding is that react will calculate the diff of your changes and what is already rendered and then only render the difference.
Also, along the topic in this thread, I've never met someone who used Clojure/script. It's why I ended up just using Node/Javascript in the end. It gets lonely in the Clojure cave.
Curious, does that apply to Angular/Ember?
I prefer the Angular approach. The initial learning curve is steep, but once you get over that, it becomes a rapid development framework, as all the pieces work together cohesively. The Angular CLI makes creating components, services, updating, etc a breeze, and helps maintain structure as your scale your app up. The core libraries (like routing, forms) are developed and maintained by Google, so you can expect a solid level of quality. The typescript-first approach means that your IDE can help you explore APIs, auto import, and work with third party libraries just as well. And the strong foundation provided by the core framework means that third party libraries have a better starting point upon which to supplement/extend.
Takes a bit of effort to learn, but once you are up and running with Angular things are pretty fast to put together.
Additionally, baking in rx-js felt like a serious mistake- not only was there the roller coaster ramp up of learning angular, but helping others on the team learn rx-js on top of it while trying to be productive probably cut our output in half.
It didnt help that we had a mix of junior developers and experienced .net devs all learning at the same time- half the battle was explaining which feature came from ES2015, typescript, angular or rx-js.
Hindsight may be 20/20, but I am reasonably confident that we could have been significantly better off with react. Ember was never an option because they are only just now getting features react and angular developers have been taking for granted for years.
Why do you need a specific forms or router library? Those are both things you can do with vanilla ES2015+ and React.
The library problem is self-inflicted, but it doesn't help that search engines tend to boost a lot of half-baked Medium posts about why you should use slightly-nicer flavor-of-the-month library to wrap something really basic like the fetch browser API.
As someone unfamiliar with the JS ecosystem I find React to be difficult because it appears just as a UI library. I have to then choose between dozens of competing options for everything (local state management, API calls, forms, URL routing, etc) where as frameworks such as Ember (not sure about Angular) seem to provide those features out of the box using a consistent API as well as some structure.
I guess React is powerful in the sense that it will allow you to do this that wouldn't fit well with the structure and way of doing things of Ember/Angular, but that seems to be a relatively rare problem. In the majority of cases the structure and "batteries included" approach of Ember (and maybe Angular) would be beneficial.
I see a similar problem with server-side Javascript. You can use Express for the HTTP side of things, but then you need to bolt on an ORM (from a dozen competing options), configure it, etc. There is no "batteries included" framework equivalent to Django, Rails or Laravel.
I think that might depend on what you're trying to do. I'm guessing as you say you are unfamiliar with the JS ecosystem, that you were trying to do something relatively simple.
As a full-stack developer who does a lot of front-end dev, my experience has been that hitting against the limitations of Angular/Ember* is exceedingly common. Not "every feature I try to implement common". But "every project has 2 or 3 features that need the flexibility" common. This is enough to make avoiding that pain very appealing.
I haven't had the same problems with Laravel or Django (haven't used Rails). And I think a key part of that is that Laravel/Django are still "just PHP/Python". Angular tries to put the proprietary string templating language in charge of everything. Which is painful.
Also: Picking libraries is a skill you can develop. You learn to google for the N most popular libraries for a given task. Then search for blog posts comparing advantages and disadvantages. And check for recent activity / outstanding issues. It only takes a couple of hours, and you get a library which is more tailored to your use case.
* I haven't actually use Ember. Only Angular.
for all of these examples, React offers a vanilla way to do this, or you could use React + ECMAScript & polyfills to do this. there are definitely bolt-on libraries that do more with those but you can be fine with minimal dependencies on other things.
I feel like a lot of pain with React development is self-inflicted.
hooks, axios, html, reach-router.
my point is that if you start with the assumption that browser APIs are sufficient, there is a natural progression to your project and «taste» in supporting libraries to react
The closest to those for JavaScript is Nest[0]
- Inferno and Preact: similar API but so much faster and smaller.
- Mithril: vdom based with components, faster than React and includes http client + router in 10kB gzipped.
- Vue: faster and smaller and has official batteries (unlike react-router which is a third party)
Etc.
[1] https://npm-stat.com/charts.html?package=react&from=2013-05-...
As for the technical merits of the alternatives, they fail to manifest in most situations:
"Faster" - any framework is fast enough for most of the common tasks; and even if a popular framework is not the fastest, it is not necessarily a bottleneck in the real life applications.
"Smaller" - it is just "faster" download. Irrelevant in many usage scenarios. It might be important in some applications, but shaving milliseconds vs man-months is a tough sale.
"Official batteries" - bundling of the dependencies is completely irrelevant from the business perspective. It's something that the developers are paid to figure out.
It's not really one or the other. Both Preact and Inferno can be used with React libraries with a compat layer.
> bundling of the dependencies is completely irrelevant from the business perspective.
It's not irrelevant. Vue is used by major corps in China.
> It's something that the developers are paid to figure out.
Didn't you just argue that the advantage of React is that developers get "things done _fast_"? How come this is not an advantage in the case of Vue?
It might be the case that in China Vue is the default and the most popular choice. And still my point holds: Vue is not the fastest, and is not the smallest framework. Technical merits alone ("faster", "smaller") are not enough to drive adoption.
On bundling/unbundling. I think it's a preference thing. "Batteries included" vs "modular" are both viable designs.
No JS framework felt anywhere close to the ease and power of Flex until I saw React.
React is Flex done right. React is Flex but armed with the knowledge that two way data binding is the fucking devil.
You mean in terms of performance, or something else?
You can greatly reduce this issue, but you do so by refusing to use most of the 2-way binding features. At that point, you're going to basically be doing one-way data flow anyway and might as well go all-in with a library tailored to do that.
This is the 'spooky action at a distance' aspect of data-binding. Doesn't it apply to data-binding in general?
The kicker for me is it is perfectly possible to use Flex in a one-way data binding manner. Just wish I'd worked that out 13 years ago!
There’s a beauty and simplicity in that. React is to web frontend what Lisp is to systems programming.
I used to _hate_ front-end programming, everything was a huge framework of magic dust and unicorns. Stuff Just Worked - if you knew the name of the magic incantations (variables and functions) you had to cast to make it work. Never mind that the whole front-end landscape seemed to do a complete pivot and invent new stuff every other week.
With React + Typescript it's just components that produce fragments of HTML and are entirely or at least mostly self-contained with a clear interface.
I recently wanted to throw up some minimal stuff on S3 without building, just a HTML file, and was surprised at how small the difference was, for simple enough pages - almost 0.
The coupling is super tight and always has been.
As a mostly back-end developer, I am not a fan of the complexity and magical bullshit you have to know about to use React properly. I am also disgusted when a stopwatch app that can be done in 500kb of native code turns into 25 MB of cruft when implemented with React Native. The fact that it completely disregards MVC, which maybe never really worked anyway, is the least of its problems.
Non-developers/designers were able to do a lot of the frontend stuff. With the "new" complexity of frontend development that's mostly gone.
I've seen it a few times with my own eyes that in teams the 1-5 frontenders specialised in html/css had a really hard time switching to react, at the same time more seasoned developers felt like fish in the water.
Considering the scarcity of developers that's actual a big deal, more work for developers while at the same time less work for traditional frontenders.
You probably shouldn't take up a career in technology if you're not willing to continually learn new things to keep up with advancements.
It's definitely not helping to democratize programming the way that the personal computer did when it simplified the world of computers down to a BASIC interpreter that a child could understand.
The "advancements" are necessary, but let's be honest - they are far from ideal, overcomplicated messes that exist solely to paper over the fact that the main software delivery platform is still just a hacked-up document viewer. They make professional programmers' lives easier, but the act of programming becomes generally less accessible with each iteration.
Frontenders at the the time didn't see themselves as engineers.
This is bad, this will kill the quirky, fun internet. Monoculture is not good.
That's a quick example of the way the React monoculture is bad for users of the web from a structural, not content point of view.
I say this as someone who has been using React professionally for 5+ years, and who was initially incredibly excited about React's potential. I'm less convinced it's actually good, after seeing how it's used in day to day work with regular engineers working on regular software that isn't Facebook scale.
And no one wants to wait around for all that state to load, that’s why those websites were so slow. Plus, then there’s the challenge of scale and traffic
It’s just not about the back button. It’s not about fashion, there are real problems that an SPA fixes. Sure it’s more complex, but the problem is more complex
It looks like you and a lot of people in HN work on super small websites that don’t require React or any SPA but yall don’t have to shit all over it and people who choose an SPA to build their web apps. In fact, more often than not, it’s the right choice
[1] http://web.archive.org/web/20171205085043/https://www.camach...
The intent of React is to drive new developers away from the building blocks of the web. And it has definitely succeeded at that. The way its ecosystem has grown all over the place, I find very passionate developers that swear by it.
But you never know, every technology at some point of time becomes a luddite’s take and then it’d become hard to even consider React. Someday may be near as well, given that it’s already more than 10 years old now… but then that would also be a good day for open web standards and simplicity. ;-)
That’s not React’s intent.