Live data from Hacker News

Backbone.js: Hacker's Guide

dailyjs.com

21–30 of 40 posts

Re: Backbone.js: Hacker's Guide

#21
post #18
post #17

Earlier quoted context omitted.

Have you used it? How did it work out?

I'm using it on a project right now. It's my first project with it, but so far so good. The tutorial is quick and straightforward, and it really gives you a flavor for it ( http://docs.angularjs.org/tutorial/ ). AngularJS is a lot like Knockout, without the ko.observables everywhere.

Neat. I don't love the ko.observables, but as an alternative to having to have objects fit into a predefined structure/class hierarchy, they seemed like a good tradeoff.

Re: Backbone.js: Hacker's Guide

#22
post #18
post #17

Earlier quoted context omitted.

Have you used it? How did it work out?

I'm using it on a project right now. It's my first project with it, but so far so good. The tutorial is quick and straightforward, and it really gives you a flavor for it ( http://docs.angularjs.org/tutorial/ ). AngularJS is a lot like Knockout, without the ko.observables everywhere.

I've been using Angular in a few prototypes and ran across funky problems using their routing in HTML5 mode with IE9.

Theoretically their router should prepend the hash fragment to the URL, but it gets stuck in a redirect loop and hangs the browser. The workarounds I've found so far are to use hash style URLs or not use a default route, neither of which are optimal. (Edit: updating to 1.0.1 fixes the problem as long as your "otherwise" route is a defined route)

Version 1.0 (they are currently on 1.0.1) of the framework broke their website for IE users, which makes me a little nervous about the level of cross-browser testing that the framework uses. Their documentation is sparse in some areas, which is an annoyance more than anything (the source is fine to read, but be forewarned that it's not a small project by any stretch of the imagination).

On the plus side, not having to litter ko.observable everywhere was nice, their concept of services (for working with REST endpoints) is great, and it's been pretty easy to break everything up into maintainable modules.

Re: Backbone.js: Hacker's Guide

#23
post #5

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

Here's my iconoclast answer (with a further caveat that I'm a systems programmer who follows web development in my spare time, not an expert on any of this): Backbone (or Spine, which is just like Backbone but a tiny bit smaller and written in CoffeeScript) is Yet Another MVC Framework. So think of it like Rails, except this time it runs in the client browser. So instead of translating between SQL and Ruby, you're tr…

You certainly have strong opinions for someone with no idea what they're talking about. Here[1] is the official backbone documentation. Please, point out the "Controller" objects.

While you're looking for that, maybe you should consider leaving the explanation of a technology to people who have taken the time to learn something about it.

[1] http://backbonejs.org/

Re: Backbone.js: Hacker's Guide

#24
post #8

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

I used Knockout.js on a project before switching over to Backbone. My experience was that while Knockout is great for simple projects, it becomes a lot more complex than Backbone once things get complicated. All those data-binds in the HTML get really annoying and the application becomes difficult to maintain. I like my templates clean.

Backbone takes care of syncing your data with the server, provides you with an event system so you can subscribe to changes, gives you a sane convention for how to structure your views and then gets out of your way. It's also easy to extend, so you could write your own data-binding system if you really need it. A simple 1-way data-bind is quite easy to implement.

If you aren't writing a single page app and only need to make a primarily static page more interactive, Knockout is probably the right choice. If you are writing a single page app, you often need to sync your models and collections with the server, or if your UI is very complex, Backbone is probably better.

Re: Backbone.js: Hacker's Guide

#25
post #8

Earlier quoted context omitted.

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

I used Knockout.js on a project before switching over to Backbone. My experience was that while Knockout is great for simple projects, it becomes a lot more complex than Backbone once things get complicated. All those data-binds in the HTML get really annoying and the application becomes difficult to maintain. I like my templates clean. Backbone takes care of syncing your data with the server, provides you with an ev…

I believe you, but would just say that for me, syncing data between the browser and the server is pretty easy; it's syncing data to the DOM that's challenging. I totally believe Backbone is great that that, but it makes design tradeoffs for syncing to the server too, and I just found no benefit from that.

Anyways, I think we're saying the same thing. The question: how is Backbone better than jQ; many answers; Ko.js as a middle ground.

Re: Backbone.js: Hacker's Guide

#26

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

Sure thing. But first, for the "kinds of things" that Backbone helps with, take a quick scroll through the list of examples available here: http://backbonejs.org/#examples Here's a bit of typical (if exaggerated) jQuery to render/update the UI for a list of "accounts": $(".account").each(function(){ var id = $(this).attr('data-id'); var data = window.accountJSON[id]; $(this).find(".name").text(data.name); for (var i…

Ask and ye shall receive. An answer from the library author. Doesn't get much better than that.

Re: Backbone.js: Hacker's Guide

#27

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

jashkenas went over a lot of this in the State of the Backbone at Backboneconf. Regretfully you can't see all of the examples in the video... but you can hear his description here: http://blog.documentcloud.org/blog/2012/06/state-of-the-back...

http://www.youtube.com/watch?v=yDmRRJzTo38 did OK with getting some of the examples in. No idea how they grew the arm of steel for holding that iPhone up though..!

Re: Backbone.js: Hacker's Guide

#28
post #16
post #8

Earlier quoted context omitted.

I had the same question after trying to use Backbone on a couple different small projects and giving up after seeing it introduce more complexity that I saw it removing. Recently, I discovered Knockout.js, which is a "competitor" to Backbone with what I think is a clearer interface and a much clearer value proposition. I've had a lot of success with Knockout and fully expect that, like Sinatra did to me with Rails, K…

Recently I discovered AngularJS ( http://angularjs.org ) by some of the guys at Google. I spend most of my time on the backend and have never been a fan of JavaScript, but the AngularJS declarative design really caught my eye. It's so clean and so simple. I think it's brilliant. See http://www.youtube.com/watch?v=elvcgVSynRg

I've been using AngularJS too.

Wow, it is nice...

Re: Backbone.js: Hacker's Guide

#29

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

I found this talk from BackboneConf helpful:

http://opensoul.org/blog/archives/2012/05/16/the-plight-of-p...

It basically expands on what Jeremy said.

Re: Backbone.js: Hacker's Guide

#30
post #5

Could anyone show me what kind of problems Backbone.js solves? Not a description like “it will replace a lot of your jQuery spaghetti boilerplate”, but some actual code: //this is what I had to write in jQuery … … //this is how I'd do it in Backbone.js

Here's my iconoclast answer (with a further caveat that I'm a systems programmer who follows web development in my spare time, not an expert on any of this): Backbone (or Spine, which is just like Backbone but a tiny bit smaller and written in CoffeeScript) is Yet Another MVC Framework. So think of it like Rails, except this time it runs in the client browser. So instead of translating between SQL and Ruby, you're tr…

You should try Backbone.js. While I do appreciate your general sentiment about the cultures, you should try it first. It's not really as big a deal as you're making it out to be. It's actually pretty small and doesn't do that much. You can make views using lightweight templates or not, your choice.

The main issue in my view is that most of the examples out there are just too simplistic. But it's too light to be considered an indoctrination platform like Rails or something like that.

Post reply on HN