Choosing a JavaScript Framework in 2017

Choosing a JavaScript Framework: A look at 6 popular options

Around the time I first published this I started assessing this myself. It is never an easy decision because there is so much to consider.

Rob Eisenberg is a JavaScript framework expert. He is the main man behind Caliburn.MicroDurandal and Aurelia, and has also worked on the Angular 2.0 and Angular Material teams. So his advice is well worth a listen, and a watch.

This article was originally written as a summary of Rob’s excellent talk. I still believe it is well worth spending a full hour to watch the whole talk yourself, however as time passes on there will gradually be more things moving on from the point when he gave the talk in June 2016.

I am gradually updating this article and extending this article to contain more information about other libraries and frameworks that I consider to be worthy alternatives to the shortlist that Rob selected. I also welcome you to submit your own suggestions and I will try to accommodate them if I can.

The NDC Oslo Talk

Rob introduces himself and says due to time constraints he’ll be presenting a “hello world” like example of each framework. Each app is a web component which simply shows First Name, Last Name and a computed Full Name.

First he asks you to bare in mind that:

  • He’s obviously biased, especially against Angular 2 (also bare in mind that this summary could potentially contain some other bias)
  • Don’t be swayed or swept up by hype. Be professional and choose what meets the needs of your business.

As bias is a theme here, it is only fair to discuss any possible biases I might have.

My brother is a React JS developer. I am also a guest blogger on Outlier Developer, which is run by the same guy behind React JS Consultancy. I do not currently use React JS or any of the other featured frameworks professionally.

I currently use only jQueryBootstrapWebpack and a few small libraries, which in my opinion is all you need for small projects. However I am currently working on a big project, so I need to get agreement on a suitable framework quite soon.

I am not paid to write for Outlier Developer or have any financial interests in any particular framework.

Any personal commentary on the talk is (italicized and in round brackets).

Rob believes our tendency to jump to technology choices too quickly is a systemic problem in our industry.

The frameworks under the spotlight are:

Rob says he’s trying to be as unbiased as he can be, and will cover the frameworks in alphabetical order.

He points out that they aren’t all frameworks in the same category, or even all frameworks.

Angular 1.x is an all-in-one framework. Rob says it is

pretty much deprecated, there’s literally a fixed number of months left on the lifetime of that framework

and

it’s probably fair to say that you shouldn’t start a new project in Angular JS right now, and you should be thinking about how you might migrate any existing code bases.

(I’ve never been a big Angular 1.x fan, but I feel it is only fair to point out that Angular 1.x is currently actively supported, and every framework has a number of months left in its lifetime, whatever that means.

If you are interested in using the Ionic Framework then you need to adopt Angular 1.x as well. To dismiss Angular 1.x is also to dismiss the Ionic Framework. Ionic v2 uses Angular 2. Rob doesn’t mention mobile at all in the talk.)

Rob describes Angular 2, Aurelia, Ember and Polymer as also All-in-one frameworks, but modern ones.

React is not a framework, per se. It’s a view rendering engine or a component model.

Rob says that although the demo is extremely simple, it shows the different approaches that each framework takes.

Rob recommends Visual Studio Code and is using it on his Mac. I’ve since heard Mark Rendle and others agree with this point. I have found WebStormis well worth the license fee but if you want a free solution Visual Studio Code works pretty well.

(For brevity, I’ll be referring to lines of code. Some lines of code can be much longer or shorter or more or less readable than others so to get the full picture you’ll need to watch the video for yourself. Rob has a style of leaving a blank line at the end of each file. I will discount those. The line count stats do not attempt to keep up to date with any newer versions released, only the versions at the time of the recording.)

Angular 1.x

index.html is 13 lines of code

We see the ng-controller and ng-model directives.

app.js is 8 lines of code. Rob describes this as a throwback to the previous generation of frameworks: Angular specific modules rather than ES2015 modules. He describes the Angular 1 two way data-binding model.

(As of Angular 1.5 we have Angular Components as a superior alternative to using controllers and directives. See Scott Allen’s Building Components with Angular 1.5 for more.)

Angular 2

Rob says Angular 2 really focuses on TypeScript, and

