Client framework

JavaScript frameworks: What are your options?

By Jason Tee

TheServerSide.com

With front-end development becoming the focus of so much attention in the Web application world, the so-called "framework wars" are in full swing. Unlike traditional languages such as Java and C#, JavaScript has never had a robust development framework. No one ever imagined it would need one. After all, JS was just a little scripting language to handle minor jobs. Secretly, many developers hoped it would be replaced by something else. That's apparently not going to happen. This means it's time for Java's little cousin to grow up -- and it needs a framework to grow upon. Currently, there are three strong contenders battling for dominance. Two experts weighed in at the 2014 O'Reilly Fluent Conference on this topic.

All frameworks serve different purposes

Brian Holt, product manager and director of front-end development for Reddit, was careful not to choose sides. He said that each framework has commendable features. That's why Holt walked developers through Angular, Backbone and Ember during his JavaScript "Smackdown" at Fluent. The choice really comes down to personal preference between Angular and Ember for rapid prototyping on small projects. Ruby developers tend to have deep loyalty to Ember because they feel an intuitive connection with how that particular MVC framework is structured. Outside the Ruby community, Angular is winning out.

Backbone, the first major JS framework, has fallen out of favor recently. It might still be the best choice for developers in the enterprise, but Holt did mention that it allows more room for error. "It's more of a DIY approach; batteries are not included. You are going to determine the structure of your app and how it's going to run. Backbone will give you enough rope to hang yourself." For a large-scale client-side app, the freedom to perform deep levels of customization in the design phase might be worth the extra risk.

For many, AngularJS is the clear winner

Freelance Consultant and JS expert Mark Bates came out strongly in favor of Angular, the Google-backed framework that has the greatest mindshare in the development community right now. Bates claimed that this is the easiest, lightest and simplest framework on the market. He probably convinced many programmers to join this camp during his AngularJS fundamentals workshop, although he admitted that it comes down to opinion at the end of the day. He made several good arguments in favor of an Angular approach.

"What's really nice about Angular is that it's very simple to use. With a few lines of code, you can have a really dynamic application up and running. That's what developers love about it." With Backbone and Ember, it's necessary to extend objects. In Angular, the focus is on using plain JS objects. A controller is nothing more than a function in Angular, which makes it very easy to test. "They've done a really nice job of separating out view code (such as templating code) from controller code. So you don't put any sort of jQuery or HTML object inside your controllers. It's simply methods and helpers to do whatever you need to do -- like returning a state or some other information." With Angular, it isn't necessary to learn models and controller objects. Simply write a JavaScript function, and it will bind with the template.

Which framework meshes best with the back end?

According to Holt, these frameworks are fairly agnostic. As long as the back-end APIs are sane (clean, simple and RESTful), they will work in well with any of these frameworks (although Backbone is geared slightly more toward Rails apps). "They don't really care what's on the back end. They just want to talk JSON. As long as you're giving JSON back and forth, they're pretty happy."

Mark disagreed. "Ember and Backbone are very opinionated about what your back end has to look like. It has to be formatted and presented in a particular way. Angular is a lot looser because it uses plain JS objects. When I make a request to an API, it's going to take back whatever that API gives me and convert it into a JS object. There's no need to write custom adapters." He did agree with Holt that working with clean, well-written APIs makes things easier with any framework.

A newcomer might still surprise everyone because frameworks are still maturing. However, it seems likely at this point that one or more of these "big three" will become the standard for front-end development. Now is a good time for server-side developers to learn a little more about how JavaScript is evolving and how to clean up their API act to make this journey into JS as smooth as possible.

25 Apr 2014

Related Content

Related Resources

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.