Live data from Hacker News

Backbone has made me a better programmer

floatleft.com

61–70 of 88 posts

Re: Backbone has made me a better programmer

#61
post #52
post #22

I didn't really like backbone at all. It was a pain. It didn't offer anything to help you build complex UI. I had to use backbone to build a mildly complicated UI - not so complex, mind you, just something that's supposed to be somewhat interactive. Backbone was no help at all. Its "views" don't really offer anything. Just about 2 weeks ago I discovered knockout.js, and I felt stupid for spending days building someth…

I've built moderately sized applications in both angular.js and backbone, backbone is much more pleasant to work with if only for the fact that everything is obvious , even if that requires you to do more development legwork and thinking about your application structure. (this is a feature, not a bug) Angular.js data bindings are great and things like ng-repeat are neat until you start to step outside of the bounds o…

"If you want to use jQuery for ajax, for instance, you lose all data bindings because vanilla javascript doesn't have the angular secret sauce!"

Data bindings should work as normal...if you're running into issues, try using $scope.$apply().

Angular uses jQuery, internally, so there are events you can hook into -- jQuery events.

And comparing the complexity of Angular and Backbone's internals is a bit misguided. They aren't meant to solve the same problems. Angular is complete Javascript application framework, and Backbone isn't. To use a non-foolproof analogy, if Angular were Rails, Backbone is Sinatra.

Re: Backbone has made me a better programmer

#62
post #52

Earlier quoted context omitted.

I've built moderately sized applications in both angular.js and backbone, backbone is much more pleasant to work with if only for the fact that everything is obvious , even if that requires you to do more development legwork and thinking about your application structure. (this is a feature, not a bug) Angular.js data bindings are great and things like ng-repeat are neat until you start to step outside of the bounds o…

"If you want to use jQuery for ajax, for instance, you lose all data bindings because vanilla javascript doesn't have the angular secret sauce!" Data bindings should work as normal...if you're running into issues, try using $scope.$apply(). Angular uses jQuery, internally, so there are events you can hook into -- jQuery events. And comparing the complexity of Angular and Backbone's internals is a bit misguided. They…

I wasn't aware of $scope.$apply, should help simplify some of my angular stuff. Thank you :)

Re: Backbone has made me a better programmer

#63
post #37

When we started using Backbone it was good for awhile until there was so much code duplication all over the place. We decided to build a small declarative API on top of backbone that allows us to easily compose views by mixing in common functionality. It looks something like this: AlbumsView = bQuery.view() .set("el", "#albums-view") .init((opts={})-> @readOnly = opts.readOnly or no @app = opts.app ) .use(Mixins.bq.i…

What's the point of this excessive chaining? I use CoffeeScript a lot, but your code looks unreadable to me.

I think code verbosity (which anyone can read and understand) is highly underestimated these days. I don't think writing less lines of code is any good if you need to explain to people what you did (yes, even smart people sometimes don't figure it out right away if they didn't use a similar library / concept before, and you don't always have smart people reading your code anyway, we all know that)

If you optimize your code to avoid any duplication, you are probably wasting more time writing / extending libraries, doing pull requests than getting working software done.

Refactoring, and good design is critical, helpful, almost mandatory, but if your feature is not out there on time because you over refactored / engineered your code, and some other startup get's it out there faster, no user will care.

users don't do view source before they pay you.

Re: Backbone has made me a better programmer

#64
post #14
post #13

