Poll: Which JavaScript framework do you use (and why)?

48 points by k-i-m ↗ HN
I'm trying to figure out which is the best javascript framework to learn. The last days I've read many articles and docs but I still can't decide.

My first choice at the moment is batman.js which is very similar to rails (where I'm coming from), but I'm worried that it's not so developed like others (at least checking the github repo)

77 comments

[ 3.3 ms ] story [ 156 ms ] thread
where's react?
Is React really comparable to things like Angular and Meteor? From what I understand, its supposed to be used in conjunction with a lot of other libraries, being only the 'V' in MVC and all.
That would disqualify Backbone too.
I'm not so sure, Backbone seems to do a lot more than React. I could just be talking out of my ass though, I've never messed with Backbone
Backbone offers some base objects/classes around Models, Views and Collections but does not enforce any specific architecture. It's completely up to you how you use it.
yeh i was wondering that too... but that's what I like about React actually. A simple skin for complex views on top of a server-side language (Java/Clojure for me).

It makes more sense to me since I don't want my entire site to be overly Ajax-y. I'd rather only feed a few initialization variables to js & have most of the site logic/navigation/variable-injection coming server-side from a nice persistence layer.

(comment deleted)
If you're looking for something reminiscent of Rails, I would suggest Ember.

I'm a junior developer (if that), and I've found the strong opinions and conventions of Ember very refreshing.

We use Backbone with a view layer that we wrote on top of it called Ribcage: http://github.com/techwraith/ribcage-view

Backbone walks the line between framework and a collection of modules really well. It gives you just enough to be productive without being overly complex or restrictive. If you go the Backbone route, here's some pointers:

- Make sure you have a system in place for model management, having multiple models around for the same data can be a nightmare

- Backbone views are a bit too simple most of the time, you'll want to at least add a view hierarchy system and lifecycle events/methods.

- You can use the router for as much or as little as you'd like, don't feel like you have to have a new URL for every state in your app.

I'm going all in on Angular, even building a big open source project around it (http://ionicframework.com/). What really drew me in was hearing from developers that were using it at big, slow companies for entire teams building production apps.

Officially adopting a technology like that is pretty rare, and I guessed Angular had started to achieve a level of adoption that would make it the most worthwhile to invest in.

I also wrote more about how I think it's going to be huge, which I admit sounds best if you already love angular :) http://ionicframework.com/blog/angularjs-will-be-huge/

We're an Angular shop and just started using Ionic for our mobile app. Loving it so far! Thanks!
Ionic is pretty darn cool! We are building our customer facing app around it and it has made developing apps for smartphones a breeze. The funny thing is, we use the MEAN stack for the server side component so essentially, our entire dev stack is HTML5, CSS and Javascript :D
Great to hear, let me know if you ever have any questions :)
I was surprised to see you're based in Madison! Dangerously close to Muramoto.
At my place of work (large, slow) Ember is starting to get widely used. "Google uses/supports it" is instant justification for using it to any layer of management, and I think that's the source of its success. (At least where I'm working people are afraid of using Ember because it's harder to explain/justify to the suits.)

Likewise, I expect at some point we'll be using node.js (probably over Rails/Django) because it's a lot more obvious to 'management' that it's used by large organizations.

I meant to say Angular is starting to get widely used. Typing snafu. (Post makes no sense otherwise.)
the [LEBRON stack](http://lebron.technology/) using many small npm modules is my favorite, but i add Backbone and React when i'm working with others who want something more framework-y.

also DocPad for static sites with more content than code.

Do you know jQuery inside out? If not, you should learn that before you worry about higher level frameworks.
I barely use jquery at all and build rather large JS applications. YMMV
Angular is making a run at replacing jQuery as we speak. It still lacks some of the easing and visual effects, but can do most of what jQuery is known for.

http://paulhammant.com/2012/03/03/replacing-jquery-with-angu...

"Don’t even use jQuery. Don’t even include it. It will hold you back. And when you come to a problem that you think you know how to solve in jQuery already, before you reach for the $, try to think about how to do it within the confines the AngularJS. If you don’t know, ask! 19 times out of 20, the best way to do it doesn’t need jQuery and to try to solve it with jQuery results in more work for you."

Actually, people should know JavaScript better before even hearing about jQuery... I lost count of how many times I heard people saying they know how to "program in jQuery" and that made me really sad/angry regarding how people lack curiosity and knowledge in their own field...

Not only that, but with current modern browsers, you might not even need jquery at all ;) http://youmightnotneedjquery.com/

