Live data from Hacker News

Rant: Backbone, Angular, Meteor, Derby

gist.github.com

141–150 of 163 posts

Re: Rant: Backbone, Angular, Meteor, Derby

#141
post #77
post #14

Try knockout. I wrote a quick intro to it a few days ago: http://returnbooleantrue.blogspot.com/2012/12/architecting-k... I personally don't like backbone that much. I don't know why so many people love the damn thing. It is hard to understand and not even that great.

What don't you like about Backbone? I never hear anything constructive or even a solidly coherent argument from its detractors

Backbone is pretty much a classic MVC, You define your data-model, your views(HTML) and than connecting all together in the controller.

It's an old and trusty way of doing GUI, but it require you to define your UI(views) in two places - HTML and js code. You must have hardcoded HTML references in your JS code(via CSS selectors & etc), and for every change you do in your view you have to check(and probably change) your js code as well - and vice versa.

Where in MVVM based frameworks(e.g. knockout) you define your view only once - in your HTML file. Your view contains everything that is needed to render the data in your View Model, and can initiate changes to the view model(and render any change that is being made to the date in the view model). There is never a need to use hardcoded references to the HTML in your js code.

Re: Rant: Backbone, Angular, Meteor, Derby

#142

I switched from backbone to angular about half a year ago. It was the best thing that ever happened to the project I was working on. I've rebuilt the complete interface using angular in 2 days. The original backbone version took me weeks (I learned both frameworks from the ground up while writing the interface) It was just a joy to see how databinding and promises where working hand in hand to make my life as a devel…

As a person that switched from Backbone to Angular, can you explain models in Angular (from a Backbone standpoint)? I've looked over the docs, and as far as I can tell there really isn't a model in Angular - not anything concrete anyway. The docs seem to explain that any JS object is a model as long as you make some reference to it. Or, is an angular Controller (+ some JS data structure) really a model. Its quite con…

I can't explain in terms of Backbone but I'll do my best to clear things up for you anyway. In Angular, you have a magic $scope variable that is available both in your controller function, and in the section of HTML that the controller is bound to. Now I can set any attributes I want to the $scope variable and they will act like models for that controller.

For example. Within my controller, I set $scope.username to "alex" and this will update any HTML bound to the value "username", within the scope, to "alex". Similarly, I can set, say, $scope.settings = {user: {username: "alex"}} and this will update any HTML elements (within the scope) bound to settings.user.username to "alex".

These are very simple examples, but they show the beauty of having plain JS objects as your "models".

Re: Rant: Backbone, Angular, Meteor, Derby

#143
post #96

Earlier quoted context omitted.

What does Knockout, Angular, et al give you that Backbone doesn't? It seems like most of the anti-Backbone comments are about it being unable to "scale", which is funny considering Hulu, Trello, SoundCloud and about a hundred other very large apps use it just fine. I have yet to see any of the other frameworks deployed to the that scale at all (where are the examples ?)

What they give you actual two-way binding for DOM manipulation and rendering between client and model. They also, generally speaking, place very few requirements on your model which is a very good thing. Angular is exceptionally flexible and one of the first tools for building client-side JS that really impressed me. That said it is fairly complex (and not that well documented) when compared to Backbone, so I can und…

There are plenty of two-way DOM binding add-ons for backbone.

OutbackJS makes it work like Knockout, but maps onto backbone models (disclosure: I wrote this one). Most of my models in production apps have zero complexity - a url property is usually all that distinguishes them, and outback bindings means that I a) don't have to litter my code with jQuery nonsense, and b) don't really have to muck with models beyond fetching and saving them.

[1] https://github.com/politician/outback

Re: Rant: Backbone, Angular, Meteor, Derby

#144
How did this get so many upvotes? It's a short rant that basically boils down to "Fuck Backbone, use Angular instead"

In fact, here is a verbatim quote: "Angular is awesome. That is all."

And here's the technical basis of why Angular is better than Backbone: "Now, I'm not suggestion people don't use Backbone. Use it if it's what's needed for your project, or you yourself are a Backbone ninja. What I'm discouraging here is its popularity as the de-facto client MV*"

I've played around with Backbone and appreciate its structure. I've never used Angular but have seen many compelling posts on HN arguing why it is a better choice in certain use cases. This rant offers no evidence or elaboration. Is it now cool just to hate the popular thing just because it's popular? Even rants against Facebook and Apple have more substance than the OP.

Re: Rant: Backbone, Angular, Meteor, Derby

#145
post #77

Earlier quoted context omitted.

