5 ms·
React is pretty revolutionary. It turns rendering code into a simple pure function, which is a necessary step for where you want to end up.
by peterhunt 11y ago
React is pretty revolutionary. It turns rendering code into a simple pure function, which is a necessary step for where you want to end up.
- seanmcdirmid 11y agoRendering code is easy to express as pure functions...that is mostly how OpenGL and DirectX work, after all. React doesn't help very much with the state of your application (nor is it meant to). That being said, being able to treat the DOM as something to be rendered efficiently in immediate mode is quite useful.
- eropple 11y agoOpenGL is a big ol' box of state in almost everything it does. I'm not sure how you get pure functions out of that.
- seanmcdirmid 11y agoImmediate shader mode is fairly stateless, pixel and vertex shaders are as functional as one can get. Let's not talk about the fixed function APIs that no one uses anymore.
- eropple 11y agoI'm not sure what you mean by "immediate shader mode". Even direct state access mode is tweaking knobs in a state machine that can have very strange side effects if you don't re-set the state every time (and that's antithetical to pure functional programming). When not using DSA--I mean, just grep for "bind" in any OpenGL codebase...
- seanmcdirmid 11y agoThe hardware has state that is exposed more or less directly, but texture management is all just plumbing and easily wrapped. Most of my experience is with directX though, which seems to have a much cleaner API. Anyways, immediate mode UIs abound for game stacks given the ease at which they can be mapped to the GPU directly.
- eropple 11y agoDirectX still uses stuff like ID3D11DeviceContext::PSSetShaderResources to set application-global state that's required to do anything. It is fundamentally stateful and non-pure. I'm not sure why you're trying to argue this point.
- forthefuture 11y agoBenchmarks for React tell a different story. It's like two orders of magnitude slower than multiple alternatives. If you are performance critical, React is not possible to use in production, and likely will never be considering Facebook's development practices.
- antris 11y agoI've deployed two applications to production that use React and in neither has React created a performance bottleneck. Both of them are heavily used in mobile, too. And they work wonderfully. Benchmarks don't mean much when you're shipping real software to production.
- Nemcue 11y agoYou're reading too much into benchmarks without understanding what the alternatives are. Sure there are faster ways of rendering a template; just use format strings! Wow — super fast! It's a nonsensical way of reasoning about frameworks.