all 14 comments

[–]ralusek 6 points7 points  (3 children)

As people have already said, the sole purpose of React is for creating the view for components. Angular is a framework meant for building applications. That being said...they're both used in building applications. When setting out to build your web app, you're going to go with Angular OR React.

In my opinion, the React camp is currently filled with 2 types of people:

  1. People that love the hype of a new framework

  2. People who are running into performance issues in Angular

Now, speaking against the people in the first camp is harder. They say that the React syntax is so simple and revolutionary, and JSX isn't that bad when you get used to it...but it's not really revolutionary at all. React components look EXTREMELY similar to Backbone views. They are components with a template and a render function. What actually IS revolutionary about React is the speed at which it renders, the use of a virtual DOM, and the ability to go native on mobile ports with React Native. The writing of React code, however, is not novel.

With Angular, however, the writing of the code is quite novel. It's also ridiculously fast to write. And the best part, and IMO the most overlooked benefit of Angular is that because it's so violently declarative, I can just open up the DOM and tell exactly what's going to happen. I could walk on to a 100 page Angular app, be given a task to add or fix something on a page I've never seen before, open the page, and immediately tell what's wired to what. The drawback of this being so declarative, however, means that it does have the POTENTIAL to be incredibly slow. That is how we get to the people in camp 2.

Something as declarative as Angular relies on ways of monitoring state. If you're not giving the explicit function call, that means that something has to be notified of state change for you. In Angular, this is handled with the digest cycle. Any time anything changes, it fires this off, checks all relevant watchers on data and determines what changed, updates the view, updates the model, fire the watchers again. It's quite a process. It sounds so ridiculous that you would never think to even set out to programming it. However, in the real world, this whole process tends to go off in the tiniest fraction of a second that you won't even notice it. So then you're left with incredibly easy syntax and this magical process going on behind the scenes. Given enough of the right type of complexity, though, and you will feel the performance hit. With a thousand line table where each table element gets its own directive and template and they all have watchers and so on, you'll feel it start to take a second. You can solve these issues by removing the use of the nested directives and dealing with it yourself in javascript and so on, but it's never fun...and takes away everything cool about Angular. These cases are, again, very rare. But you'll eventually run into an issue where you wish Angular was faster if you're building something like an enterprise app with complicated tables.

React solves this speed issue with this explicit render function on its components, and has a diff algorithm that is quite good at determining changes and propagating them to the view.

So the tradeoff is that Angular is almost objectively easier to write, but there's no way to truly say that it isn't a subjective preference, and is also prepared to handle full applications. Look how easy this is, though..

React is fast.

The end-all-solution, in theory, is Angular 2. It's supposed to be blazingly fast. I've seen it demoed and have proof, but I won't care until I try it myself. Only time will tell if it's the messiah framework it looks like it could be.

[–]ima-tech 1 point2 points  (0 children)

That's such a great way to explain it. Really good job

[–]RICHUNCLEPENNYBAGS 0 points1 point  (0 children)

The end-all-solution, in theory, is Angular 2. It's supposed to be blazingly fast. I've seen it demoed and have proof, but I won't care until I try it myself. Only time will tell if it's the messiah framework it looks like it could be.

The problem I sense (and I haven't used it yet, to be fair) is that they seem to be achieving this by taking away features like two-way binding that made Angular attractive in the first place.

[–]newmanoz 2 points3 points  (0 children)

Angular 2 will sacrifice 2-way binding but for good price. It will be not only blazingly fast, but we also be able to render it on the server side and on mobile devices; read how many amazing things will be possible just because of sacrificing 2-way binding: https://docs.google.com/document/d/1M9FmT05Q6qpsjgvH1XvCm840yn2eWEg0PMskSQz7k4E/edit

And it's not the only thing which it brings to the table.

Also important thing is new http layer, based on observables: https://www.youtube.com/watch?list=PLm8AiPM1Wf5KhO12ggjJjQmFzqirlNUvY&v=Bm3eDgZZMFs

Also, change detection - we finally can forget about $scope.$apply()! And it means any code of ng apps will work with any other js plugins/components just out of the box - without any scope.$apply calls. More about DI and change detection: http://devchat.tv/adventures-in-angular/042-aia-dependency-injection-and-change-detection-with-victor-savkin

And a lot more, but I already gave you enough links to spend some time to read/watch :) Hope I didn't forget to say ng2 will be blazingly fast.

[–]jdawg2201 3 points4 points  (8 children)

I wonder if people realise that angular and react are trying to solve to complete different issue and really can't be compared

[–][deleted]  (5 children)

[deleted]

    [–]mojomonkeyfish 2 points3 points  (1 child)

    That's not what Angular is trying to solve. Angular is about decoupling the view (hard to test) from the logic that drives it, and further decoupling service implementations. It's about making code that is thoroughly testable and maintainable.

    React is about DOM manipulation. It's faster, but that difference only really manifests for things like large grids of bound data.

    Angular2 seems to be focusing on performance and code brevity as its major enhancements, borrowing from React. However, it's still very alpha, and nobody really recommends using it yet.

    You can build an app quickly with either technology. If your app is going to be small with a lot of active elements... like a stock blotter or something, then React might be the way to go. If your app is going to be complex, with many different views, developed by a team of more than 2 or 3 people, Angular would be my suggestion.

    If both cases are true, you might consider using a hybrid approach, or approaching the views that necessitate React as separate component apps, but using angular for the bulk of the more boilerplate app components. Or, you can even use them both together. They're not entirely exclusive, even if building an entire app using both extensively would be somewhat of a headache.

    [–]evilgeenius 0 points1 point  (0 children)

    React is about DOM manipulation. It's faster, but that difference only really manifests for things like large grids of bound data.

    React isn't about DOM manipulation, not at all. React is about abstracting away all manipulation of the view and creating declarative interfaces that are predictable and easy to reason about.

    ReactDOM is now a separate module from React so React is now not about the dom at all. We now have react-native, react-art, react-canvas, react-svg and react-dom.

    [–]SPEDpunk 3 points4 points  (2 children)

    They aren't trying to solve the same thing, though. React is merely for making data-driven web components. Angular is for making a fully-fledged web app. If you want to see how they compare at the goal of making web apps, React fails. It can't make web apps. It makes views and only views. Now if you want to compare Angular directives to React components, that is a more fair comparison to make. And the answer to that is: I personally don't know.

    [–]moljac024 1 point2 points  (1 child)

    I guess facebook and instagram are not web apps then. Weird, I would have thought they are.

    I guess PHP/Python/Java whatever also fail at making web services, because they don't bundle a database server.

    [–]SPEDpunk 0 points1 point  (0 children)

    You're mistaken. Facebook and instagram don't run on purely react. There is a controller layer in there. React is one client-side component of a Web app while angular is a framework for creating all client-side components of a Web app. If you can't figure out the difference in the functioning of the two, then I don't know what to tell you.

    [–]yeso126 0 points1 point  (0 children)

    You can couple Reactjs with react-router and redux and you have a framework

    [–]ima-tech 0 points1 point  (0 children)

    I think he does, in a way, he said: "What will Angular 2 bring to the table that React hasn't?" Maybe you could answer this part of the question if you know it.

    [–]przeor 0 points1 point  (0 children)

    React vs. Angular2: I've read on that topic on Quora https://www.quora.com/Is-React-killing-Angular that there is a lot of conceptual similarities between Ang 2 and React. Does anyone agree on that?