I recently showed the (old) React Hooks documentation to my 70-year-old mentor, a comp sci PhD who started on punch cards and never stopped. I wish I had taken a reaction video of the flabbergasted look on his face when he was reading the React docs section titled "Classes Confuse People and Machines" (https://legacy.reactjs.org/docs/hooks-intro.html#classes-con...).
Now, I like React, more or less. But some of the discussion around React reminds me of Wimp Lo from Kung Pow ("...we trained him wrong as a joke..."). For instance, the whole immutability for performance thing (I get it, but lol). Or statements like this: "[w]ith Hooks, you can extract stateful logic from a component so it can be tested independently and reused" (thank God someone finally figured out how to reuse stateful logic in software /s).
Saying hooks are less confusing than classes and understanding the weirdness of `this` is a pretty bad selling point and easily refuted. Hooks are weird. Really weird. They make all your components that use them impure which makes them harder to reason about. But hooks do compose better than classes. With classes, everything is tied to `this` which means that if you decide to reuse some stateful or effectful(?) logic somewhere, you have to disentangle it from `this` first. So on the whole, I think hooks are a win over classes. But they are weird and confusing.
I had to read the code when hooks came out, because I couldn't believe they'd done the thing that the documentation of hooks' behavior sure made it look like they'd done.
Sure enough, they had. I was left in a state somewhere between dumbfounded and amused. Reading the justifications for what they'd done just made both reactions more intense.
Yeah that's one of the biggest annoyances of the frontend community in general to me. This constant "We have to do X because Y confuses developers" uhhhhh maybe they should expand their knowledge instead of putting bumper rails on everything causing pain for everyone.
Now, I like React, more or less. But some of the discussion around React reminds me of Wimp Lo from Kung Pow ("...we trained him wrong as a joke..."). For instance, the whole immutability for performance thing (I get it, but lol). Or statements like this: "[w]ith Hooks, you can extract stateful logic from a component so it can be tested independently and reused" (thank God someone finally figured out how to reuse stateful logic in software /s).