Spine seems to have given up the separation between Controller & View. Backbone has a great separation here that has been a great aid to me in refactoring a large application. (+1 Backbone)
Backbone treats collections of Models (Backbone.Collection) as proper first-class citizens. Collections can receive & emit their own events, handle their own serialization/fetching, and make use of all Underscore.js methods (+1 Backbone)
Other than that they seem pretty similar to me. So my verdict: Spine +1, Backbone +2 :)
> Spine seems to have given up the separation between Controller & View.
Controllers are supposed to coordinate the interactions between views and models by propagating changes and events between the two.
For example, if you had a todosController responsible for controlling a collection of views, there isn't really a clean way (in my opinion) to utilize it from two independent Backbone views without passing the controller through to the view (which makes the view depend on the controller). By handling events in the controller instead of in the view, you remove this dependency (which is also similar to my perception of Cocoa's delegates/SproutCore's bindings, but I may be wrong).
Both Spine's and Backbone's view layer consists of rendering templates to the DOM. To me, a "proper" view layer would include things like positioning and both frameworks seem to utilize CSS to do this, for the most part.
I think of Backbone's controllers as a poor man's State chart, without any enter or exit callbacks (e.g going from "#/" to "#/todos" should trigger a callback that states that I will exit the state "#/", so I can do necessary cleanup).
In my experience Backbone Views become the "top level" of a client-side app, but that is appropriate because they encapsulate controller logic.
I guess I just dislike the convention of interacting directly with collections from places where it shouldn't be done, e.g a todoView removing its own Todo from the collection (hence the risk of duplicating functionality throughout your code), instead of asking a proxying controller to do it. I think this is the reason as to why I've seen a lot of Backbone code where a reference in to the view is stored in the model itself (e.g http://documentcloud.github.com/backbone/docs/todos.html), which disgusts me since it completely misses the point of MVC.
Also, events passing feels more complicated than it would need to be (even if you can always include Backbone.Event).
The key architectural difference seems to be that the ui is updated before the server responds, which is great in a single user situation, but can get pretty inconsistant once you're in a multi user app.
I do have to say that I like the patterns section at the end, it's always good to see a prescription for how you would use a library or framework.
Seems neat, but it would have been nice to differentiate itself from backbone a little more upfront. The sites even look similar.
Upon reading more about it, it sounds like a really nice framework.
A shame it is branded so similarly to backbone which is bound to result in people fighting about which is better, spine or backbone, instead of seeing it for its own merits.
But it's definitely on my list of nice things to try.
Open source isn't a zero-sum game, the more you share, the more you have to give away.
By introducing a too-similar competitor, (in general, not necessarily Spine) you risk fragmenting the above, which leads to many okay projects, not one great projects.
It's unreasonable to suggest that anyone who has an idea for a project simply abandon it because someone's already working on something similar. It's also unreasonable to suggest that if they do end up writing something really cool that touches on a few concepts of an existing project, that they should keep it to themselves.
In backbone the dom events are tied to the view which makes it more difficult to reuse the logic with other views. I've worked around this by doing pretty much the same thing as spine; i've created a dom controller from the base controller, but it's not ideal since the controller was specifically designed for hash change events.
Both have DOM events, a "this.el" property, a "this.$" selector, and event delegation. The patterns of use should be the same.
Can someone explain this to me? I've been using prototypal inheritance through Closure's goog.inherits() and never had any problem using regular object constructors.
This article is a great explanation on issues with prototypal inheritance http://howtonode.org/prototypical-inheritance
At the top of the FAQ, he answers some of the comparison questions: http://maccman.github.com/spine/#h-faq
The bit about it being smaller is pretty misleading (especially when comparing 2k to 3k) -- it may be 500 lines instead of 1100, but the 1100 are heavily commented, and the 500 are entirely comment-less. It also doesn't include any of the collection mapping, filtering, and aggregation functions, which contain a large part of the usefulness of Backbone when used with real models.
That said, competing so closely with an Ashkenas library is not a niche I'd want to be in...
... which, even when natively implemented, is quite a bit slower than the real thing:
> Whoah - your API looks really similar to Backbone. Why should I use this instead?
> Well, it's true that Spine was inspired by Backbone, an excellent library, and its controller API is very similar. However, the similarities end there. Internally the library works very differently. For example, Spine has no need for Collections, which are required for pretty much every model in Backbone. Spine provides a class library, and has very different ideas when it comes to server sync. Lastly, Spine is much simpler and half the size, go and check out the source.
"Well, it's true that Spine was inspired by Backbone, an excellent library, and its controller API is very similar. However, the similarities end there. Internally the library works very differently. For example, Spine has no need for Collections, which are required for pretty much every model in Backbone. Spine provides a class library, and has very different ideas when it comes to server sync. Lastly, Spine is much simpler and half the size, go and check out the source."
Copying the website element for element and 90% of the design paradigm from backbone.js would have been semi-acceptable to me if the author elaborated more on the comparison between backbone in his FAQ.
"Lastly, Spine is much simpler and half the size, go and check out the source."
"Much simpler" seems like a huge call to make and it has been nice to see Jeremy refute all claims by spine.js thus far.
Edit: Also I don't think Backbone.js should receive any negative points for naming conventions. MVC has such a diluted definition that it barely matters how a framework chooses to implement it.