4 ms·
Studies have shown that number of lines of code is directly proportional to the number of bugs produced in that code, regardless of language or framework. Would
by ttfkam 2y ago
Studies have shown that number of lines of code is directly proportional to the number of bugs produced in that code, regardless of language or framework. Would it stand to reason then that a framework (yes, I said it) like React with its boilerplate is suboptimal, even with the new compiler?
As an old school web dev, to this day I cannot understand how multi-megabyte JavaScript code blobs (after gzipping!) became "normal" and acceptable.
- adzm 2y agoReact with several big libraries is still only 100k or so gzipped. I'd say it has less boilerplate than most other frameworks too, especially when compared to something like angular.
- ttfkam 2y ago1. React doesn't have less boilerplate than the average let alone most. 2. You haven't seen Angular lately, have you? It's on 18 now. 15 and 16 really trimmed things down.
- throwAGIway 2y agoA basic React app is 3 lines of code with an optional but recommended compilation step. You can get a very complex app with 20% of the code compared to Angular. Nothing else of the big ones (React, Vue, Angular, Svelte) comes close. Just don't use bloat like create-react-app, instead make an empty folder and install react and react-dom yourself.
- ttfkam 2y agoWhat's the smallest "Hello ${name}" hooked up to an input field you can make deployable in React? Svelte's is about 2.1KB last I checked. Can React get below 40KB?
- acemarke 2y agoNope, ReactDOM is 132K min, 42K gzipped: - https://unpkg.com/browse/react-dom@18.2.0/cjs/ https://unpkg.com/browse/react-dom@18.2.0/cjs/ - https://bundlephobia.com/package/react-dom@18.2.0 https://bundlephobia.com/package/react-dom@18.2.0
- throwAGIway 2y agoNote that this is the full package, and that it's normal to use a bundler that will treeshake things you don't use away. For example react-dom includes server-side rendering functions that are not necessary on browser side.
- ttfkam 2y agoSo how small can you get for a hello world page with a single "hello $name" component, spending an hour or less on it?
- acemarke 2y agoThat bundle size + the size of your component. Just created a fresh Vite+React app and rendered a "hello world" component, and the resulting output is: dist/assets/index-uoOveHrm.js 142.66 kB │ gzip: 45.76 kB
- acemarke 2y agoAfraid that's not accurate. The package size I linked is specifically the `react-dom.production.min.js` bundle that is used on the client side. The `react-dom` package does include _separate_ bundles used for server rendering, but that whole React client bundle will get included in your app, and it does _not_ tree-shake at all. (To be clear I _like_ React, but it's best to be accurate about what happens here.)
- throwAGIway 2y agoSo this package is not the actual react-dom package I get when I npm install react-dom? Thanks for the correction!