it is much more difficult to use plain JavaScript so most people are going to be kind of pushed down the TypeScript road necessarily with Angular 2

(The equivalent documentation is available for TypeScriptJavaScript and Dart. Judge for yourself how much more difficult it is to use with plain JavaScript)

index.html is 32 lines of code

(I could not believe that there isn’t a simpler way to write this in Angular 2. Rob has found some Angular 2 documentation that pulls in a whole load of modules. For the purposes of developing a hello world type app, Rob is pulling in the following modules:

There is also a bunch of code for here configuring a System JS module loader. System JS is written by Guy Bedford and Max Norlund and has nothing to do with Angular 2

Update: I have found this code is very similar to the Bill Stavroulakis “Hello Component” demo which you can find on Plnkr. Bill describes it as “a very simple Angular 2 setup”. I was very surprised to find that this simple demo won’t work at all without Rx.js. You can create “Angular 2 components” easily, but using the Web Components standard with Angular 2 appears to be a lot harder.

Bill is a fan of Polymer JS and has created several Hello Component demos available at HelloComponent.com

Please let me know if there’s an easier way to achieve this.)

main.ts — 4 lines

app.component.ts — 20 lines

Rob explains the Angular2 decorator. He uses an inline template rather than using a template URL. He also explains two-way data-binding in Angular2, and points out that Google have deviated from the HTML specification by using mixed casing.

Aurelia

index.html — 10 lines. This imports System JS and uses it to import the Aurelia bootstrapper.

app.js — 8 lines

app.html — a template with 5 lines of code. Rob explains the two way data binding mechanism used here.

Ember

index.html — 16 lines. Imports jquery, handlebars, ember and app.js

app.js — 23 lines. Rob says Ember is a very strict MVC paradigm and requires a router even for Hello World.

Polymer

index.html — 10 lines.

my-app.html — 22 lines including template, a script block and 4 blank lines.

Rob says the web components centric philosophy concerns him because

…it doesn’t make sense to do everything in HTML but there it is, that’s my opinion

(Rob could have easily put the JavaScript in a JavaScript file. Polymer doesn’t stop you from using JavaScript at all, it just provides some short-hands that can reduce the amount of JavaScript that you need to write.)

Rob likens Polymer to the long forgotten Microsoft Acropolis project from 2008 which tried to do everything in XAML.

React

index.html — 13 lines, importing es5-shimes5-sham and console-polyfill

(Again, some totally unnecessary imports doing nothing except adding ridiculous complexity to a hello world app.)

app.js — 39 lines.

At 28 mins in we’re wrapped up with the hello world examples and go into the slides.

Technical

Size (minified, not gzipped)

  • React+Redux — 156k or 167k with plugins
  • Angular 1 – 158k minimum, 240k with router, HTTP and animation system
  • Polymer — 222k minimum, 302k (spec compliant)
  • Aurelia — 252k minimum, 302k with standard plugin
  • Ember — 435k including router
  • Angular 2 — 698k minimum, 919k with RxJS, 1023k with RxJS and router and HTTP client

(Not that Redux is in any way large, but it is unfair to add Redux to the file size for React only. Redux happens to be more commonly used by React users, but it is an optional extra regardless of which framework you choose.)

Rob mentions that the Angular team are using tree shaking to reduce the file size.

Repaint Performance

This test uses DB Monster Repaint. Numbers are frames per second.

Aurelia — 90–105/130–150 (with optimisation plugins)
Angular 2 — 80–90/110–130 (with optimisation plugins)
Polymer — 50–60
Angular 1–50–55
React — 45–50
Ember — ???

Rob says that to be honest all of these frameworks are very fast because 50 frames per second is faster than what we can usually see.

