Hacker News new | ask | show | jobs
by rich-and-poor 2945 days ago
Oh Brad, you do not know what you are talking about right off the bat. Let's go through your list.

1. Every document has a root node. <div id='app' /> is your root node now. You had a root node before, you have a root node now.

2. Do a search and replace. That's easy.

3. That's another search and replace.

4. You don't need to call a constructor, you don't need to use bind, and you don't need to assign your functions to an variable on your class instance.

React allows you to compose things. Make something once and use it everywhere. You write much, much less code. You get lifecycle hooks for when things mount, update, unmount. You get easy templating in JSX. You can also ditch the whole thing for Inferno if you care about having no lisence or company behind it.

You also get amazing libraries for state management and async via reactivex.

2 comments

I like Brad's articles, but recently it has seemed like he has struggled to migrate on React, and some recent articles have just been trying to criticise React but with bad (or false) arguments, which makes it appear just him trying to justify himself not being able to wrap his head around.

React is great, mostly for bigger web apps that do need a framework and more structure, such as an SPA with multiple team members working on it.

Just like jQuery is great to do some quick and simple dom manipulation.

I've tried both opposites; I've been on teams working on large apps in jQuery, and it's hell. And I've also used React to implement simple little things, and it's also hell (part of it for reasons Brad mentions in this article).

I don't have much experience with Vuejs but I've been using it instead of React recently, and it's refreshing indeed. Just like jQuery you can just import it with a script tag and start doing some dom manipulation and it makes the code much cleaner than jQuery.

And as others have said, jQuery is not bad - it's awesome. I guess it didn't age very well with the JS env evolving, but it's great.

>React is great, mostly for bigger web apps that do need a framework and more structure, such as an SPA with multiple team members working on it.

I'd argue this is bad advice. What constitutes a 'bigger' project us arbitrary, and once you build your whole app on jQuery it's expensive to migrate to React once you get just a bit 'bigger'.

Now whether or not all websites need to be React-based SPAs is a different question entirely.

yeah you are right about the cost of migrating, I've been through one and it's indeed to be avoided.

I badly used "bigger". What I meant was more in the lines of React is great to build what we could call web apps - something with complex logic, etc. While jQuery is better for simple DOM manipulation.

Maybe a good line is, as soon as you find yourself manipulating data you might want to think about using a framework such as React.

You also get convention. jQuery didn't offer much of that once you started gluing its functions together...

I can usually jump into someone's react code and get what's going on pretty quickly unless they did something really gnarly with incredibly nested props. Even then, at least I still know where to drill down. With jQuery soup, you didn't get that luxury.

Being able to have an entire team know how to build components and provide them with functionality is an incredible advantage. I don't love everything about react either, but the ecosystem, somewhat enforced convention, tooling, etc - it's worth it (so far).

I love some things about Vue, but it isn't a silver bullet either. Brad seems to be pretty butt hurt about react. If you've worked on a large team without something like react, then worked on one with react, it really shines. It's a major productivity booster.

It's not perfect, but it's very good.

jQuery had a lot of convention, for both it and it's plugins.

jQuery + co. have very consistent "look and feel"

I agree when you’re talking about the most well known of plugins and so on, but IME for application code all that goes out the window. A lot of developers really didn’t know how to write JavaScript back then. Still don’t, but we didn’t then either ;)
I agree that the library has great convention. I actually learned quite a bit from that API when I was starting out. The only problem was you could really abuse the usage of the API.

I'm realizing now that this isn't a fair comparison. React 'wins' here largely because it has a smaller scope. It's for giving functionality to templates built in the library using a certain approach. jQuery was far more open ended and far less opinionated. That was as much it's strength as it's weakness.

It's definitely not a direct comparison. But I do think react is a nice safe tool for larger teams.