Live data from Hacker News

Coding the Angular Tutorial App in Backbone

blog.42floors.com

31–40 of 71 posts

Re: Coding the Angular Tutorial App in Backbone

#31

One thing this tutorial / thing doesn't highlight is that Angular is ~800 KB (unminified, ~200 KB gzipped, including some modules), versus Backbone's ~60KB (unminified, ~20KB gzipped). So it does take 240% more lines of code to do sort of the same thing as the angular tutorial, but the angular library is 1000% as big. If my math's correct. (disclaimer: I like Angular, and for big projects like the one I've worked on,…

I don't know we're you're getting those numbers - angular is 36k minified, backbone is ~10, and includes much less code (no rendering/binding library etc). Still a nontrivial distance, but a far cry from 700kb/10x

Re: Coding the Angular Tutorial App in Backbone

#32

Earlier quoted context omitted.

That's sort of a weird way to frame it. I could make the same argument against Angular: "I want to write a bunch of gross code to perform dirty checking of objects to keep everything in sync" said no UI developer ever. That's the point of libraries and frameworks. They do the repetitive or "ugly" or "hard" things that we don't want to do over and over.

> "I want to write a bunch of gross code to perform dirty checking of objects to keep everything in sync" said no UI developer ever. Except that this is in no way an equivalent comparison. With Backbone, you actually have to write the hundreds of callbacks in your application code . Whereas with Angular, you attach a value to a scope, and declare it in a template. In that case, the framework actually does take care o…

My fault. I guess I misunderstood the point being made.

Re: Coding the Angular Tutorial App in Backbone

#33
post #27
post #13

This is really useful and good, esp since the source is on GH. Thanks for putting it together, OP! That said, lines of code is really the wrong metric to gauge the merits of the frameworks. Fewer lines of code may mean better abstractions, but it also may mean more 'magic'. A metric that may be more useful would be to have one developer write half the project and have another finish and then compare the time they tak…

I think LOC is actually a great proxy measurement of productivity. 3x the code is 3x the code that can break and 3x the code you have to wade through while debugging or adding features. I see what you're getting at with "magic" abstractions, but it's like comparing Python and C. I don't know everything that happens under the hood in Python off the top of my head, but I also don't care. I could learn it if I needed to…

The difference here is that in Python vs C, you almost _never_ actually need to know what's going on under the hood[1]. Whereas in every framework I've _ever_ used, I eventually need to dig into the guts of them because of some leaky abstraction. For instance, automatic data bindings are great until you want to do animation[2].

I do agree that LOC for a _non trivial_ application is a reasonable measure, though I disagree that Angular:Backbone is Python:C.

[1]: Serious performance optimization is the exception here, but in building CRUD apps, this honestly did come up infrequently, and usually the right thing to do was to improve algorithmic complexity or fix slow DB queries, not fix python constructs that were unexpectedly slow.

[2]: I haven't spent much time with Angular specifically, but definitely remember this being difficult in other automatically bound frameworks, like Meteor in its initial release.

Re: Coding the Angular Tutorial App in Backbone

#34
post #4

A better comparison would be Angular vs Backbone Marionette or vanilla Angular (no pre-built directives) vs backbone. I'm looking at you ng-repeat. I love angular as much as the next person, but comparing two frameworks by LoC does not do much to move the discussion along.

Or Angular to EmberJS

Re: Coding the Angular Tutorial App in Backbone

#35
post #31

One thing this tutorial / thing doesn't highlight is that Angular is ~800 KB (unminified, ~200 KB gzipped, including some modules), versus Backbone's ~60KB (unminified, ~20KB gzipped). So it does take 240% more lines of code to do sort of the same thing as the angular tutorial, but the angular library is 1000% as big. If my math's correct. (disclaimer: I like Angular, and for big projects like the one I've worked on,…

I don't know we're you're getting those numbers - angular is 36k minified, backbone is ~10, and includes much less code (no rendering/binding library etc). Still a nontrivial distance, but a far cry from 700kb/10x

Continuing this point, Backbone requires rendering, binding, and probably relational models libraries. Not to mention the boilerplate and configuration code you have to write to tie all those libraries together. Less may end up being more.

Another point is that with all those libraries, how do you sanely manage the security and quality of your application? With the exception of just a few - almost every Backbone add-on library I've tried is badly programmed (un-SOLID / weird JS / no tests), not documented enough, and unmaintained solo-projects that just so happen to be on GitHub.