(This tool was popularised by Ryan Florence (from Facebook) in his talk at Conf 2015 showing React was faster than Angular 1 and much faster than Ember at the time it was recorded.

You can see Matthieu Ancelin’s dbmon repaint rate challenge which tests a much wider choice of frameworks, however Aurelia is a “TODO” implementation at the moment. Rob says the Aurelia team are working on an implementation for submission and it will be available soon.

Latest Performance Developments (updated 25th Mar 2017)

There is still nothing available on dbmon to support Aurelia’s performance king claim.

The dbmon test has recently been updated with adjustable mutations percentage. I have set these to 50% for these tests. The top performers may be different at lower or higher percentages.

I ran the optimized tests for Rob’s selected frameworks on my laptop on Chrome 57 for Windows and got these results:

Angular — 45 to 46fps
React — 52 to 54fps
Angular 2– 49 to 52fps

Only naive implementations for Polymer and Ember are currently available

Polymer 1.8 — 44–46 fps
Polymer 2.0 –37 to 40 fps
Ember — 44–46 fps

Some other selected framework/technology results:

Vue — 51–53 fps
Vue 2–41 to 44fps
Elm — 51 to 53fps
Inferno — 54 to 56fps

Vanilla JS varies from 50 to 72 fps

I also ran these tests on Firefox and Edge. Frame-rates are significantly slower in both of these browsers. I found Angular 1 outperformed Polymer on Edge. Ember performance is massively improved with the latest version and there is an optimized version here which is insanely quick!

Many other fast frameworks are tested here as well. Angular Light and Motorcycle score well, although not as fast as Inferno. At the end of the talk Rob recommends Riot as an alternative to React. I found Riot scored about 36fps at 50% mutations. Also see more benchmarks from auth0

It is interesting that Rob downplays the significance of leading performance here because — giving the Aurelia team the benefit of the doubt — in the past other frameworks have easily generated a lot of interest just by being very vocal about their superior benchmark results. It is a crown which is never held for very long however.)

Standards Compliance

Aurelia: HTML, ES 2016, Web Components (including the Shadow DOM)

Polymer: HTML, ES 2015, Web Components

Ember: HTML, ES 2015

Angular 2: ES 2016 (TypeScript). Non Compliant: NG2 Markup and Dart

Angular 1: HTML, ES5. Non Compliant: Modules, Dependency Injection

React: ES 2015. Non Compliant: JSX

(Web Components is still not yet a proper standard but has now reached “V1” — See Taylor Savage’s article on V1 support in Chrome 53/54+.
Web Components Shadow DOM is currently a 
Working Draft
Web Components Custom Elements is a 
Working Draft

TypeScript is not a standard, and ES 2016 is a standard.)

Separated Presentation

Excellent: Aurelia and Ember

Moderate: Angular 1

Poor: Angular 2 and Polymer

N/A: React

Rob says Separated Presentation is less of a technical issue than a people issue.

Obtrusiveness

Unobtrusive: Aurelia

Average: Ember

Obtrusive: Angular 1, Angular 2, React

Rob provides some commentary for the purpose of justifying these claims.

(These are opinions not measurements)

Interoperability

Very Interoperable: Aurelia, Ember, Polymer

Average: Angular 2

High Friction: Angular 1, React

That concludes the technical comparison. At 43 minutes in Rob moves on to discussing the project and the team.

Project and Team

The table is very useful but has too much information to recreate here, so see the video at (43:30) for that.

Rob says although Angular 2 is claimed to be at Release Candidate Status, there are still breaking changes being made and

it’s not really a release candidate if you look at what’s really happening there.

(In my opinion this was fair comment at the time but is no longer relevant as Angular 2 is far more mature now, and Angular 4 perhaps even more so.)

Rob says there is a patent clause in the React license, which prohibits you from using it to compete with Facebook, or if you have an intellectual property dispute with another company using React.

He says this is why Google and Microsoft employees don’t use React.

Latest Version Information (updated 14th Apr 2017)

React

You can find React’s Patent clause here.

Robert Pierce of El Camino Legal LLP has written this article criticizing Facebook’s patent clause and arguing it is not open source software. Hacker News comments here.

After a 3 months wait, v15.5.0 is released. The team is also busy working towards v16 which is currently in alpha.

Aurelia

It’s now approaching a whole year since Aurelia reached v1.0.

Following the Early March Mega Release there’s been an April update with — aurelia-router 1.3.0
aurelia-templating-resources 1.4.0
aurelia-cli 0.28.0
aurelia-ui-virtualization 1.0.0-beta.3.1.0
aurelia-i18n 1.5.0
and some patch releases

