Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Node Web Development - Second Edition

You're reading from   Node Web Development - Second Edition JavaScript is no longer just for browsers and this exciting introduction to Node.js will show you how to build data-intensive applications that run in real time. Benefit from an easy, step-by-step approach that really works.

Arrow left icon
Product type Paperback
Published in Jul 2013
Publisher
ISBN-13 9781782163305
Length 248 pages
Edition Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
David Herron David Herron
Author Profile Icon David Herron
David Herron
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Node Web Development Second Edition
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. About Node FREE CHAPTER 2. Setting up Node 3. Node Modules 4. HTTP Servers and Clients – A Web Application's First Steps 5. Implementing a Simple Express Application 6. Data Storage and Retrieval 7. Multiuser Authorization, Deployment, Scaling, and Hosting 8. Dynamic Interaction between the Client and Server Application 9. Unit Testing Index

The capabilities of Node


Node is a platform for writing JavaScript applications outside web browsers. This is not the JavaScript we are familiar with in web browsers! There is no DOM built into Node, nor any other browser capability, but a DOM can be added using JSDom, and there are Node-based wrappers available for some browser engines. Between the JavaScript language and its asynchronous I/O framework, it is a powerful application development platform.

Beyond its native ability to execute JavaScript, the bundled modules provide the following capabilities:

  • Command-line tools (in shell script style)

  • Interactive-TTY style of program (REPL or Read-Eval-Print Loop)

  • Excellent process control functions to oversee child processes

  • A buffer object to deal with binary data

  • TCP or UDP sockets with comprehensive event-driven callbacks

  • DNS lookup

  • Layered on top of the TCP library is an HTTP and HTTPS client/server

  • File system access

  • Built-in rudimentary unit testing support through assertions

The network layer of Node is low level while being simple to use. For example, the HTTP modules allow you to write an HTTP server (or client) in a few lines of code. This is powerful, but it puts you, the programmer, very close to the protocol requests and makes you implement precisely which HTTP headers to return in request responses. Where a PHP programmer generally doesn't care about the headers, a Node programmer does.

In other words, it's very easy to write an HTTP server in Node, but the typical web application developer doesn't need to work at that level of detail. For example, PHP coders assume Apache is already there, and that they don't have to implement the HTTP server portion of the stack. The Node community has developed a wide range of web application frameworks, such as Connect, allowing developers to quickly configure an HTTP server that provides all of the basics we've come to expect—sessions, cookies, serving static files, logging, and so on—thus letting developers focus on their business logic.

Server-side JavaScript

Quit scratching your head already. Of course you're doing it, scratching your head and mumbling to yourself, "What's a browser language doing on the server?" In truth, JavaScript has a long and largely unknown history outside the browser. JavaScript is a programming language, just like any other language, and the better question to ask is "Why should JavaScript remain trapped inside browsers?"

Back in the dawn of the web age, the tools for writing web applications were at a fledgling stage. Some were experimenting with Perl or TCL to write CGI scripts, the PHP and Java languages had just been developed, and even JavaScript was being used on the server side. One early web application server was Netscape's LiveWire server, which used JavaScript. Some versions of Microsoft's ASP used JScript, their version of JavaScript. A more recent server-side JavaScript project is the RingoJS application framework in the Java universe. It's built on top of Rhino, a JavaScript implementation written in Java. All this means that JavaScript outside the browser is not a new thing, even if it is uncommon.

Node brings to the table a combination never seen before; namely, the coupling of fast event-driven I/O and a fast modern JavaScript engine such as Google's V8, the ultrafast JavaScript engine at the heart of Google's Chrome web browser.

You have been reading a chapter from
Node Web Development - Second Edition
Published in: Jul 2013
Publisher:
ISBN-13: 9781782163305
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image