Re: Coding the Angular Tutorial App in Backbone

#36

> but I’m really fond of the less restrictive nature of Backbone, so I’ll probably end up sticking with Backbone. Backbone is terribly devious in that it tricks you into thinking that it is unrestrictive and unopinionated. Backbone manages state with mutable models and model change callbacks, so Backbone's opinion naturally is that models and change callbacks are a good way to organize your application. "I want to wr…

Yes. Backbone basically supplies CRUD mapping and an event bus. So it is opinionated about models. But CRUD is a solved problem that's easy to implement, and view / controller code ends up being the bulk of your application. I'd rather my framework give me a little help there. CRUD is even kind of an anti-pattern, because it prevents you from doing relations in your relational database.

> CRUD is even kind of an anti-pattern, because it prevents you from doing relations in your relational database.

I'm not sure I get this. How are the two things connected? i.e. why can't CRUD honour relations? (Django's admin does auto-CRUD and handles relationships moderately well - at least to one level of nesting)

Re: Coding the Angular Tutorial App in Backbone

#37
post #33
post #27

Earlier quoted context omitted.

I think LOC is actually a great proxy measurement of productivity. 3x the code is 3x the code that can break and 3x the code you have to wade through while debugging or adding features. I see what you're getting at with "magic" abstractions, but it's like comparing Python and C. I don't know everything that happens under the hood in Python off the top of my head, but I also don't care. I could learn it if I needed to…

The difference here is that in Python vs C, you almost _never_ actually need to know what's going on under the hood[1]. Whereas in every framework I've _ever_ used, I eventually need to dig into the guts of them because of some leaky abstraction. For instance, automatic data bindings are great until you want to do animation[2]. I do agree that LOC for a _non trivial_ application is a reasonable measure, though I disa…

automatic data bindings for animation are still great though, and its internals should definitely always be hidden from user-land, but I totally agree with you, performance and ease-of-use vary wildly in javascript-land and needs to get better.

Re: Coding the Angular Tutorial App in Backbone

#38

> but I’m really fond of the less restrictive nature of Backbone, so I’ll probably end up sticking with Backbone. Backbone is terribly devious in that it tricks you into thinking that it is unrestrictive and unopinionated. Backbone manages state with mutable models and model change callbacks, so Backbone's opinion naturally is that models and change callbacks are a good way to organize your application. "I want to wr…

Yes. Backbone basically supplies CRUD mapping and an event bus. So it is opinionated about models. But CRUD is a solved problem that's easy to implement, and view / controller code ends up being the bulk of your application. I'd rather my framework give me a little help there. CRUD is even kind of an anti-pattern, because it prevents you from doing relations in your relational database.

> CRUD is even kind of an anti-pattern, because it prevents you from doing relations in your relational database.

Please explain how doing CRUD operations -- which is, after all, what SQL INSERT, SELECT, UPDATE, and DELETE statements are -- prevents you from doing relations in your relational database. Because that's a seriously wierd claim.

Re: Coding the Angular Tutorial App in Backbone

#39
post #26

I am currently writing an app in angular and I really enjoy how it supports my workflow. Before choosing angular I did a very thorough evaluation of Javascript Frontend Frameworks. My stomache told me to use backbone because it is simpler to understand the whole codebase and I personally like to know how something works behind the scenes. Also the built with backbone section is pretty impressive. BUT getting started…

Yeah, that's one of those things that's hard for people to get at first, that the front-end turned out to be a more difficult problem than writing the back-end.

But people judge an app by its cover, so what can we do.

Re: Coding the Angular Tutorial App in Backbone

#40
post #4

A better comparison would be Angular vs Backbone Marionette or vanilla Angular (no pre-built directives) vs backbone. I'm looking at you ng-repeat. I love angular as much as the next person, but comparing two frameworks by LoC does not do much to move the discussion along.

Marionette is terrible. The code is a mess: prototypes defined within instances [0]. Uninformed use of design patterns: controllers are what, just namespaces? [1] Unmodular internals, almost like globals [2].

It's not worth a comparison.

[0] https://github.com/marionettejs/backbone.marionette/blob/mas...

[1] https://github.com/marionettejs/backbone.marionette/blob/mas...

[2] https://github.com/marionettejs/backbone.marionette/blob/mas...

Post reply on HN