It’s been two years now since we started building most of our products with Angular at Wizbii. Obviously we faced some issues but nothing that could make us turn from Google’s framework (proof is: we didn’t). Before I explain why we’re exploring other solutions, I want to make it clear: Angular is great. It’s at the core of our main app and handles everything on the client side. So cheers Angular!

The fact is that the web evolves at an incredible pace. There are new solutions addressing nowadays’ concerns coming up everyday. When we started building the next iteration of the product, things were different. Grunt and Gulp were the most famous build tools. Bower was pretty popular and you had to pick one of Backbone, Ember or AngularJS for the front-end. Two years later, Bower is about to disappear. Webpack is getting a lot of traction, ES2015 is everywhere and a new framework is popping up everyday. As web developers, part of our job is to keep up with all that and update our stack accordingly. So what does the future look like for Angular 1.x apps?

Angular 1 is growing old

Before going any further, it’s worth discussing why it might be time to look for a framework upgrade. The following observations apply as much as Angular 1 as anything else released around the same time.

The first reason is that, because it’s older, it does not integrate concepts that emerged lately. Technologies that address common issues in web applications. For example it doesn’t support virtual DOM, server-side rendering and component oriented architecture. That’s why it performs worse than new alternatives, doesn’t work for SEO and is complex.

Speaking of new technologies, Angular’s dependency injection (DI) doesn’t play well with modules definitions. For the record, it was one of the first to offer a powerful built-in way of managing dependencies:

angular

.module('app', ['ngMessages'])

.factory('DemoService', [

function () {}

])

.controller('DemoController', [

'DemoService',

function (DemoService) {}

]);

That’s enough if you’re putting all your application’s code in the same file but you’ll need to split things at some point. And then, because we want to serve a single file, we need to re-assemble them. To do so we used to have a list of files to concatenate in a certain order by a build tool. We were relying on implicit imports, managed by a configuration file. Thanks to the rise of bundlers like Browserify and Webpack, it’s now possible to use modules in the browser.

import angular from 'angular';

import 'angular-messages';

import DemoService from './DemoService';

import DemoController from './DemoController'; export default angular

.module('app', ['ngMessages'])

.service('DemoService', DemoService)

.controller('DemoController', DemoController);

We can now explicitly declare a module’s dependency without any tradeoff. You may have noticed something weird though: we still need to inject the imported code into the Angular module. Things get even more awkward in DemoController.js:

import './DemoService'; function DemoController (DemoService) {} DemoController.$inject = ['DemoService']; export default DemoController;

It imports the code in ‘./DemoService’ but reference it with a string wrapped in an array, assigned to a $inject property. But importing DemoService is not enough, we must inject it in the module that uses DemoController. This example illustrates how Angular 1 is colliding with the new standards for modules definitions.

Angular is simple, yet complex

Angular’s team have made all the hard choices for its users. Thanks to them we don’t have to think too much about the application’s structure and there are even some well defined style guides. So yeah, getting up to speed with Angular does not take that much… Until it comes to the template syntax and directives (among other things).

There are a lot of template engines out there, each one with its own syntax and no clear standards. Angular’s is one more to learn — at least until you move to Angular 2. The problem is that when you learn a template’s syntax, you’re learning this particular one. Once you move on to another framework/library/whatever you’ll have to relearn everything. It’s not that Angular’s templating is bad, it’s rather powerful and you can manage to deal with any edge case. But I bet that you’d have trouble building a list of options from an object with ngOptions. Something that would be a trivial task with Array.map. My point is that JavaScript is powerful enough, we don’t need such abstractions.

While I’ve pointed ngOptions as being part of the template syntax, it’s actually a directive. Directives (and now components) are a way of creating reusable UI fragments. They are permissive and allow you to do much more things than React’s components. To provide such flexibility, Angular developers had to come up with a solution for each case, leading to a complex API. Since you can do almost whatever you want, there’s also no real guidance about the good way to do things. So soon enough you’ll have to learn more about transclude, link, pre-compile, compile, post-compile, priority, scope inheritance, …

