What are the differences between Backbone.js and Node.js? And which is best?

Problem

I'm feeling a bit confused, there are so many frameworks out there for Node.js related 'stuff'. Would someone be able to give me an overview of What are the differences between Backbone.js and Node.js? And which is best? Thanks in advance.

Problem courtesy of: Mohit Kumar

Solution

I am quoting it from a couple of sources here:

Firstly, to quote from the stack overflow question here:

Most of the things you listed are related only because they are written in or otherwise use JavaScript. Comparing them is much like comparing apples to oranges. It's like asking what the difference is between a Toyota Camry and a V6 engine. They are related, but do different things.

Node

Also known as Node.js, Node is the JavaScript environment on which we run our server-side JavaScript code. It is based on the V8 JavaScript engine. All of the JavaScript code you write, or install and run from packages from NPM, GitHub, etc. is executed by the Node runtime environment.

Backbone

Backbone can be likened to as a Model-View-Controller framework for JavaScript. I believe it was originally written for the browser; it helps keep your client-side JavaScript clean by implementing most common MVC patterns (as well as a couple other things), allowing you to more easily connect your client-side JavaScript to your server-side code.

Also, this is from an answer for the same question on Quora. Credit goes to Drew Harry:

They're almost completely unrelated. Traditionally, Backbone.js is a client library and Node.js is a way to write server-side applications in Javascript. Backbone aims to be a model + view system for binding data models with DOM elements that represent that model visually in a web page. Backbone also provides Collections of Models, as well as a bunch of utility functions for synchronizing those models with their server-side representations.

Node.js is just the v8 Javascript run-time environment packaged with a standard library to do useful server-side things with Javascript. There are lots of packages designed for Node (check out npm for ways to easily install those packages, Backbone included) that extend it to do all sorts of interesting things. It's possible to use Backbone.js with Node.js, but Backbone isn't particularly designed with use on the server in mind.

Go and upvote the above answer(s) if you find the material helpful.

Solution courtesy of: Forbidden Overseer

Discussion

Node.js :

Javascript for backend side. ( like : php, ruby on rails, python, etc. )

Backbone.js :

Javascript for frontend side ( running on the browser of your client ) backbone.js also uses jquery , more frameworks of javascript for client side are : 1. mootools 2. ExtJS 3. dojo 4. prototype and many more ...

Discussion courtesy of: IdanHen

Pretty much the only things those two have in common is that they're Javascript based and have a lot of hype surrounding them (not undeserved though).

node.js is a framework for Javascript server applications. It includes the V8 Javascript engine developed for Chrome. It's asynchronous and event-driven, so it's ideal for serving large numbers of small requests.

backbone.js is a framework for client-side web applications, specifically for so-called "single page web applications" where only a single HTML page is sent to the browser at the beginning, and every interaction thereafter is handled by AJAX requests and Javascript logic that transforms the page.

This means that the two can also work effectively together: an app implemented using backbone.js for the frontend could have its AJAX requests handled by a server part using node.js - a rather popular combination since it allows you to have an entire web app using only Javascript.

Discussion courtesy of: Michael Borgwardt

Node.js is a server-side platform designated for building network applications. It is built on Google's V8 Javascript Engine and uses asynchronous event-driven approach for building applications. Backbone.js is a simply javascript client library that makes it easier to create and maintain client-side code and comply with MVC pattern. Hence, they cannot be compared.

Backbone.js has a lot of alternatives that use slightly different approach to achieve the same goal. Most known are: knockout, ember.js and others. And it also can be plugged into node.js application.

Discussion courtesy of: koss

Backbone.js is a javascript library, similar to jQuery or YUI but addressing different needs.

Node.js is a javascript interpreter, similar to Internet Explorer or Firefox or Safari but addressing different needs.

I don't know much about backbone.js but I believe you can use it with Node.js since it uses regular javascript. You may need a DOM emulation layer for the DOM related stuff though.


Additional answer:

A bit of googling reveals that there are people out there using Backbone on Node.js. The advantage of this is obviously you'll be able to use the same framework and reuse code on both client and server.

