Codementor Events

Why React.js Trumps Angular 2 (and 1)

Published Mar 23, 2017
Why React.js Trumps Angular 2 (and 1)

I remember coding with Angular 1 back in 2013 or thereabouts. Using Angular 1 directives was pretty remarkable at the time. Angular had bold promises about enhancing HTML with custom elements, and a whole lot more.

Then, you had to deal with transclusion, dependency injection, factory services, and a whole bunch of other mumbo-jumbo.

It was hard to see how all that chicanery made you more productive. On mobile, frameworks like Ionic Framework and a handful of others made the slog worthwhile. There were few alternatives at the time that came with a powerful backer like Google. Everyone was jumping on the Angular bandwagon, including Firebase and just about any serious JavaScript vendor with a mission to boogey.

So, About That New JavaScript Framework…

In a little corner far away, the Ember kids were grokking that. When they tried to come out from their little corner, the smoke from all the Angular directives and transclusions was enough to drive them back away into their little cave once again.

They were right, of course, duh! It was just that, in that Brave New World, it was easy to mistake factories and snake-oil for productivity. And StackOverflow had not even made it to the promised land! They were still using jQuery, ha! (And doing it very productively, I and a million programmers must add!)

If you were really brave, you could always go nuclear and use Backbone, but among its few faults, hype was never one of Backbone's weaknesses. Everybody, more or less, quickly clambered the Ember train or the shiny new Angular “bullet” train and failed to see the value of simplicity, which was core to Backbone.

Until months later, when you were slogging through a ton of abstractions that barely made sense. Productivity ground to a halt. An old boss of mine seemed skeptical of Angular’s benefits, and in retrospect, one had to be skeptical of Angular’s cost. It seemed that the Angular engineers had brought the worst ideas and “patterns” and antipatterns from .NET and Java and somehow transmogrified JavaScript into the worst incarnation of old EJBs. So much for experience! Barebones jQuery had to be better than that mess.

Let’s Start From Scratch

Then React came along and was bold enough to actually throw all that gunk away. Few of us thought so, of course, at first. The Angular love was just too fresh, the dream of the promised land too vividly etched in our programmatic minds, the high priests of Dependency Injection too ensconced in their Olympian perch in Mountain View that few even noticed the tremendous change that had occurred overnight.

A bunch of crazy upstarts had dared to challenge the Emperor in his own backyard. And when you looked at it carefully, they had won!

Good riddance, I thought, when I finally learned React. No more transclusion, controllers, factory this 'n' that, all the weirdness and un-JavaScript-like declarations and code repetition. No more boilerplate and spaghetti.

React was simpler, and made plain sense. Why had somebody not thought of this before?

We could now go back to writing straight-up JavaScript like we were back in Backbone.js! But not quite.

React still came with some conceptual overhead, and some rather inelegant semantics. Wrapping your head around JSX was like trying to switch from a QWERTY keyboard to using the OODAA keyboard, like, “what exactly did you say we now need to do with our HTML”?

Still, after the disillusionment of those crazy Angular days, anything had to be better. And it was fast! Shadow DOM! Functional, stateless components! And Atom could understand it!

Then along came React Native, and for me that was really the game-changer. Mobile, the only thing keeping me in Angular, was gone. React Native was even better than anything that could challenge it. It still had bugs and had not even reached release, but in time it would just be better than any non-native solution. Angular was dead! Game over.

The Matrix Reloaded

Demon_Orc_army.jpg
The Return of Angular

So, fast-forward and the Angular chefs went back into the kitchen, and swiped some good ideas from React, Ember, Backbone, and everyone else, as best as one can see, and went at it again.

Out came Angular 2, like Saruman’s NEW and IMPROVED Uruk-hai, marching across Middle Earth to take over JavaScript everywhere!

And I kinda liked it. The components are nice, the directives, where you use them, seem to have been simplified, no more controllers and crazy patterns (unless you happen to live for that stuff). It actually runs faster, uses ideas from the shadow DOM, and dared to rethink its own idioms. I give 'em a lot of credit for that.

Mmm, I Thought We Were Here To Code JavaScript

The Angular 2 experience and productivity is much nicer than before, I have to say. However, I wish they had not made everyone learn TypeScript.

And no, TypeScript is not necessary, in my opinion. I fall much more on the CoffeeScript side myself. And I think ES6 and future versions of JavaScript do too. TypeScript is somewhat of a mess. It’s not a zero-cost super-set around JavaScript. It can slow you down considerably. And its benefits can be extracted much more painlessly with something like Facebook’s Flow and similar systems. Having a good linter and JavaScript style guide for your team can keep you fairly safe. And you can use something like Mocha to run tests that keep your code pretty safe.

So, this whole Angular 2 craze? I just don’t see it folks. And I promise you, I'm not the only one. I’m here to anoint the new king, and React.js it is!

React has spawned off really good side-effects like Riot.js, which in turn inspired Vue.js, and then you have MobX, Redux and a bunch of reactive libraries that have all kinda emerged out of this innovation.

What’s not to like? You don’t need Angular 2 or 1 for that matter. Grok straight-up JavaScript, not some pretentious static monster, and pick React, Vue, Backbone or Riot.js. Even Ember will be a solid alternative. Either way, you run a leaner, faster, more productive, more elegant system, or any subset of those four. Your team will thank you for it!


About the Author

Tendai Mutunhire is a startup React and Node.js developer. He may be found at TowersOfZeyron and hacking on startups like NomadHideout and UnicornPoach.

This post was originally posted here. This version has been edited for clarity and may appear different from the original post.

Discover and read more posts from Tendai Mutunhire
get started
post comments3Replies
Girish Thanki
8 years ago

Coming from a desktop background, I really see no issues with typescript (once you are use to it, its like wearing clothes it makes sense and will protect you from the cold - with React you might be flexible free and wild - it won’t be enough on the really large teams/Projects and will catch a ton of coding issues)

frank cooke
8 years ago

Honestly, there really isn’t much here to validate your claim. Just sharing your opinion without proper validation makes you one of many js library/framework fanboys. The thing is, I appreciate both tools. They both do what they do well. The only thing that a good engineer (especially a js engineer) should be prepared for is change.

MC
8 years ago

React.js looks awesome! Any concerns regarding React.js being licensed under BSD instead of MIT? Would big companies hesitate at committing to React for legal reasons?