What don't you like about Backbone? I never hear anything constructive or even a solidly coherent argument from its detractors

Backbone is pretty much a classic MVC, You define your data-model, your views(HTML) and than connecting all together in the controller. It's an old and trusty way of doing GUI, but it require you to define your UI(views) in two places - HTML and js code. You must have hardcoded HTML references in your JS code(via CSS selectors & etc), and for every change you do in your view you have to check(and probably change) you…

There is a multitude of two-way DOM data binding add-ons for Backbone.

Re: Rant: Backbone, Angular, Meteor, Derby

#146
post #56

Earlier quoted context omitted.

I have the same question as @hnwh: I'm using Knockout and really, really like it (more suited to my way of working than say Backbone), but considered that Angular could be a more advanced/featureful Knockout. Can you elaborate a bit? Thanks!

If you use Knockout please consider being more vocal about it. It is a fantastic mini-framework/library but doesn't have the crazy PR behind it like backbone. Angular is great but the problem is you really need to use client side templating for it to be useful. It also has the same syntax as django's template language by default. All this is workable but Angular is great for projects that you are starting. Knockout i…

Thanks to all in this part of the thread for talking so pretty about Knockout - it got me to try incorporating it tonight on a simple interactive page I started recently, and it's a pleasure to use so far. Works nicely in combination with coffeekup, which I also enjoy a lot.

Re: Rant: Backbone, Angular, Meteor, Derby

#147
I'll chime in with the requisite "90% of the time, don't use an mvc framework in the browser." Don't build up a mountain of state for no reason. Use functions and composable, lightweight, short-lived classes.

If I had to choose the 'best' javascript development framework, I'd choose clojurescript, not because it's such a great tool in itself (it is a great tool, though still a bit immature), but because it forces the developer to write javascript in the best possible way: functionally, only holding onto state when it's absolutely necessary.

It's good that there are solid mvc frameworks out there for when they are truly needed, but when the average developer picks one up for a routine web app just because it's the hot new thing, he/she's walking into a minefield for no good reason. Javascript is at its best when it's just a dumb, fast bridge between your server and your ui.

Re: Rant: Backbone, Angular, Meteor, Derby

#148
post #80

Marionette (a framework built on backbone) offers a nice solution. It still keeps things pretty light but does a lot of the groundwork you would normally have to do with backbone for you. Eg cleaning up event bindings, provides a region/view manager and an application wide event bus.

I'd also recommend looking into Chaplin for stronger routing / app design. It's got a great CollectionView, which is one of the most common use cases for Backbone (also seems to solve a lot of the gripes with plain Backbone

Chaplin is a mess. I need node, npm, build a bunch of stuff from scratch? I've already lost interest (I looked at Chaplin a few months ago and honest to God couldn't even figure out what the hell it did besides download various crap to a /lib/ dir. Aren't there six dozen tools that do that?)

Re: Rant: Backbone, Angular, Meteor, Derby

#149

"It seems that most people today, when thinking about their next JS project, will use Backbone because it's the most popularl framework when it shouldn't be." (sic) Here's a long list of examples why maybe it should be: http://backbonejs.org/#examples In comparison, here's the public list of interesting apps built with Angular and Derby: http://builtwith.angularjs.org https://github.com/codeparty/derby/wiki/Community…

Backbone tries to provide the barest useful essentials -- the main business of building your app is up to you.

I personally prefer minimal frameworks because they don't assume what your finished product will look like. You can grow the application organically rather than trying to fit it into some prototypical mold. Full-fledged frameworks have their uses - they are perfect for getting up and running on known problems. But if you are trying to bake things into an already mature code base or trying a totally different style of architecture, they are not worth the work.

Re: Rant: Backbone, Angular, Meteor, Derby

#150
post #144

How did this get so many upvotes? It's a short rant that basically boils down to "Fuck Backbone, use Angular instead" In fact, here is a verbatim quote: "Angular is awesome. That is all." And here's the technical basis of why Angular is better than Backbone: "Now, I'm not suggestion people don't use Backbone. Use it if it's what's needed for your project, or you yourself are a Backbone ninja. What I'm discouraging he…

It got upvotes (1) because nobody's talking about Meteor v Derby, (2) because people agree. I'm not the only one wondering why Backbone is de-facto - look at all these responses, 80% of them are agreement. That surprised me, I thought this thread would be buried. Many (like you) think this as insular and inane. I left out detailed explanations of Backbone cons and Angular pros just to get the conversation rolling, and indeed the comments took care of that entirely.
Post reply on HN