Why Angular? Why Not React?


A very common question. Let's search its answer.

Instead of following market trends, always choose the best technology stack based on your project requirements and business needs.

Lets discuss, why Angular and why not react.

Why Angular?

  • If you are already familiar with OOPs or you have C# / Java background and know dependency injection then the learning curve is comparatively low.
  • If your application has not a dynamic UI i.e. forms are predefined and could not change at runtime.
  • Angular is a full-fledge framework to create enterprise business applications.
  • 70% same code for Mobile App i.e. Only Html & CSS files would be separated for Web and Mobile apps and some specific modules (Using NativeScript)
  • Good separation between logic, markup, styles.
  • NgModule, Modularize approach which organize the architecture of app in a better way.
  • HttpClient Angular Module. Supports custom headers, request type, automatically parses JSON, can be streamed, piped, debounced, retry, response can be typed, returns an Observable, can be intercept (request and response), chain-able, and transformed, has caching strategies and events. Powerful and fits any type of needs.
  • The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code. Compiling your application during the build process provides a faster rendering in the browser.
  • Why compile with AOT?
    • Faster rendering With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.
    • Fewer asynchronous requests The compiler inlines external HTML templates and CSS style sheets within the application JavaScript, eliminating separate ajax requests for those source files.
    • Smaller Angular framework download size There's no need to download the Angular compiler if the app is already compiled. The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.
    • Detect template errors earlier The AOT compiler detects and reports template binding errors during the build step before users can see them.
    • Better security AOT compiles HTML templates and components into JavaScript files long before they are served to the client. With no templates to read and no risky client-side HTML or JavaScript evaluation, there are fewer opportunities for injection attacks.

Why NOT React?

  • All in one, styles, logic, html
  • At scale complex and fussy structure, no separation of concerns, prop Types, connectors, import of CSS in JS.
  • Does not have the concept of modules.
  • A lot of community libraries to learn for HTTP Calls, Routing, etc. which increase the learning curve.
  • If views/layouts have limited user interaction or simply serve static content, then implementing and using React may be more effort than it's worth.
  • React is unopinionated — meaning that developers sometimes have too much choice. There is no ideal React application setup. Every ideal React setup is subjective to its needs of the developers and project. 
  • React doesn’t have any predefined structure. This means that structuring the app is fully the responsibility of the developer, and depends a lot on his knowledge and experience.
  • As a simple library, React leaves more space for custom cases and solutions at the cost of having developers to find and implement the best solutions. It doesn’t provide state out of the box. You have to pick one Redux, MobX, etc and add it to your application. It does not provide navigation mechanism, you have to pick one from react-router, react-navigation etc.

Remember, both Angular and React are not comparable as they both have almost same Pros and Cons. Which is better for you is all depends on your project requirements and business needs. So, instead of searching Pros and Cons of Angular and React, its more beneficial for you to analyse your projects requirements in more detail so that you can choose a better technology for your project.

Note: I collect these points based on our own project requirements and business needs.

Comments

Popular posts from this blog

Data Bound Controls in ASP.Net - Part 4 (FormView and DetailsView controls)

ASP.net: HttpHandlers

The Clickjacking attack and X-Frame-Options