Totally agree with this post - I was a 'JavaScript =~ jQuery' guy before I picked up Backbone - writing hopelessly average jQuery spaghetti (with the best of intentions - I'm a designer and had never looked at JS as a programming language. Backbone has totally changed all of that - learnt so much about design patterns in such a short space of time - shout out to Addy Osmani for writing such down-to-earth, approachabl…

I also agree, although instead of Backbone I recently found that Twitter Bootstrap's javascript files offer similar insights as to how to structure code in an javascript-style object oriented manner. For example: https://github.com/twitter/bootstrap/blob/master/js/bootstra...

  matcher: function (item) {
    return ~item.toLowerCase().indexOf(this.query.toLowerCase())
  }
Why there is "~" bitwise operator used in this method?

Re: Backbone has made me a better programmer

#65
post #52
post #22

I didn't really like backbone at all. It was a pain. It didn't offer anything to help you build complex UI. I had to use backbone to build a mildly complicated UI - not so complex, mind you, just something that's supposed to be somewhat interactive. Backbone was no help at all. Its "views" don't really offer anything. Just about 2 weeks ago I discovered knockout.js, and I felt stupid for spending days building someth…

I've built moderately sized applications in both angular.js and backbone, backbone is much more pleasant to work with if only for the fact that everything is obvious , even if that requires you to do more development legwork and thinking about your application structure. (this is a feature, not a bug) Angular.js data bindings are great and things like ng-repeat are neat until you start to step outside of the bounds o…

There is a good reason for this http://stackoverflow.com/questions/3503102/what-are-top-leve...

Besides the official JSON spec doesn't support JS top-level arrays.

Re: Backbone has made me a better programmer

#66
post #62

Earlier quoted context omitted.

"If you want to use jQuery for ajax, for instance, you lose all data bindings because vanilla javascript doesn't have the angular secret sauce!" Data bindings should work as normal...if you're running into issues, try using $scope.$apply(). Angular uses jQuery, internally, so there are events you can hook into -- jQuery events. And comparing the complexity of Angular and Backbone's internals is a bit misguided. They…

I wasn't aware of $scope.$apply, should help simplify some of my angular stuff. Thank you :)

You're welcome. :)

Re: Backbone has made me a better programmer

#67
Am I the only one who still makes websites with very little JS in them? One jQuery thing here and there. Using Backbone would be overkill and to be honest I can't think of one hypothetical project where I would need it.

Re: Backbone has made me a better programmer

#68

Earlier quoted context omitted.

I'm afraid that advice is about 180 degrees away from the truth. If you look at the kinds of large scale projects that people are building with Backbone: http://backbonejs.org/#examples ... or the new Hulu.com, from earlier this week -- I'm not aware of any of the sites on that list using any of the libraries you're recommending.

@jashkenas Those sites use their own custom libraries that do about the equivalent of what the libraries I suggested use. I say this not out of any disrespect, I love backbone, but backbone doesn't provide enough to build a complex app. Does it have memory management? No. Does it provide a pub/sub pattern? No. Does it handle views/nesting subviews and layout management? No. You can roll your own library, of course, i…

This might be something that you're thinking people should work towards... Aura (http://addyosmani.github.com/aura/ ) "an event driven architecture built on top of backbone"

Re: Backbone has made me a better programmer

#69
post #37

When we started using Backbone it was good for awhile until there was so much code duplication all over the place. We decided to build a small declarative API on top of backbone that allows us to easily compose views by mixing in common functionality. It looks something like this: AlbumsView = bQuery.view() .set("el", "#albums-view") .init((opts={})-> @readOnly = opts.readOnly or no @app = opts.app ) .use(Mixins.bq.i…

I'm so glad that this is the current top comment. Backbone apps are the most verbose and non-DRY apps in my experience. Tons of code duplication.

Re: Backbone has made me a better programmer

#70

Earlier quoted context omitted.

@jashkenas Those sites use their own custom libraries that do about the equivalent of what the libraries I suggested use. I say this not out of any disrespect, I love backbone, but backbone doesn't provide enough to build a complex app. Does it have memory management? No. Does it provide a pub/sub pattern? No. Does it handle views/nesting subviews and layout management? No. You can roll your own library, of course, i…

> Does it have memory management? JavaScript has memory management; JavaScript has a garbage collector. If you structure an app (with any library) not to leak references, then no manual memory management or bookkeeping is needed. Not having additional memory management is a feature, not a bug. > Does it provide a pub/sub pattern? Yes. That's Backbone.Events, which is the core how models work with changes, and can be…

I'm not sure if this is something that could be helped with some doc changes, but it took me awhile to figure out that pubsub is exactly what Backbone.Events gives you. And even then, I only figured that out from reading tbranyen's code.
Post reply on HN