Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
133 views
in Technique[技术] by (71.8m points)

javascript - 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!

question from:https://stackoverflow.com/questions/6943899/confused-about-backbonejs-and-expressjs

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...