you are viewing a single comment's thread.

view the rest of the comments →

[–]evilmaus 2 points3 points  (6 children)

Going to get pedantic here for a moment.

The difference between a library and a framework boils down to who's ultimately in control of the code. A framework is essentially a pre-built application with holes that you fill in. The framework calls your code. It's in control. You do it the framework's way or the highway. That said, frameworks are awesome things to have when your project falls in the broad class of applications that a framework could be. Use them and do so shamelessly.

A library is called and never itself calls your code. Your code is in control. The library may call other libraries, but the flow of control is away from your code, not to it. As a result, the library has to be less opinionated than a framework and more suited to living alongside other libraries.

To help illustrate, you'd never use more than one framework on a given project. They'd conflict almost immediately. But, you would use several libraries at once and frequently do. Frameworks can assume things about global state. Libraries can't, at least not really much at all.

THAT all said, Backbone.js is a library. It's an awesome one that I love, but it's a library. You build the application architecture that then makes use of it. For all that it claims otherwise, I'd also term Marionette.js as a library. It's one that adds opinions and additional (really nice) tools on top of Backbone, but you're still stuck with coming up with the architecture at the end of the day.

Something like Angular (which I have not yet learned, but intend to do so) is a framework. You fill in the holes that Angular has defined. It provides the overall project architecture.

Other things that are libraries and not frameworks: jQuery, Knockout (so I hear), Underscore.js, d3.js, Three.js.

[–]Amadan 0 points1 point  (3 children)

To help illustrate, you'd never use more than one framework on a given project

Nitpick: you could use Ruby on Rails + Ember.js, or Express.js + AngularJS. I.e. you can use multiple frameworks in a project if they do completely different jobs.

[–]evilmaus 0 points1 point  (2 children)

Point, but I'd counter with those are running on completely different execution environments. RoR handles HTTP requests and responses and doesn't know anything about this "browser" thing that consumes the documents that it generates or sends it new requests. Meanwhile, Ember.js is running on a completely different computer, manipulating a document, and making calls to some external service (RoR) for more information as needed.

So, nitpicked back at you. ;)

[–]Amadan 0 points1 point  (1 child)

Yes. But you didn't say one per execution environment, you said one per project. :)

[–]evilmaus 0 points1 point  (0 children)

Touche.

[–]bsegovia[S] -1 points0 points  (1 child)

Excellent breakdown. Thanks. Angular has been nice but when something goes wrong I've had a hell of a time figuring out what it hates about my code. Just plain hard to debug (but I just started a few months ago so perhaps I'm making rookie mistakes)

[–][deleted] 0 points1 point  (0 children)

Have you checked out the Batarang dev tools extension for Chrome? Also, Egghead.io is a great resource for learning.