ANGULAR 2
VS
REACT
ANGULAR 2
VS
REACT
Angular 2
Thoughts on selecting a JavaScript stack in a .NET shop.
React
Michael K Snead
React.js
Angular 2
We'll compare developing applications "with React" vs. "in Angular 2".
React.js
Angular 2
Everything (obviously) desugars/compiles down to JavaScript.
Angular 2
Facebook created their own type checking system called "Flow".
Type annotations are optional, works on today's JavaScript.
Angular 2 supports TypeScript and Dart first for development.
React
TypeScript has supported React (JSX) since VS2015 (as TSX)
Dart is a new language invented by and widely adopted internally by Google.
Google featured Telerik's NativeScript on the AngularJS blog. You can use Telerik's native UI components with Angular2 classes.
NativeScript is not specific to Angular 2
(it's been out since 2014)
Facebook uses their own React Native framework in-house. Native components on the target framework (ie: iOS/Android) have counterparts in the React Native framework.
React Native currently runs in production.
Copy/Pasta Spaghetti Coding
Results when searching for these terms
Copy/Pasta Spaghetti Coding
Results when searching for these terms
Survey 2016
Survey 2016
Survey 2016
Visual Studio 2015 introduced JSX support last year.
WebStorm has supported JSX since 10/14 (2 years).
VSCode has full support for JSX since adopting project "Salsa".
React
Visual Studio 2015 and VSCode have experimental support for Angular 2 TypeScript as of today.
Visual Studio does not understand decorators in JS.
WebStorm appears to have good support for Angular 2 in TypeScript or in ES.
Angular2
Angular2
Rangle.io is partnering with the AngularJS core team to develop Batarangle Augury for Chrome!
You can tell things are still churning since Augury has a "supported version" note on the repo.
React
The React Developer Tools are available for native, both Chrome and Firefox, developed by Facebook.
Also, it may be noted that Redux DevTools are written in React and their are React-Perf-Tools.
In January, Telerik announced a roadmap where they would be creating components native to React and Angular 2 in parallel.
This is a complete rewrite.
As these components still aren't ready, you can still use Kendo if you use a wrapper library.
In both cases you'll have a much better experience long-term if you get comfortable with...
"Getting Started"
Angular2's "Getting Started" recipe includes ...
Angular2 also provides a pre-built "sfx" package for ES5 development.
For production (performance) builds you will need jspm or webpack.
For typescript, you will need the above + "typings" and the typescript compiler.
"Getting Started"
React's recipe includes ...
Facebook also provides ReactJS.NET, allowing Visual Studio/C# developers to skip the build/transpile step and to perform server rendering right from Razor.
For a complete SPA, you'll probably want to add ...
Can we compare speed?
Most benchmarks have bias and subjectivity. It's hard to get a good, scientific benchmark.
With that said, here's my biased "Hello, world" sample!
All assets loaded from disk, using Chrome 47's "Timeline" tool.
Uses Google's minified copies of Angular2 and only the required shims for Chrome.
A2
React
Fails at compile-time.
Line number provided.
Unclosed tag mentioned.
Fails at runtime.
No line number provided.
No unclosed tag mentioned.
"In React, you don’t learn framework-specific HTML shims like ngWhatever. You spend your time writing plain ‘ol JavaScript. That’s the future I believe in."
- Cory House
Presenter on PluralSight
In a comparison on January 3rd...
Angular 2
Angular 2
Template Engine
Dependency Injection
Angular 2 HTTP
Fetch, jQuery, etc.
(AJAX)
Rx.js, Redux, etc
(State / Flow)
Angular 2 Router
(Routing)
Validation
FormBuilder, Validators, Control, ControlGroup
React
View Library
Fetch, jQuery, etc.
(AJAX)
Flux, Redux, etc
(State / Flow)
React Router
(Routing)
React
Validation
My preference?
Roll your own.
Because drag and drop is hard.
Angular2's ecosystem continues to mature, but is still very young. You will run into immature components and bleeding edge issues. React's ecosystem has had years to mature.
js.coach
react-widgets
Facebook's list
StackOverflow
"We love React at Paypal"
"Our decision to adopt React was influenced by a number of factors, most notably:
1) startup speed,
2) runtime performance
3) modularity"
"React stood out in that its defining features not only satisfied the criteria set forth above, but offered advantages including being relatively easy to grasp and ability to opt-out."
The company behind the most popular open source project in the world, the WordPress CMS.
75m sites and 48% of Technorati's Top 100 blogs are WP sites
(in 2/2015)
Originally written with LAMP, Automattic recently released their latest version, codenamed "Calypso": a top down re-write using Node.js to serve a React/flux frontend.
"React has many benefits and it's probably the future of web development..."
Facebook eats its own dogfood.
React is live and in production on 3 of the Internet's most heavily used properties owned by the devs of React (Facebook, Instagram, and WhatsApp).
Since Angular2 just hit beta in December of last year, it's hard to say who is (will be?) using it. I've read that Google is using it internally for some of their projects, but not the ones you would think...
There is a neat "built with Angular 2" twitter feed...
IE8 has enjoyed support from React since the beginning. This just ended with the release of v15. React is designed to work in all popular browsers.
Angular2 takes a different approach, starting with only the latest, modern technology and then shimming/shivving for browsers (there are no browsers today that can run Angular out of the box without shims).
As with any well-architected UI application, you'll want to keep as much logic as possible out of your UI components to get maximum testability.
React
Angular2
Since React is unopinionated about modularity, you can expect adding most libraries and plugins to work much the same as you would jQuery or Kendo. Drop in and go.
You can also use ES6 import syntax with React.
With Angular2, you need to examine the build system and language used by the library implementor.
For example, webpack vs jspm, TypeScript vs ES-next.
JSX is not HTML. There is no string markup in your JSX.
There are a few things learn, like...
It's easy to convert between JSX/HTML with online and offline tools.
Like Angular 1, Angular 2 has its own DSL for templates.
Some examples:
I really like a library or framework that...
REACT
WINS
REACT
WINS
Questions? Thanks for your time.
Go do your own research!
Angular2 may be something someday, but I need to be productive now.
Links