See: http://nerds.airbnb.com/weve-launched-our-first-nodejs-app-to-product


More additional answer:

With regards to semantics I see that some people disagree what some terms in computing means. While the terms are loosely used, and while they are somewhat interchangeable, they do have fairly well defined meanings.

In general, an interpreter is an executable, that is, a program that takes as input some data and executes it as a program. V8 is not this. It cannot take javascript by itself and run it. It needs to be compiled into another program, an interpreter in order to run javascript.

V8 does ship with example code to build an interpreter though. That interpreter shipped with V8 is called V8-shell.

An engine is a library that implements an interpreter. This is exactly what V8 is.

The two terms above are somewhat interchangeable because the word "interpreter" can also validly be used in place of "engine" to describe what a library implements. But that usage of the word is similar to the usage of "MVC framework" or "UI toolkit" in that it is used as an adjective. So it is correct to say that an "interpreter" is a kind of library.

But the word was originally used to mean the binary that executes a programming language. When used this way one uses it as a noun as it refers to something on the file system. Used this way is similar to the usage of the "compiler". For example one would call clang a compiler in this sense and one would call llvm, the library used by clang, a compiler in the previous sense.

Lets take a look at something that is not javascript as an example:

  • tcl is a programming language

  • tcl is also the library that implements the interpreter for tcl. In other words the engine.

  • tclsh is the tcl interpreter

Let's take a look at another example:

  • ruby is a programming language

  • RubyC is one of the many engines for ruby

  • ruby is the interpreter that uses RubyC

Nobody uses the word "framework" when referring to the binary executable interpreter for the above two languages. It just sounds silly.

But wait you say, Node.js refers to more than just node.exe. It truly provides a bunch of additional features that can be used as a good foundation to write great programs. In other words a framework.

Well, yes. That being true does not make the usage of the word "interpreter" to refer to node.exe automatically invalid. Just as using the word "earth" to refer to the planet does not make using the word to refer to soil automatically invalid.

Besides, those extra functionality? That's true for tcl and ruby as well. It's also true for C. Those extra functionality like fs and http on Node.js are traditionally called standard library. While the Node.js project calls it a framework that's their choice. Almost nobody else calls their interpreter + standard library a framework. PHP for example is distributed exactly like Node.js with a bunch of very high level standard libraries but nobody would call PHP a framework. It's also a bit silly when people write actual frameworks on top of node - frameworks for a framework. But I'm not going to say they are wrong because they choose to call it that. It's just their way to describe what they've created. More power to them.

What I am saying is that people who say that node.js is not an interpreter is ignoring the usage of the word throughout the history of computing. I don't know. Coming from an asian background it's natural to me to assume that everything belongs to multiple categories. Maybe it's a western idea that things belong strictly to specific categories that I don't quite get.

So here are the facts:

  1. Node.js is not simply a javascript library. You need node.exe to use the standard libraries that node ships with.

  2. Backbone.js is on the other hand a standard javascript library. It is not an executable.

  3. Node.js is the only example where an interpreter + library is called a framework so far. All other examples of framework I know of in programming refer to libraries that implement a design pattern.

  4. Calling something "B" does not automatically make calling it "A" invalid.

One final thing: web browsers also come with a very large high level standard library for javascript. It's called the DOM (there's also a bunch of other stuff like Math and XMLHttpRequest but the DOM is the biggest). Accordingly one should call Internet Explorer and Firefox javascript frameworks but nobody does that.

Discussion courtesy of: slebetman

Both are javascript related but totally different.

Node is a interpreter/platform to execute javascript code in the server such as JDK or Ruby. To put it simple, you need NodeJS installed to interpret Backbone based script on the server.

When it comes to server side MVC., Geddy, RailwayJS, Express etc., considered to be serving the purpose better than Backbone.

Whereas Backbone is a champion MVC framework in the client side.

Discussion courtesy of: Vivekanandan Murugesan

This recipe can be found in it's original form on Stack Over Flow.