Click here to Skip to main content
15,887,596 members
Articles / All Topics

Why React? Why not Angular 2?

Rate me:
Please Sign up or sign in to vote.
3.00/5 (5 votes)
3 May 2016CPOL3 min read 8.2K   1   2
Why React? Why not Angular 2?

As Angular 1.x gets older and Angular 2 picks up steam, many 1.x developers are wondering what to do next. Should you pick Angular 2? Maybe React? Something else?

I’ve also gotten some questions from readers recently about why I’ve been starting to write about React instead of Angular 2.

Why React over Angular 2? Well, I started off with Angular 2 as it seemed like the logical progression from 1.x.

Right away, it seemed very complicated to write. There’s a lot of ceremony: import the module, then put it in the providers array, then inject it into the constructor, then assign it to an instance variable.

That’s 4 times typing the same name before I can even use it for anything.

YO DAWG

Oh and one more place: when you bootstrap the app, you have to give it a list of providers for things you’ll want to inject later. It’s one more thing to remember, and one more thing that can cause your app to error out.

I’m not a huge fan of TypeScript and static typing generally. It has some benefits, sure – better IDE integration, better autocomplete, and better assurance you didn’t make any typos…

But I don’t want to wrap every class in an interface so that I can subclass that interface with a mock instance so that I can write my unit tests. I don’t think that leads to better design or more maintainable code, just more code.

Part of the power of JS is the loose nature of it, and I actually enjoy that part of it :) I know the community is divided on this point: half of the people reading this are probably nodding along, and the other half probably think I’m insane (“JS is awful! TypeScript turns it into a proper language!”).

Officially, you can write Angular 2 in JS, and it works, but there’s not much support yet. I think most people will go with TypeScript, and writing in JS will be an uphill battle every time something breaks, because there won’t be many Stack Overflow questions or other community support.

So if you put a gun to my head and made me choose right now… my preference right now is for React. It’s simpler to write (at least, plain React), and easier to figure out what your code is going to do when you write it. You need to learn JSX, but after that, it’s basically just JavaScript.

Redux adds quite a bit more complexity, more to learn, and more decisions to make. But even still, it’s possible to understand what the library is doing behind the scenes, once you understand the concepts.

With Angular 1, it felt like the rabbit hole always went deeper. The more I learned, the more there was to learn. Compiling elements by hand, intercepting the digest cycle, and learning all these Angular internals… React doesn’t feel that way – the abstractions are much cleaner.

With Angular 2, I’m a bit worried that there’ll be even more (and more complicated) internals to learn. Or at least, relearn.

In any case, that’s where my head is at right now. What do you think? Which would you choose for a new project?

Leave a comment! Send an email! Let’s have a discussion about it.

Why React? Why not Angular 2? was originally published by Dave Ceddia at Angularity on April 26, 2016.

This article was originally posted at https://daveceddia.com/feed.xml

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Dave is a Software Engineer in the Boston area and writes about AngularJS and other JavaScript things over at daveceddia.com

Comments and Discussions

 
GeneralMy vote of 3 Pin
Rasoul Abbasi6-May-16 0:58
Rasoul Abbasi6-May-16 0:58 
AnswerLet's make measurements Pin
Rasoul Abbasi6-May-16 0:50
Rasoul Abbasi6-May-16 0:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.