简体   繁体   中英

Confused about BackboneJS and ExpressJS

I want to create a NodeJS application, and I am learning more about the packages that need to be installed to make development easier. Two packages in particular, ExpressJS and BackboneJS, are confusing me. What is the difference between the two? Backbone provides an MVC structure, but doesn't ExpressJS deal with views and controllers, too? How should I use these two packages in conjunction with each other, or should I even use them in conjunction with each other?

Thanks!

Backbone is a front-end framework. Express is a back-end framework.

To further clarify, you could essentially run Backbone.js stand-alone with no backend support - just HTML, CSS, and JavaScript, and have "page switching" loading HTML templates through hash tag changes and load and save data through cookies or localStorage - but in the end your app needs to talk to a backend services for authenticating a user or saving / restoring data from a database, etc. That's where you'd want Express / node.js to comes in.

You could also do all this stuff without Backbone and just Express (or another backend language / framework), but then all your pages are separate requests to the server (unless you setup something custom on the front-end). Backbone, ajaxes that all out and lets you create templates beforehand, so all you need to request from the backend is plain data objects, and you're essentially only needed to load one page.

This is an oversimplification, but that's essentially it.

If you're accustomed to server-side MVC development, like ASP.NET MVC, Rails, Sinatra, Django, etc, using Express is going to be intuitive.

Backbone stops short of including a view engine, conventions for rendering partials, and that sort of thing. It also includes features like client-side browser history support that don't make much sense on the server-side. Though you could technically use it on the server-side with Node, Backbone is targeted at building single page interface apps on the client-side.

Backbone is normally for use on the client side (browser) and Express is for the server side (NodeJS).

When Backbone is used on the server it's mostly for the models as Express doesn't provide any of these.

Backbone is a front-end framework. Otherwise express is a back-end framework based on node.js.

A common setup is express as rest api server and backbone as front-end framework.

Backbone.js, Angular.js and Ember.js => Client Side JavaScript Frameworks, means they provide building blocks to build client side of web application. Node.js are of same kind and build on top of V8 Chrome engine.

Express is a framework built on top of Node.js to make our server side development easy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM