Poll: Which JavaScript framework do you use (and why)?
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 ] threadIt 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.
I'm a junior developer (if that), and I've found the strong opinions and conventions of Ember very refreshing.
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.
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/
http://ionicframework.com/blog/where-does-the-ionic-framewor...
http://eisenbergeffect.bluespire.com/angular-and-durandal-co...
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.
also DocPad for static sites with more content than code.
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."
Not only that, but with current modern browsers, you might not even need jquery at all ;) http://youmightnotneedjquery.com/
As crockford would say "The World's Most Misunderstood Programming Language Has Become the World's Most Popular Programming Language" http://javascript.crockford.com/popular.html
https://github.com/angular/angular.js/blob/master/src/ng/com...
https://github.com/angular/angular.js/blob/master/test/ng/co...
https://github.com/angular/angular.js/blob/master/src/ng/roo...
https://github.com/angular/angular.js/blob/master/test/ng/ro...
(By that I mean that there would be efforts made to keep it lean. I don't think Google is Microsoft.)
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.
I'm using sails.js (on top of express.js and node.js) for an MVC app
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.
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.
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.
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.
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.