Angular’s complexity is in the little details, which makes it easy to grasp but hard to master.

But then, how can one handle every edge case while remaining simple? React is a good example of how to tackle the problem, mainly for two reasons:

It doesn’t deal with every edge case. React doesn’t let you do everything but guide you through a new way of thinking. Going from dependency management to templating, it’s all JavaScript. React is just that: JavaScript. That’s also why I won’t recommend it if you’re not too comfortable with JavaScript.

The future of Angular 1.x applications

Right now, the latest production-ready version of Angular is 1.5.x and the next major one (2.0) is in RC. It brings a full rewrite of the framework. While the Angular team worked hard to improve the migration path, you will not be able to conserve the code base as is. That’s usually what happens when something gets a major release but it’s particularly true for Angular 2.0. It means that the migration will be a step by step process to update the code base. It’s going to look a lot like we’re moving to another framework. So in such conditions, why not taking the time to consider other alternatives?

Upgrading from Angular 1 to 2 is not going to be as costly as moving to a different library/framework. As said earlier, there are some tools to help us and some concepts will remain. But that’s one more reason to explore other solutions now, before running out of time. While I’m pretty confident about moving to Angular 2, I’d be more worried about leaving it for React. I’d have to deal with problems that a framework solves. Yet, React’s ecosystem is so different I couldn’t give it a try.

The only way to know if React+Redux could fit our needs better than Angular was to give it a try in real world scenarios. That’s why we started to build some of our internal tools with this stack.

It’s important to understand that Angular is a framework while React is a library. It means that the latter, alone, can’t be a real alternative. There’s a lot of gaps to fill and decisions to make. We’re gathering our findings as we’re filling the gap and document it on GitHub: wizbii/react-redux.

Getting started with React and Redux

React and the Redux architecture can look a bit confusing at first. There are so many new concepts that it could be overwhelming. To be honest, it took me some time before feeling confident. That’s why I’d like to share the path that worked for me.

React and Redux are two different things. The first one is a UI library and the other one is a pattern so it’s fine to start learning one before the other. I’d recommend to start with React as it’s probably the easiest part. Apart from a few specific concepts, there’s not much things to learn as it’s pure JavaScript. Have a look at the documentation, spend some time experimenting and soon enough you’ll be able to build cool things. The tooling can be complex but apart from that you shouldn’t have too much trouble.

Things tend to get more complicated when it comes to Redux. Since it’s a theoretical concept, it’s harder to understand before putting it in practice. It was co-created by Dan Abramov after he faced some issues with the original idea of Facebook’s Flux. You can start by getting a sense of Flux but it’s ok if it doesn’t make much sense yet. It’s going to look clearer after you’ve read Lin Clark’s article: A cartoon guide to Flux. Lin also wrote a great article about the differences between Flux and Redux: A cartoon intro to Redux. Finally, I’d recommend to watch Dan’s egghead serie: Getting Started with Redux. He’s rewriting a simpler Redux while explaining how things work behind the scene. At this point, you can have a look at the Redux documentation and the real world example.

By now you should have a better understanding of what Redux truly is and how it works. Give it a try and build some apps. Soon enough you’ll have to use some more advanced techniques but take your time.

Stay focused to fight the JavaScript fatigue

I made the choice not to go into details about some other aspects that surround the development of React and Redux applications for focus and brevity reasons. The best way to fight JavaScript fatigue is to stay focused and learn what matters to you, step by step. Start simple, make it work and look for improvements only when you’re feeling comfortable.

That been said, I need to mention that the experience of developing with React and Redux is awesome. The libraries, along with some developer tools, do a great job at letting you know what’s going on. It results in a faster development process. Watch Dan’s talk to see how much he cares about developer experience: Dan Abramov — Live React: Hot Reloading with Time Travel at react-europe 2015.

If you’re considering React and Redux as an alternative to a framework you’re using, have a look at wizbii/react-redux. It’s a repository where we’re gathering the building blocks of large applications to see what it’d take to replace Angular.