Blog entry

JavaScript in 2014

JavaScript has lived through several incarnations. Many of the early uses have been hard to forgive as well as forget. Starting with AJAX and Dojo and moving up through JQuery, perceptions of the JavaScript language have been changing. I even heard rumours that it was a full-fledged real computer language. When I heard of server side Node JS I knew it was time to take a look. If you can run JavaScript outside of a browser you can probably avoid the DOM and maybe JavaScript won't seem so bad.

Node JS and Express JS

Node.js is powered by Google's V8 VM. Want to execute "Hello World" to a terminal? Create a file named hello.js

console.log("Hello world!");

Execute it though Node.js

[allison@eckford hello-world-express]$ node hello.js
Hello World

Want to execute "Hello World" to a browser? You could use the http module that ships with Node.js. Or you could use express. Express.js and Node.js go hand in hand. Express is a web application framework for node. Create a file named app.js

var express = require('express');
var app = express();
// app.set('port', process.env.PORT || 3000);
app.get('/', function(req, res){
    res.send('Hello World');
});
app.listen(3002);
console.log('Listening on port 3002');

Execute it through Express.js

[allison@eckford hello-world-express]$ node app.js
Listening on port 3002

Isn't that a lot easier than the first time you set up Apache?

I'm not suggesting it's time to retire your favourite Web Server but doesn't it look like quick and easy may have it's benefits?

Want to learn more about node.js?

Share this: 

 

Support

Drupal professional support

 

Small Business Tools

You have a vision, but you need the tools. We have the tools.

 

Drupal Training

Let us show you as much or as little as you would like to learn.

 

Responsive Design

Responsive web design for mobile, smartphones, tablets and desktop PCs.

On the Subject of Me

On the Subject of Me

I'm Allison with many hats. I am a System Analyst and Technical Writer with an IT and programming background.

I think Drupal is a super-awesome framework and I'm happiest when working on a Drupal Project!

Hire me, I'm really good

Expansion packs

You can add features to your Starter Kit at any time. Powerful add-ons include:

My Photostream