Report: HTML5 and Node.js (Tim)
Contents
HTML5
HTML4 has been the standard version of HTML since 1999 until the release of HTML5 in 2004. The language stands for Hyper Text Markup Launguage and is the foundation of the client side of most websites across the internet and also cross platform mobile applications. The markup language provides structure to pages through the use of tags, each of which must be followed by a closing tag with only a few exceptions such as a line break, which does not need a closing tag. The syntax for a line break is <br/>. HTML5 uses the same syntax as the previous version, but includes many additional features.
The format of HTML was designed to replace HTML 4, XHTML, and the HTML DOM Level 2. Each language is incredibly similar, by being able to accept XHTML and HTML syntax under a common doctype. A few of the updates to the language itself include <audio> and <video> tags replacing the <object> tag that was used for each previously. The new tags make it possible to embed audio, video and charts to a web page. The added tags are an example of the improved interactivity that HTML5 emphasizes. Forms validation is another technology that has been improved through HTML5 reducing the need for third party languages like JavaScript, expect in cases where browsers don't support the form type used.
HTML5 has storage advantages as well for users that eliminates the need for cookies because of the ability to store data locally through functions like session and local storage. The local functions improve speed because they eliminate the need to include cookies in the HTTP header, which can slow response time. An example of the localSession function below is used to store the number of clicks made by a user over a period of sessions:
if (localStorage.clickcount) { localStorage.clickcount = Number(localStorage.clickcount) + 1; } else { localStorage.clickcount = 1; } document.getElementById("result").innerHTML="You have clicked the button " + localStorage.clickcount + " time(s).";
HTML5 has improved client side development and reduced the need for third party plug-ins for a page’s interactivity. The simpler syntax and universality allows the markup language to be used across platforms, which is a necessity for the growing number of web- available devices. The updates presented in HTML5 reinforce the need for HTML5 as the foundation for web pages and applications.
(Back to top)Node.js
Node.js is a program built on the V8 Javascript Engine that is used to build scalable network applications. A focal point of node.js is the fact that it is an asynchronous I/O framework, also referred to as a non-blocking I/O. Input/ output operations and be extremely time consuming compared to other processing. Asynchronous I/O means that a program can perform I/O requests without pausing any processes in progress, allowing programs like node.js capable of managing thousands of network connections at a time.
The core library is written in JavaScript because it is known as a "complete" language, meaning it is not limited to specific functions and can be used in many contexts. Node.js allows JavaScript to be written in the backend and it is commonly used to create HTTP servers to provide data to web pages. An example below:
var http = require("http"); function onRequest(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); } http.createServer(onRequest).listen(8888);
Node.js is only one single process when it is executed, so if one segment of the code is slow, everything must wait until the slow segment is completed. To avoid this, Node.js uses event driven loops that utilize functions in the request to pull data. This capability means that results are constantly being returned and the loop will be cycled until there is no more data to return. The same type of function call can also be included in the HTTP server request to handle large numbers of simultaneous requests while minimizing CPU processing power because Node.js runs as a single process.
(Back to top)