├── .gitignore ├── LICENSE ├── README-more-stats.md ├── README.md ├── reactn ├── .gitignore ├── README.md ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ └── manifest.json ├── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ └── serviceWorker.js └── yarn.lock └── redux ├── .gitignore ├── README.md ├── package.json ├── public ├── favicon.ico ├── index.html └── manifest.json ├── src ├── App.css ├── App.js ├── App.test.js ├── index.css ├── index.js ├── logo.svg └── serviceWorker.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /create-react-app 2 | /reactn/build 3 | /reactn/node_modules 4 | /redux/build 5 | /redux/node_modules 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Charles Stover 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README-more-stats.md: -------------------------------------------------------------------------------- 1 | The following statistics were deemed unimportant for the main README and are listed here for archival. 2 | 3 | ## Foundation Testing 4 | 5 | ### Development Size in Bytes 6 | 7 | The development size in bytes measures how much disk space is required to implement one of these global state management packages. 8 | This size was determined prior to the adjustments listed under the Methodology section above and therefore only takes into account _dependencies_. 9 | This removes white-space bias, however negligible, and focuses solely on the size of ReactN and Redux. 10 | 11 | The baseline, `create-react-app`, is 116,852,648 bytes. The following statistics _include_ `create-react-app`'s files. 12 | 13 | | Application | Size | Size Diff. | CRA Diff. | 14 | | ----------- | ----------- | ---------------- | ---------------- | 15 | | reactn | 117,111,833 | -272,831 (-0.2%) | +259,185 (+0.2%) | 16 | | redux | 117,384,664 | +272,831 (+0.2%) | +532,016 (+0.5%) | 17 | 18 | Comparisons were determined using `ls -r | measure -s Length` in Windows PowerShell. 19 | 20 | Using ReactN will increase your development disc usage by 0.2%. 21 | Using ReactN over Redux will decrease your development disc usage by 0.2%. 22 | 23 | Using Redux will increase your development disc usage by 0.5%. 24 | Using Redux over ReactN will increase your development disc usage by 0.2%. 25 | 26 | ### Development Memory Size 27 | 28 | The development memory size is how much memory is required to run a development build of your application. 29 | 30 | | Application | Code | Strings | JS Arrays | Typed Arrays | System Objects | Total (KB) | Total (MB) | Total Diff. | 31 | | ----------- | -------- | -------- | --------- | ------------ | -------------- | ---------- | ---------- | --------------- | 32 | | reactn | 1,116 KB | 1,745 KB | 262 KB | 2 KB | 1,904 KB | 15,056 KB | 14.7 MB | -452 KB (-2.9%) | 33 | | redux | 1,140 KB | 1,882 KB | 270 KB | 1 KB | 2,308 KB | 15,508 KB | 15.1 MB | +452 KB (+3.0%) | 34 | 35 | Comparisons were determined using the Memory development tool built into Chrome 68.0.3440.75 (Official Build) (64-bit) after running the application using `yarn start`. 36 | 37 | Using ReactN over Redux will decrease your additional development memory by 2.9%. 38 | Using Redux over ReactN will increase your additional development memory by 3.0%. 39 | 40 | ### Production Memory Size 41 | 42 | The production memory size is how much memory is required to run a production build of your application. 43 | 44 | | Application | Code | Strings | JS Arrays | Typed Arrays | System Objects | Total (KB) | Total (MB) | Total Diff. | 45 | | ----------- | ------ | -------- | --------- | ------------ | -------------- | ---------- | ---------- | --------------- | 46 | | reactn | 366 KB | 176 KB | 13 KB | 1 KB | 1,121 KB | 3,161 KB | 3.1 MB | -199 KB (-5.9%) | 47 | | redux | 389 KB | 183 KB | 13 KB | 1 KB | 1,211 KB | 3,360 KB | 3.3 MB | +199 KB (+6.3%) | 48 | 49 | Comparisons were determined using the Memory development tool built into Chrome 68.0.3440.75 (Official Build) (64-bit) after building the application using `yarn build`. 50 | 51 | Converting from Redux to ReactN will decrease your additional production memory by 5.9%. 52 | 53 | Converting from ReactN to Redux will increase your padditional roduction memory by 6.3%. 54 | 55 | ## Application Testing 56 | 57 | ### Development Memory Size 58 | 59 | The development memory size is how much memory is required to run a development build of your application. 60 | 61 | | Application | Code | Strings | JS Arrays | Typed Arrays | System Objects | Total (KB) | Total (MB) | Total Diff. | 62 | | ----------- | -------- | -------- | --------- | ------------ | -------------- | ---------- | ---------- | --------------- | 63 | | reactn | X KB | X KB | X KB | X KB | X KB | X KB | X MB | -X KB (-X.X%) | 64 | | redux | X KB | X KB | X KB | X KB | X KB | X KB | X MB | +X KB (+X.X%) | 65 | 66 | Comparisons were determined using the Memory development tool built into Chrome 68.0.3440.75 (Official Build) (64-bit) after running the application using `yarn start`. 67 | 68 | Using ReactN over Redux will decrease your development memory by X.X%. 69 | Using Redux over ReactN will increase your development memory by X.X%. 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactN vs Redux 2 | 3 | This repository contains a test that compares an implementation of the same application using both ReactN and Redux. The resulting applications are compared in size, speed, and memory usage. 4 | 5 | ## Foundation 6 | 7 | The applications are bootstrapped using `create-react-app@2.1.0`, then upgraded to `react@16.7.0-alpha.0` and `react-dom@16.7.0-alpha.0`. 8 | 9 | ### reactn 10 | 11 | The `reactn` application installs the `reactn@0.0.9` dependency. 12 | 13 | ### redux 14 | 15 | The `redux` application installs the `react-redux@5.1.0`, `redux@4.0.1`, and `redux-thunk@2.3.0` dependencies. 16 | 17 | ## Foundation Testing 18 | 19 | Before the implementation even occurs, these are the comparisons of merely the foundations on which the implementations are based. 20 | 21 | An empty global state is initialized and the `App` component is connected to the global state. 22 | 23 | ### Methodology: reactn 24 | 25 | The `App.js` file was adjusted to import from `reactn` instead of `react`. 26 | 27 | ### Methodology: redux 28 | 29 | The `index.js` file was adjusted to create a store and implement the Provider HOC as follows: 30 | 31 | ```JavaScript 32 | import { Provider } from 'react-redux'; 33 | import { applyMiddleware, combineReducers, createStore } from 'redux'; 34 | import thunk from 'redux-thunk'; 35 | 36 | const store = createStore( 37 | combineReducers({ }), 38 | applyMiddleware(thunk) 39 | ); 40 | ``` 41 | 42 | The `` component was then wrapped in ``. 43 | 44 | The `App.js` file was adjusted to wrap the default export in the `connect` HOC. 45 | 46 | ```JavaScript 47 | import { connect } from 'react-redux'; 48 | 49 | export default connect( 50 | null, 51 | null 52 | )(App); 53 | ``` 54 | 55 | ### File Count 56 | 57 | The file count metric measures how many files are required to exist in your file system to implement one of these global state management packages. 58 | 59 | The baseline, `create-react-app`, has 24,384 files. The following statistics _include_ `create-react-app`'s files. 60 | 61 | | Application | Files | Files Diff. | CRA Diff. | 62 | | ---------------- | ------ | ------------ | ------------ | 63 | | reactn | 24,396 | -213 (-0.9%) | +12 ( 0.0%) | 64 | | redux | 24,609 | +213 (+0.9%) | +225 (+0.9%) | 65 | 66 | Comparisons were determined using `ls -r | measure -s Length` in Windows PowerShell. 67 | 68 | Using ReactN will increase your file count by 0.0%. 69 | 70 | Using Redux will increase your file count by 0.9%. 71 | 72 | Converting from Redux to ReactN will decrease your additional file count by 0.9%. 73 | 74 | Converting from ReactN to Redux will increase your additional file count by 0.9%. 75 | 76 | ### Production Bundle Size 77 | 78 | The production size in bytes measures how many bytes are contained in the production-ready bundle that the end user downloads. 79 | 80 | The baseline, `create-react-app`, is 465,572 bytes. The following statistics _include_ `create-react-app`'s files. 81 | 82 | | Application | Size | Size Diff. | CRA Diff. | 83 | | ----------- | ------- | ---------------- | ----------------- | 84 | | reactn | 534,729 | -76,818 (-12.6%) | + 69,157 (+14.9%) | 85 | | redux | 611,547 | +76,818 (+14.4%) | +145,975 (+31.4%) | 86 | 87 | Comparisons were determined using `ls -r | measure -s Length` in Windows PowerShell after building the application using `yarn build`. 88 | 89 | Using ReactN will increase your production bundle size by 14.9%. 90 | Using ReactN over Redux will decrease your additional production bundle size by 12.6%. 91 | 92 | Using Redux will increase your production bundle size by 31.4%. 93 | Using Redux over ReactN will increase your additional production bundle size by 14.4%. 94 | 95 | ## Application Testing 96 | 97 | The following tests instantiate a store, reducer, render data from the store, and update that data in response to user interaction. 98 | 99 | The store contains an integer `x` and an object `data`. 100 | For `reactn`, these properties are on the global object, as that is a limitation of ReactN. 101 | For `redux`, these properties are on a `demo` object, as that is a limitation of Redux. 102 | 103 | The `App` React Component is updated to fetch data on mount and store the response in the global state. 104 | 105 | The `App` React Component is updated to read from the global state and display the value of `x` on a button. 106 | When the button is clicked, a reducer is used to increment the value of `x` by 1. 107 | 108 | ### Production Memory Size 109 | 110 | The production memory size is how much memory is required to run a production build of your application. 111 | 112 | | Application | Code | Strings | JS Arrays | Typed Arrays | System Objects | Total (KB) | Total (MB) | Total Diff. | 113 | | ----------- | ------ | -------- | --------- | ------------ | -------------- | ---------- | ---------- | -------------- | 114 | | reactn | 392 KB | 177 KB | 12 KB | 0 KB | 1,620 KB | 3,642 KB | 3.6 MB | +24 KB (+0.7%) | 115 | | redux | 397 KB | 184 KB | 13 KB | 0 KB | 1,512 KB | 3,618 KB | 3.5 MB | -24 KB (-0.7%) | 116 | 117 | Comparisons were determined using the Memory development tool built into Chrome 68.0.3440.75 (Official Build) (64-bit) after building the application using `yarn build`. 118 | 119 | Converting from Redux to ReactN will increase your production memory by 0.7%. 120 | 121 | Converting from ReactN to Redux will decrease your production memory by 0.7%. 122 | 123 | ### Production Bundle Size 124 | 125 | The production size in bytes measures how many bytes are contained in the production-ready bundle that the end user downloads. 126 | 127 | | Application | Size w/ .map | Size Diff. w/ .map | Size w/o .map) | Size Diff. w/o .map | 128 | | ----------- | ------------- | ------------------ | -------------- | ------------------- | 129 | | reactn | 531,736 | -80,256 (-13.1%) | 141,142 | -10,512 (-6.9%) | 130 | | redux | 611,992 | +80,256 (+15.1%) | 151,654 | +10,512 (+7.4%) | 131 | 132 | Comparisons were determined using `ls -r | measure -s Length` in Windows PowerShell after building the application using `yarn build` both including and excluding the `.map` files. 133 | 134 | Converting from Redux to ReactN will decrease your production bundle size by 13.1% or 6.9%, depending on if you consider `.map` files as a part of your bundle size. 135 | 136 | Converting from ReactN to Redux will increase your production bundle size by 15.1% or 7.4%, depending on if you consider `.map` files as a part of your bundle size. 137 | -------------------------------------------------------------------------------- /reactn/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /reactn/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | -------------------------------------------------------------------------------- /reactn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactn", 3 | "version": "0.1.0", 4 | "homepage": ".", 5 | "private": true, 6 | "dependencies": { 7 | "react": "^16.7.0-alpha.0", 8 | "react-dom": "^16.7.0-alpha.0", 9 | "react-scripts": "2.1.0", 10 | "reactn": "^0.0.9" 11 | }, 12 | "scripts": { 13 | "start": "react-scripts start", 14 | "build": "react-scripts build", 15 | "test": "react-scripts test", 16 | "eject": "react-scripts eject" 17 | }, 18 | "eslintConfig": { 19 | "extends": "react-app" 20 | }, 21 | "browserslist": [ 22 | ">0.2%", 23 | "not dead", 24 | "not ie <= 11", 25 | "not op_mini all" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /reactn/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CharlesStover/reactn-vs-redux/082ea23f297cc335901ddc55be12a4bf14150fe3/reactn/public/favicon.ico -------------------------------------------------------------------------------- /reactn/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 22 | React App 23 | 24 | 25 | 28 |
29 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /reactn/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /reactn/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | } 9 | 10 | .App-header { 11 | background-color: #282c34; 12 | min-height: 100vh; 13 | display: flex; 14 | flex-direction: column; 15 | align-items: center; 16 | justify-content: center; 17 | font-size: calc(10px + 2vmin); 18 | color: white; 19 | } 20 | 21 | .App-link { 22 | color: #61dafb; 23 | } 24 | 25 | @keyframes App-logo-spin { 26 | from { 27 | transform: rotate(0deg); 28 | } 29 | to { 30 | transform: rotate(360deg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /reactn/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'reactn'; 2 | import './App.css'; 3 | 4 | class App extends Component { 5 | 6 | componentDidMount() { 7 | this.global.fetchData(); 8 | } 9 | 10 | render() { 11 | return ( 12 |