This should be, "Do you know JavaScript inside out?". Native JS is where people should be starting.
I'm not quite sure what's your point. Of course the magic has to happen somwehere. I just don't want to bother with it. AngularJS is not so easy to understand, but it works pretty well, for me at least.
The point is that the code is quickly piling up technical debt.
Maybe. But it could also benefit from Google's financial backing if it became as big as the author would like it to be. Then it wouldn't matter.

(By that I mean that there would be efforts made to keep it lean. I don't think Google is Microsoft.)

Can you elaborate?
Besides just four files containing ~10k lines of code?
We can't read your mind buddy! But agreed, 10k lines of code in just a few files is a valid point of concern.
It's mostly comments and tests. Seems like exactly what you'd want.
Two of those are test files. Nothing wrong with more tests, and they seem descriptive to me. And it's a very easily testable framework, unlike some of the others in the thread.
Started with Backbone and found myself using a lot of extensions to get the work done. Switched over to Angular and it seemed like a much more complete framework. Nail in the coffin for Backbone was when a buddy rewrote one of his extensions from Backbone (almost 2000 lines) for Angular (just shy of 800 lines).

I haven't built anything huge with it, but am enjoying how easy it is to work with. I use .Net and MVC quite a bit, so I think the Angular with its "pseudo" (some people argue Angular isn't a "real" MVC framework) MVC approach was easy to pick up. I also like the idea you can use a little for say a navigation or a photo album or a lot for a large scale native application.

Never liked Knockout for a variety of reasons, did some cool stuff with Meteor, but convincing people to use it was a hassle.

In the end, AngularJS wins for me.

Should specify you mean frontend

I'm using sails.js (on top of express.js and node.js) for an MVC app

Meteor is amazing and having been given the opportunity to build out a shop I am going all in with it. I've previously used backbone for large scale(HUGE contracts) projects, and I appreciate it a lot, but meteor makes things ez-mode for me. Basically abolishes front/backend dichotomy(apart from design type stuff, which I'm still abysmal at, but that's why we have designers who can layout in CSS)
I like Chaplin.js, it provides a very structured way of building Backbone applications with things like memory management and object disposal, which are really nice.
Disappointed (but not surprised) to see Twitter Flight missing from this list. Flight + jQuery has been stellar for me, building several applications of varying complexity (one basic CRUD app with a little bit of flair, one pretty client-intensive app, though no client-side routing, and a few in between).
Came here wondering if I'd see anyone else using flight. Really liking it as a light weight framework/lib so far.
As someone who doesn't build a lot of SPA's, it's a godsend. Keeps the UI structured and decoupled, but doesn't get in the way. I wonder if it really classifies as a "framework"? I feel like it does, since if I'm using it I'm not using a more traditional "framework" like Backbone or Angular; but at the same time, it doesn't come with all the usual restrictions of traditional frameworks (nor does it provide everything they do, but that's kinda the point).
I mucked around with a few but found them quite restrictive and generally only pushed issues around as opposed to solving them. As soon as you're dealing with a nasty API you can generally find the limits of a framework and have to start writing your own work arounds to behave inside its designed parameters.

Essentially I've found jQuery the best option as a framework, and only because it reduces the verbosity of straight Javascript. Everything else, as noted above, usually ends up in the "good at first then in wish I didn't" basket.

At the end of the day, the majority of what I do is binding, validation, and event handling... and no framework really reduces what has to be done, they just stops other people from doing it differently.

What frameworks and libraries do you use to develop for iOS and Android?
(comment deleted)
I use backbone, I like it because it's less of a framework and more of a way of structuring your code, you can decide the rest and there are loads of modules/libraries out there to help you out.
I use Marionette (a very light framework built on top of backbone) and love it - perfect blend of power and ease of use.
Backbone (though I want something lighter weight and w/o the jquery dependency), backbone-signal, Handlebars, browserify.

