Which one is better Angular or React JS?

Programming Answer

Click here to type your answer

Safarov answered

Angular and React are the most popular tools to develop Javascript applications nowadays.

Actually I have far more Angular experience, for me Angular is a clear winner. Maybe someone with more deep knowledge in both frameworks can give a better answer. Also here I compare React JS to latest Angular 4/5. Anyway I will try my best.

So What's React. It's basically library to make encapsulated components in Javascript. You can manage states of components using dynamic properties. Also data is stored in Virtual DOM, then React renders html elements when data is changed. Each component is completely independent - I guess this made to make it reusable.

What I don't like in React JS ?

1. You need to have render functions to html code. I personally like clear separation of html and javascript.

2. React doesn't have routers built in - you have to add another library to enable it. There are a lot of useful features missing in React. I understand it's not a framework, but as i am mostly developing Single Page Applications it's easier to work with Angular.

3. You don't have powerfull CLI what you have in Angular. Yes you can create new project easily, but you can't add services / components as easily as in Angular CLI. Also each time you have to import all of those components manually in React.

4. There isn't ngFor in React. I know you can use map in React. For me, map looks like hacking into core code and makes code less readable.

5. We have better constructor in Angular than in React. In React we have to call super() function inside constructor even if we don't use properties of extended component. In Angular we inject dependancies like services, route to constructor which makes more sense.

6. We don't have decorators in core React JS like we have in Angular: @Component, @ViewChild, @Input ..etc. I used to work with Java Spring framework, we have similar decorators there, that's why I personally find them more readable.

7. We write normal html elements in Angular, but we are writing Virtual DOM elements in React JS. There can be 2 issues with that. First one, think about following scenario - you have old codebase written in React JS in 2017, but in 2019 there comes new html6 specifications (let's just assume). You can't use them, you will wait untill React developers release new React-Dom version, then you will need to update project to newer version, fix bugs, then you can use new Virtual Dom elements. But in Angular you just writing normal html elements and it works. Second issue is some Code Editors doesn't recognise those virtual elements as html and doesn't give you code completion.

8. Binding with React Js is a nightmare, every time have click event you will have to bind "this" to get it working with system. Similarly you will need to pass props and other values to functions through binding. Basically state managment is done manually done by you in ReactJS. In Angular you have proper state managment and your html template is aware of all properties component class has.

9. In React you don't even have the most simple features like http calls. You will need to use external library like Jquery for that. In Angular you have all you need for SPA - you don't need to import any external library for basic stuff.

Where React JS might be better than Angular?

1. There are some benchmarks that conclude React JS runs faster than Angular. It might be the case, because React it's a framework as Angular, if you compare core library without extra features (Angular have), then you have faster code.

2. Virtual Dom makes React run faster, but please check 7th point why I wouldn't want to use it.

3. It's easier to pass data between components in React than in Angular. React is built around components, it's plus for React, but on the other hand React doesn't have application state, people use Redux for that.

Despite the fact React now loses game, Angular learn't from React JS. For example, Angular copied component based structure from React starting from AngularJS 1.5.

0 points