Javascript and the MEAN Stack
Steven Bock December 10th, 2014
Features of the Javascript Language
- Functional paradigm
- Ability to pass functions as values
- Dynamically typed
- Mostly interpreted, but can be compiled in some instances
- JS started in 1995 by Netscape
- Originally was meant for client side scripting of simple user initiated events
- Maintained by ECMA International as ECMAScript standard
- Expanded to other web browsers around 1997
- Fell out of favor for a while around 1999-2000
- In 1998, the Department of Justice sued Microsoft over alligations that the company had used its substantial market share in the computing space to upend and effectively destroy competing technologies
- One of the issues at hand were Windows-specific implementations of both Java and Javascript
- MS Java Virtual Machine and JScript
- This mess resulted in Javascript falling out of favor for a few years in fear of Microsoft potentially controlling the language
- Most modern computers have web browsers shipped with them
- Just-in-time compilation techniques to improve O(n) runtime efficiencies
- Entire operating systems designed to pull data from the Internet at all times
MEAN is an acronym
-
MongoDB - JSON/dynamic schema based DBMS
-
Express.js - Javascript based webserver
-
AngularJS - Javascript controller framework created by Google
-
Node.js - Server-side Javascript runtime based on Google Chrome's V8 JS engine
Example MEAN code (from Express)
//import express server
var express = require('express');
//decalre app container variable
var app = express();
//define root HTTP GET request
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
//Event listener
app.listen(3000, function(){
console.log("Express server listening on port 3000...");
});
Advantages and Disadvantages of Javascript on the Server
Advantages
- Portablility
- Ability to learn the lanugage
- Ease of use
Disadvantages
- Scalability
- Readability
- Depth of what can be done in JS
- Reputation of the JS platform
- Platform stability
All of this code is on GitHub