You should know ClojureScript before choosing Redux, here’s why…
I’m not happy about Redux, but I’m not writing long post trying to uncover the dark side of Redux. People are praising Redux. As we all know it came from Elm, and earlier it can from speeches by Bret Victor. It’s time travelling debugger. Like all developers I want it become easier and faster to build apps. Redux is making things much better. The part that made me unhappy is, I found it could be simpler and more beautiful in ClojureScript. While Redux comes with some concepts that are stranger even than that in Elm, that’s very strange.
So some about me. I’m working in Shanghai and has worked on React for about 2 years. I used to write in CoffeeScript and for the recent months in ClojureScript. I also tried to implement things by myself, like a tiny Redux copy called actions-recorder, a tiny “redux-router”-like component called router-view, a virtual DOM based MVC library in ClojureScript called Respo. My crafts can be slower and unstable compared to the well known libraries. I worked in React long enough to know why React is great and what React is short for.
- So you want immutable data structure, fine, it’s built-in in ClojureScript.
- You want that every thing is an expression so you may use “if” and “switch” directly without introducing “a?b:c” or “return”, fine, that’s ClojureScript.
- You want an emitter so than the library knows the updates in the store, okay, it’s what “Atom” does in ClojureScript.
- You don’t like to always bind “this”, that’s good, “this” does not exists in daily ClojureScript code.
All above. I just turned them into list for looking up.
The part that is good is not original, and the part that is original is not good.
Let me go back to Redux. Redux is almost the same when compare with ClojureScript. I just said as long as you get Clojure, you can by default:
- values(which is immutable)
- Atoms(already a emitter you can “add-watch”)
- pure functions to update the store(“get-in”, “update-in”, “assoc-in” are core functions here)
so you already got the pieces of Redux. It can be quite cheap as I can see, why is that so expansive in Redux? We need “reducer”, “combineReducer”, “Provider”, “middleware”. That’s complicated.
As I said I’m not saying it’s bad, but it’s overwhelmed. And I don’t believe that the complexity of Redux is just fine, it’s too much. That’ all I want to say and enough to push me to Clojure side.