Several other great new Aurelia features are coming this year:

  • New Chrome Debugger
  • Webpack v2 support
  • CLI enhancements
  • Hot module reload
  • VS Code plugin enhancements
  • HTML Template Validation

For more details see the Aurelia blog.

Angular 2+

Angular 4 RTM has now been released! v4.0.2 is also out and v4.1 is currently in Beta.

Angular 2 reached RTM on 15th September and reached v2.4.10 before v4 came out.

Since v2 was released, the Google team has mostly met its own proposed schedule on releasing new minor and major versions
Angular 2.1 — Route Preloading
Angular 2.2 — AOT + ngUpgrade
Angular 2.3 — Language Service
Angular 2.4 — “Stability Interjection”
Angular 4 — March 2017

The Google Team have agreed to release new patch versions every week, a new minor version every month and a major version every 6 months.
So this is the plan for new major versions

Angular 5 — Sept/Oct 2017
Angular 6 — March 2018
Angular 7 — Sept/Oct 2018

There was no Angular 3 but don’t worry about that.

By new major version we mean new features and potential breaking changes since the last release. So we should not necessarily get overexcited about new major versions, or conflate higher major numbers with very much higher quality.

For full details see Igor Minar’s blog post and opening keynote. Igor makes many interesting points in the keynote.

Google always use the latest version of AngularJS for their own applications. He also mentions TypeScript and the desire to support v2.1.

Some of the new Angular features we can expect by March are:
– Better Compiler Errors
– Faster
– Smaller

Angular 4 is backwards compatible with Angular 2 (but not Angular 1) so Angular 2+ looks to be the better bet for new applications that you will need to maintain and improve over a long lifetime.

For applications that you expect to be one-off releases and need to release very soon, it might still make more sense to use Angular 1.x if your experience is with Angular 1.x and you want to take advantage of the more mature ecosystem that surrounds it, however the case for Angular v2+ over v1 will only grow stronger as time goes on.

The Google team recommends we use the latest version.
Asked about using Angular with a module loader Igor said
“This will probably change in 6 months…it seems that webpack is a better option from the developer ergonomics.”
he goes on to explain where Rollup or SystemJS may be better.

Google’s Green Tea app was rewritten big-bang for Angular 2.

Angular 2 on Pluralsight

The Pluralsight Angular 2 Fundamentals course is now out. It is a huge 10 hour course.

There is also a recent course by John Papa and Dan Wahlin.

I’ve also written reviews of first look and getting started. Deborah Kurata’s getting started course has been updated for the RTM version of Angular 2 and contains more than an hour of additional content than her original course: I am currently updating my review to include that.

There are a few new Angular 2 courses released by Pluralsight: Mark Zamoya’s Angular 2 Forms, John Papa and Ward Bell’s Play by Play: Angular 2 Quick Start, and Deploying an Angular 2 to Azure with Git by John Papa and Shayne Bower.

Polymer

Polymer v1.9 has been released.

If you haven’t currently invested in Polymer 1.x, I recommend using v2.x instead.

The 4th Release Candidate version of Polymer 2.0 has now been released. A series of videos from Polymer Summit 2016 are available on YouTube.

To learn about the upgrade path to Polymer 2.0 watch Polymer 2.0 in 2.0 seconds. To understand how it works see Polymer 2.0: Under the Hood. Rob Dodson describes Polymer as an opinionated usage of Web Components.

Another good watch is What’s New in Polymer Tools.

Ember

Ember v2.12 and v2.13 Beta are out

Noel Peden has produced the Pluralsight course Getting Started with Ember 2

For a history of the evolution of Ember.js see the EmberConf 2017 keynote — Yehuda Katz and Tom Dale address the common perception that Ember is an outdated framework with too much baggage 21 minutes in. They are continually working to modernize the framework in a way that doesn’t alienate the existing user base.)

Core Team

Another detailed table at 48 mins in. Rob claims that the Angular teams don’t use their own frameworks, and that only the Aurelia and Ember teams are available to provide training.

(If you need React JS Training it is provided by Ryan Florence and Michael Jackson from Facebook)

Community and Communication

Another table of information and commentary on how strong each community is and how well the teams communicate with those communities.

Learning Materials

All frameworks score well on this.

