I keep thinking of switching to React but then I hold back because I keep seeing posts like this.
These were the biggest takeaways from this post for me:
However, the difference between my code and React is that I don’t have HTML in my JS files, I leave that in the views. I mean, I really wonder, how do frontend devs cope with React files? If I were a frontend dev and I needed to update the HTML, I sure wouldn’t want to wade through the tree of JS files just to figure out which file to edit.
And is React really that strict? If it forces you to have tiny component files where every dynamic element needs to have its own component class, then I can totally understand how that would be a pain. I have found that sometimes this doesn’t need to be the case – sometimes it makes more sense for a component class to refer and add behavior to other elements inside of it without those elements being explicit components. This kind of code may get refactored out later, but having that option is nice.
I can confirm that two-way data flow code sometimes is not as clean to read, but most of these fears are mixed with overall pain about Angular 1 where two-way binding was bad, and still.. probably it was not the biggest fail even there.
That’s an interesting argument, and I’ve actually never heard anyone make it before, but I think it dovetails with some of the feelings I’ve had about React in the past. Honestly, the first time I read about Flux (or any of its interpretations, such as Redux), it seemed like it was a solution in search of a problem. When I used Angular 1, I definitely encountered problems with two-way binding, so I understand at least on the surface why a one-way flow is in theory better. However, now that I think about it, my problems were with Angular, not with the idea of two-way binding: I was trying to do something fancy with watches, and it backfired on me. So I can’t help but think, if two-way binding had been simplified so that I couldn’t have shot myself in the foot, wouldn’t that have been better than overhauling the ENTIRE app flow?
Vue.js may be very nice, but this article is uninformed FUD about React.js and JSX.
If it forces you to have tiny component files where every dynamic element needs to have its own component class, then I can totally understand how that would be a pain.
It does not force you to do this. At all. I’ve worked on a few large React.js projects with a bunch of developers of varying skills and everybody finds their own balance for component size, but my advice is as follows: Break components up in to large natural pieces, use local variables to build up little state-free fragments in one large render method. Over time, refactor those things in to methods or components as needed for parameterization, reuse, or performance.
if two-way binding had been simplified so that I couldn’t have shot myself in the foot
Two-way binding is a generally bad idea. I’ve written about the fundamental problem here: http://www.brandonbloom.name/blog/2015/04/26/rarely-reversible/
Cool, I appreciate the clarifications.
I don’t know if the post you mentioned helped me to understand why two-way bindings are necessarily a bad idea. Can you expound on this? Specifically, 1) what is “reversibility” mean in this context and 2) what do two-way bindings have to do with it?
My frustration with two-way bindings is that it leads to everything poking everything.
How easy is it to track a bug to its source? With a clear hierarchy and direction I find it to be pretty straightforward. When it is two-way I find it to be much more complex.
I used “reversibility” to avoid having to talk about the finer points of functional inverses. I’m saying that if you have f(data) -> view, there’s no way to get g(view) -> data without a very complex set of rules or a overly simplistic one-to-one mapping of data == view. The former is an open research problem and is unlikely to produce a simple solution. The latter just shuffles the problem to somewhere else: “Hey, I have data-binding of this data and this view… but how how do I get that data to data bind?” - You always need a function without a good inverse somewhere.
There’s a lot to unpack here. I’ll run through some of the more egregious points.
This claim is followed by a link to an official blog post which suggests avoiding certain patterns.
That’s it. That’s too much ‘ideology’ baked into the framework. Nevermind that those patterns can be used (and will continue to work indefinitely)
This is not examining technology on its merits - it is looking for excuses to support a conclusion.
Here we get a flat assertion about readability. It’s neither actionable or falsifiable; no justification is provided for the claim.
The difference between ‘unfamiliar’ and ‘difficult’ appears to be lost on the author.
As evidence that it’s hard to read, the author posts an example in JSX. No vue.js equivalent is posted for comparison, and the JSX form provided makes some odd decisions about which readability features to include/exclude (I’d have used whitespace quite differently and destructured the arguments).
It’s possible that Vue is the better tool, but the line of reasoning (if it could be called that) followed in this post is no way to make a decision.
It’s an opinion piece, it doesn’t need to have any sort of great comparison between them. “Why we chose Vue.js over React” can simply come down to “we just like it more” and that’s fine.
I don’t think anything is egregious in it.
The only way that first statement could be a reason is essentially, I don’t know functional style and I can’t be arsed to learn it or its benefits. shrugs