I have a single app model which uses a bunch of reactive signals and other registry data.

The great thing about browserify if it give you commonjs for the client side. commonjs takes care of the structure & naming of your domain logic. It also allows you to create fine-grained modules, which is wonderful for reuse & maintainability.

I wish there was a standalone Handlebars module which allows updates to the data, like what is done in Ember. I'm willing to use another template framework, which can be mimized, that supports data binding. React seems interesting.

I test with jasmine & jsdom. I tried phantom, but it's nice to be able to easily create test doubles as needed. I tend to perform black box (or functional) testing when possible, eschewing unit tests. I use jasmine-flow to test user flows.

backbone's only hard dependency is underscore, it's also the lightest library on this list by a solid margin
Spine is even lighter than Backbone. I like Spine because its functionality is not really tied to the DOM or jQuery -- I make native mobile apps with Spine on Titanium, for instance. Spine is built out of components (i.e. Model and Router), which can be used separately or in concert. It's a massively underappreciated framework that has had staying power.

Not to mention, stepping through (or trying to log) the endless anonymous functions created by underscore can be a hassle and straight crashes chrome/node inspector in some situations.

One of the big reasons I chose Ember is because it embraces convention over configuration and I have no patience for boilerplate.
Backbone. its a very minimal single purpose library I enjoy and come back to. Wrote several modules to help with redis, socket.io, server side templating and more.. Its APIs are quite mature, the community is great, plays nicely with coffee script and anything I threw at it so far..
I chose Angualar due to having the largest community, biggest backer (Google), and the positive reviews. I'm a huge fan but sometimes think there's a bit too much "magic" happening. The worst part however is the learning curve, which can be brutal for new javascript devs. Still, the more I hear about Angular 2.0, the more I realized AngularJS was the right choice and will be the dominant framework for the web moving forward.
So I've been using angular almost daily for a year and a half now and I might be biased, but from what I've done on other frameworks angular is still my personal favorite. Good choice.

I'm curious what you mean by "magic." Once you understand how it all works, there's no magic. Though you are right that it takes time to understand. I feel like the magic is just part of that learning curve.

For what it's worth, I've worked on large teams building production Angular, Backbone and Knockout applications. By far my preferred framework is Backbone.

Angular is great at first. You can get the first 80% of your application done in no time. The rough edges are intense though, and if you find yourself using the $compile and $parse services you're definitely writing code someone else is going to curse you for down the road.

Also, I do not understand why so many people think Angular is "testable." The end to end testing is weird and would be better accomplished with Selenium.

The unit testing story is even worse. inject() and module() helper functions are a necessity, and that fact alone should cause everyone pause. How come the basic injector is so difficult to load things into? Creating controllers in unit tests is awkward. Dealing with scope.$apply and promises is also painful.

Large code bases get painful quickly. There's (at least last time I looked) no dynamic script loading solution. You can use require, but coupling that with the dependency injector gets awkward. Further, directives sound great at first, but once big teams start pumping out directives, it gets difficult to reason about your html and figure out what's going on.

Form validation is really strange and the business requirements on every project I've worked have never been met by it.

Also, Angular seems to suffer more from client side rendering jitter than many of the SPA frameworks I've seen. Backbone does too, for sure, but it's easier to hook up something like FastDOM to Backbone.

Which leads me to Backbone - it's more of a library than a framework. It provides nice code structure and organization and otherwise stays out of your way. For small apps that may not be desirable, but for large apps it can absolutely be a blessing. Sure, you have to do more, it may even take more discipline, and it might even be more lines of code, but for big teams it really does seem like a better fit.

Finally, my contention is that VERY FEW APPLICATIONS SHOULD BE WRITTEN AS "SINGLE PAGE APPLICATIONS". Using something like Pjax + Backbone/React for light interactivity seems to be a sweet spot for many of the applications I've worked on. So many screens are read only, and performance will be markedly better rendering server side and injecting HTML directly in to the DOM.