4 ms·
I think React would get better developer experience and performance if they adopt language coroutine feature to implement direct style algebraic effect. In fact
by rixtox 2y ago
I think React would get better developer experience and performance if they adopt language coroutine feature to implement direct style algebraic effect. In fact the React Fiber system is already an implementation of algebraic effect.[1] However, it’s “suspending” a routine by raising an exception. Thus unwinding all the call stack, therefore, it needs to re-run that same routine on resume. This is the core reason why they have a performance issue and why they created the compiler to cache values on reruns.
JavaScript has language level coroutine features like async/await or yield/yield* and we have seen libraries using these features to implement direct style algebraic effect. For example Effect[2] and Effection[3]. You don’t need to memoize things if the language runtime can suspend and resume your functions instead of throwing exceptions and rerun them.
[1]: https://youtu.be/7GcrT0SBSnI https://youtu.be/7GcrT0SBSnI
[2]: https://effect.website/ https://effect.website/
[3]: https://frontside.com/effection/ https://frontside.com/effection/
- eiriklv 2y agoIn Rick voice: Well, that just sounds like generators with extra steps..
- namaria 2y agoThis is a Morty line...
- eiriklv 2y agoI feel like redux-saga [0] also belongs on that list of algebraic effects - at least as an honorable mention. [0]: https://redux-saga.js.org/ https://redux-saga.js.org/