Business

Another table of information at 54 mins giving details on:

  • Corporate Buy-in
  • Commercial Support
  • Consulting
  • Customer Relations
  • Official Relations
  • Official Partners
  • Motivation
  • Brand Recognition

Rob says Angular 1, Angular 2 and Polymer are not Google products. They are open source side projects from teams inside of Google.

(For detail’s on Google’s CRM system greentea, and it’s relationship with Angular, see How Google Uses Angular 2 with Dart. Google has also rewritten Google Adwords using Angular 2, and this is millions of lines of code.)

Rob’s Recommendations

Yes: Aurelia and Ember

Maybe: Polymer (or web components JS) and React (or Riot to avoid the patent problem and smaller size)

Rob says React is much better for read only apps and a lot more work for input intensive apps.

No: Angular 1 and Angular 2

Rob finishes the talk by re-iterating that he is biased, but hoping that the talk included useful information.

(I definitely feel that this talk has been useful to me. When doing your own assessment don’t forget there’s also Elm, Meteor, Cycle, Marionette, Inferno, Sails, Vue and many others worth considering.

My Recommendations

There is no one framework that is objectively “best”. Every option has its own strengths and weaknesses as we have seen. Your choice should depend on your own circumstances. A few guidelines:

Strongly consider Angular 1 if:

  • You are already using Angular or have developers with Angular 1 experience
  • You are looking to recruit one or more developers who already have experience in your framework of choice (easy to find developers with Angular 1 experience)
  • You are not particularly interested in chasing the latest shiny things; you just want something that is proven and reliable
  • You need good performance but it doesn’t need to be state of the art

Strongly consider Angular 4 if:

  • You are a fan of TypeScript or have developers with TypeScript experience
  • You want to write large, very high performance applications
  • You are not very purist about the JavaScript language — you do not mind learning proprietary directives and other Angular concepts
  • You don’t mind taking a bit more time to learn an advanced framework
  • You don’t mind your users downloading a larger than average file
  • You do not want to fall behind the technology curve (it is being regularly updated in a way that makes it easy to stay current)

Strongly consider React if:

  • You are writing a medium or large scale app and are concerned about maintainability
  • You prefer to make your own specialized decisions on how your software works — you enjoy investigating and evaluating new technologies
  • If you write a bug you prefer to fail fast and early
  • You do not mind writing a bit more code as long as it clear and understandable
  • You are not religious about web components, as React’s virtual DOM does the job well enough
  • You are not frightened by the patent clause

Strongly consider Ember if:

  • You are not particularly interested in chasing the latest shiny things; you just want something that is proven and reliable
  • You don’t want to waste time being overwhelmed by the number of possible solutions to a problem — you want an opinionated framework that gives you standardized and high quality solutions to the common problems

Strongly consider Polymer if:

  • You love Web Components
  • You love minimalism
  • Your users, or most of them, are using very modern browsers
  • You want the minimum “startup tax” on your users — Polymer 2 file size is tiny

Strongly consider Aurelia if:

  • You want a framework that doesn’t get in your way too much
  • You are a fan of Web Components
  • You need high performance, but not necessarily state of the art
  • You appreciate a clean syntax
  • You consider standards compliance an important consideration
  • You only hire good developers, so you are confident they will be able to learn the framework quickly enough

Further Reading

Choosing a JavaScript Framework — Rob Eisenberg at NDC Oslo 2016

Fun Fun Function: Too many tools and frameworks! (how to deal with it)

Tessa Thronton: How to learn web frameworks

Review of Brian Noyes’ Aurelia Fundamentals course

Rob Eisenberg on Aurelia and how it stacks up against Angular 2 and React

Todo MVC examples in many, many frameworks

Front End Masters: Brian Holt’s JavaScript Framework Showdown (Angular 1/Ember/Backbone/React)

React.js Conf 2015 — The complementarity of React and Web Components by Andrew Rota

Stickfigure compares Angular, React and Aurelia

Daniel Steigerwald medium posts:
What’s wrong with Angular 1?
What would I recommend instead of Angular?

Source: https://medium.com/@ZombieCodeKill/choosing-a-javascript-framework-535745d0ab90

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s