Poll: Which JavaScript framework do you use (and why)?
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)
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)
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.
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.
If your intention is to build JavaScript applications and the different philosophies of these projects isn't obvious to you, then I think it's worth hearing Yehuda Katz and Tom Dale make the case for frameworks (specifically Ember) in their keynote presentation at Fluent 2014: http://youtu.be/jScLjUlLTLI
I've written 2-3 large applications in Angular, I've contributed ~1200 lines to Angular 1.3, and racked up a lot of points on StackOverflow answering questions around Angular.
However, I'm currently working on a pretty crazy real-time app for Netflix that's all in Ember, and I wouldn't have it any other way. I have the pleasure of working with @ebryn there, and it's been an awesome experience.
In this poll, there are really just those two frameworks. The others frankly aren't in the same league right now.
I've yet to read what I thought was an unbiased, honest comparison of the two. Generally, anyone that does a comparison has one favorite, and the other they barely know. I'm hoping to remedy that at some point, but I still feel my Angular experience out-weighs my Ember experience. At least for now.
However, preliminarily, I can say that both frameworks are absolutely brilliant attempts to solve similar problems in completely different ways. I think they both have a LOT they could learn from one another. I prefer a convention-based approach, which is one thing I love about Ember... That said, I prefer Angular's constructor-based DI over the setter-based DI of Ember... That said, both of them have somewhat primitive IOC containers that could be better (which is a whole blog post by itself)... THAT said, Angular allows developers to put too much logic in their templates via expressions (harder to test)... THAT said, Ember's structure and composition isn't quite as easy to pick up if you're new to the framework... THAT said, Angular doesn't require any other libraries and is very compact... THAT said Angular's directives allow for wild-west spaghetti code and give developers enough rope to hang themselves... blah blah blah
... the point is, I could go on forever. Both libraries have REAL advantages over one another, but libraries have REAL disadvantages over one another as well.
# Embular.js in 2016!! Change the world!
What I'm hoping for is that the incredibly brilliant minds behind these two efforts see the light and join forces. Even work with the folks designing ES6/7 and the future of HTML/DOM...
What I'm hoping stops is the "my framework is better than your framework because _______." silliness.
Well, I was going to say something good about it, but nothing comes to mind. To be fair, we've built some pretty complex applications on it, so clearly it can be made to work. It just doesn't feel natural, and you have to work around a lot of issues.
For some of the mobile development, we evaluated Angular, Knockout, and even briefly Meteor, but there was a desire for pre-canned view components available in the framework instead of writing HTML snippets/templates. It's too bad, because I really liked Angular and Ember (I didn't personally look at Meteor). I'm hoping to be able to use one of these on future projects.
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.)
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 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.
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 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've recently been working on a glorified FAQ that would be very helpful if you decide to go the batman.js route: https://www.softcover.io/read/b5c051f3/batmanjs_mvc_cookbook
And I'd love to add to it -- just drop by #batmanjs on freenode! (ps, I kept trying to vote but I didn't see the thing go up ... and I even made a HN account just for the occasion!)
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.
There are a few types of javascript styles that I've found are pretty common.
- Event Based (jQuery-esq) - Class Based with router (backbone, marionette, et al) - Declarative with routing (Ember, Angular)
Of those, I think the declarative applications tend to build out into easy to maintain systems. State management is easier, extending is easier, and most tend to build easy to digest components that are small and cohesive.
I've found that Ember scratches a number of itches for me when it comes to building out a declarative system. The biggest win for me is the fact that Ember's router is a really, really fantastic bit of engineering. The way that you can build out state into your router and have classes and components that react to those state changes is a super elegant way to develop web applications, for me. Combined with the outlet system for managing complex view trees, and it's a slam dunk.
Ember's system of routes, controllers, and views help me maintain single responsibility principles, because I have a clear definition of what a route does, what a view does, and what a controller does. Things are even easier when you get down to the refactor stage and start moving everything you possibly can into components (which are forward compatible with the upcoming specifications for web components).
The only reservation is that, because the style of MVC that ember follows, the learning curve can be a bit drastic. They've been solidly improving since 1.0 dropped and the wealth of materials out there that are outdated or old (pre RC days) are dropping off of the SERPs pretty rapidly.
Ember's a joy to work with. For 85% of the web applications out there, you probably won't need to venture out of the framework all that much. However, when you DO need to venture out of the framework, it can be a really frustrating experience. The primary example would be integrating something along the lines of D3 or Three.js, or honestly any library that expects to manipulate the DOM directly, as ember's reliance on handlebars is pretty complete. This means that having a view class manage user interaction events really can't be decoupled from the rendering of the view itself, which I feel like is ember's biggest issue right now. Secondarily, there is a personal need for better hooks for view lifecycle events, for providing things like animations / transitions in and out. animated-outlet is a potential solution, but I'd much rather do it the 'ember way' with hooks I can define in my controller classes rather than using a one-size-fits-all style solution (which is what I feel like animated-outlet is).
Don't let these things detract you from really diving into Ember. It's honestly a super refreshing and highly efficient way to build javascript applications. The state management of URLs within the router as well as the very clear and well enforced separation of concerns helps reduce code rot and smells before they even get started. Once you're past the initial learning curve, you'll be shocked at how rapidly you can develop robust, focused applications.
Hoping to get some video tutorials up in the next day or two.
I'm a junior developer (if that), and I've found the strong opinions and conventions of Ember very refreshing.
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.
also DocPad for static sites with more content than code.
WindowBuilder is free and allows really good GUI construction.
It's blazingly fast.
disclaimer: I work for famous.
I'm using sails.js (on top of express.js and node.js) for an MVC app
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