Fusor vs React
My job is to write code in React. Even though I like React, when developing with it I encountered some of its shortcomings. In this regard, I decided to create my own library, Fusor, to correct these shortcomings and this is what came out of it.
Found one fatal flaw and decided to make my own with blackjack…
I don’t like unnecessary conversations, so I’ll move closer to the body of our experimental subjects.
Divide and rule
It is also the single-responsibility principle from one “little-known” methodology – SOLID.
It is also the principle of separation of concerns.
ROUND 1, FIGHT!
Area of responsibility | Fusor | React |
---|---|---|
Creating a Component | create() | create_update() |
State change | state = x | setState(x); create_update() |
Component update | update() | setState(x); create_update() |
This is pseudo code
As you can see, React didn’t do well with separation.
“Well, so what?” – you say.
But the fact that…
There are problems
ROUND 2, FIGHT!
Area of responsibility | Fusor | React |
---|---|---|
Component data | Created once | Recreated for every sneeze/update |
Side effects | Change data and update | Complex and verbose logic hooks |
Update | Where and when needed | Not obvious and heavy |
Context | Not needed | Needed |
Size | ~2kB | ~44kB |
This is what happens if you don’t follow the basic principles of programming. It’s not for nothing that he is in first place in SOLID.
“But thanks to this ‘heavyweight’, life is easier for us developers, right?”
.
.
.
No.
Talk less, work more
ROUND 3, FIGHT!
In my opinion, the result is obvious. React is more verbose than Fusor.
useCallback
in this simple example because, in Fusor, the click handler does not change its pointer either.
Bottom line
React is more complex and heavier than Fusor.
“But React is used by millions of developers and tons of libraries have already been written for it.”
Yes, but before React, gazillions of developers used and wrote libraries in JQuery, and before it they generally generated pages in PHP. Time passes, the world changes.
“What, should we relearn now?”
No. If you know React, then you already know Fusor, and a bunch of extra concepts from React.
That’s all I wanted to say.
Link to Fusor repository: https://github.com/fusorjs/dom
Thank you all for your attention!
Goodbye!