React vs Angular: Choose wisely
It’s time to start your new project. The feeling is amazing. Now you can start from scratch, try new technologies and forget about all those old things you had to support before.
The choice is not easy, there are a lot of new tools to try. And you know you need a few things for sure:
- A tool to do repetitive things for you, like compilation, transformations, linting, minification on your assets.
- A local development server with Live Reload or similar.
- A framework/library that allows you to write maintainable and clean Javascript.
The first thing you will do is research. You will find hundreds of articles telling you why one is better than the other.
You notice the last commit on the Grunt project was 5 months ago. Then you find Gulp and Webpack. Both of them have thousands of downloads and are actively maintained. You are sure you want to use the shiny ESNext features and JS modules. Webpack provides both with minimal configuration and also a server with hot reload, so we have a winner.
Then the most difficult choice: Should you use the old good jQuery? Or give Angular or React a try? You know you will have smart components that are reusable and complex, so jQuery could become a big headache because the manual DOM manipulation and imperative programming style when the project grows. Here is where we end up with our 2 friends: Angular and React.
Researching about this topic it’s not easy. Both of them look good, they have features that will help you to accomplish the project requirements in an efficient way, they are created by some of the best developers in the world and both are supported by HUGE companies. How would you make a good choice based on your requirements?
Get José Pablo Granados’s stories in your inbox
Join Medium for free to get updates from this writer.
That was the problem I had a few weeks ago when started a project and had to decide between the two. At that moment, I would love to find an article talking about the differences in a more clear way.
Angular
Angular is a complete Javascript Framework created by Google. Its core was created using Typescript from Microsoft. It recently released the final version after being in beta for some months. It comes with a lot of awesome features:
- You can create reusable components very easily having data binding between your HTML template and your JS logic.
- Typescript as JS superset allows to use the most recent features and compile down to ES5. It also provides static typing and real time syntax checker in you favorite text editor or IDE.
- Provides an HTTP module to handle web services integration and ajax requests in a clear and smart way.
- You can use promises or streams with Reactive Extensions(rx.js) to manage your async data in a more powerful way than before.
- It comes with an awesome router so that you can create your entire single page application with it.
- It has some old concepts from Angular.js that will result familiar to you.
- You can use state containers like Redux in Angular with some configuration.
- Server side rendering is supported using Angular Universal.
Based on the above the framework sounds great, but it has some downsides:
- Even if you are very good with JS the learning curve is big, you need to learn a lot of new things about framework to work with it.
- The configuration with a module bundler like Webpack or Rollup is very hard.
- The size of the framework is almost 1MB, you can integrate tree shaking to remove the unused pieces of the framework, but the configuration process is time consuming and hard.
- For production is recommendable to enable Ahead of time compilation which is a way to compile Angular in a smarter way and make it faster. This is hard to configure as well.
React
React is a UI library created by Facebook. It has been around for a while and it have had a very good acceptance by developers around the world because its simplicity and power. It provides:
- An easy way to create reusable components in your page.
- The configuration is small and easy to follow.
- You can integrate it easily with Webpack and Babel to get all the ESNext features you need.
- It has JSX built-in which is a very nice way to create your HTML in Javascript.
- The great React router can be added so you can manage routes and create entire single page applications with it.
- Redux can be added for more complex projects, so that you can have better state management.
- You can use Typescript, and Rx.js with React if you wish.
- The learning curve is very small. The more you know about JS, the more you know about React. The library specific things are just a few.
- Server side rendering is supported using ReactDom Server.
The downside of it could be a good point too, depending on the context. You start with the basics and add features as you need. For some projects this save time, removes extra configuration and size in the final bundle.
The differences to help you making the choice
As you can see there is no clear winner. Everything depends on your needs. But there are a few differences that will help you to choose the best tool for your project.
The built-in features you need
Angular is a complete framework that comes with a lot of features out of the box. This will save you time if you need them all.
React is just an UI library that can be extended to do the same Angular does, but you will need to add features as needed.
This is a huge deal breaker depending on the project requirements. It will save you time and boost your productivity.
The flexibility of the tool
Angular is a complete framework that work best for Single Page applications. It uses a parent root component and it creates your application inside of it. This is something very important to understand, in special if you are dealing with a website that needs to mix static content with dynamic components that needs to be reused. I do not recommend to use it if your website is not a SPA or you don’t need most of the features that it provides built-in.
React is much smaller UI library and can be used without restrictions in standard websites for a few components or create entire Single Page applications with it.
Conclusion
Angular and React are awesome tools that can help a lot during your development process and will make you a happier developer. Avoid doing extra work and many headaches by just taking a pause analyzing which tool will fit your time and needs.
For standard websites with some dynamic components use React.
For Single Page apps with Typescript and Observables built-in use Angular.
For Single Page apps with JSX and ESNext features use React.
I recommend this read from Eric Elliott which provides more deeply details about this topic https://medium.com/javascript-scene/angular-2-vs-react-the-ultimate-dance-off-60e7dfbc379c#.ia3t1x23j
Feel free to leave some comments.








