Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



LearnNow


XAMALOT
 


SSWUG

Reader rating:
Click here to read 2 comments about this article.
Article source: CoDe (2011 May/Jun)


Article Pages:  1  2 3 4 5 - Next >


An Introduction to node.js

JavaScript has a lot of momentum these days. It seems you can’t get very far in a software development discussion without hearing about node.js. If you are wondering what all the fuss is about, and why you should care, you’re in the right place.

The tag line for node is “Evented I/O for V8 JavaScript” with a goal of “[providing] an easy way to build scalable network programs.” If the tag line seems a bit cryptic, all you really need to know is that V8 is the extremely fast JavaScript engine maintained by Google that is used in their Chrome web browser, and “evented I/O” means that I/O in node is completely nonblocking. Like a web browser, node has a built-in event loop that runs continually in the background. When writing code, you subscribe to events using callback functions and node sleeps until something happens that it needs to process. If that sounds familiar, it should. It’s the same way you’d handle, let’s say, a click event using jQuery.

In this article, I’m going to explore node and progress through the basic concepts needed to develop with it. By the end of the article not only will you have a functioning chat server, you’ll understand enough to take the sample code and enhance it on your own. I hope you’ll be pleasantly surprised at how easy it is.

Installation

With node.js, the world is pretty clearly divided. Its development is done completely in Linux or Mac OSX, and a massive majority of its community works in the same environments. There has been very little attention given to Windows until recently, and some versions of node were impossible to run. Luckily, while doing the work for this section of the article, I found a relatively simple solution to running node on Windows that is unobtrusive and just works. There are some slight differences that you will have to contend with when running node on Windows, but I will address them when they are needed. The following subsections give installation instructions.

Windows

In Windows, use the following steps to install node:

  1. Go to http://www.rafaljonca.org/d/nodejs-windows and download the NodeJS 0.4.1 package.
  2. The built-in Windows extractor won’t work, since the package is in 7-zip format. Download an extractor that will work if you need to. For a free one, go to http://7-zip.org/.
  3. You can extract it anywhere, I just put it on my Desktop.
  4. Open up a PowerShell prompt with administrator privileges and navigate to the bin folder in the distribution you just extracted.
  5. Execute ./shell.cmd.

Please note that every time you open a new PowerShell prompt to use node, you will need to execute the shell.cmd file as outlined in step 5.

OSX

In OSX, use the following steps to install node:

  1. Go to http://sites.google.com/site/nodejsmacosx/ and download the NodeJS-0.4.1.pkg file.
  2. Install the package.
  3. Open your shell of choice.

Type the following command and make sure you get matching output:

> node -v
v0.4.1

There are some alternate ways to install node.js both on Windows and OSX. You can see them on the node.js wiki https://github.com/joyent/node/wiki/Installation.

First Example

Let’s take a look at a simple node.js program. Open your favorite IDE or text editor and create a file called flyingMonkeys.js, and then type in the code from the following code snippet and save the file:

// Simple console logging.
// It works the same way it would in a web browser
console.log('Look! Flying monkeys!');

To run programs in node, you’ll go back to your trusty command-line tool and type the following command: (note: if you have installed node using the Windows instructions I provided above, make sure that you have executed ./shell.cmd):

> node flyingMonkeys.js
Look! Flying monkeys!

Hooray! OK, now that the ubiquitous “Hello, world!” app is out of the way, let’s look at a comparison of the behavior between node and the browser.

&

By: Brian Mavity

Brian Mavity has been working on web applications with C# and .NET since 2004. For the past three years he has been working on web applications that are very heavily JavaScript oriented and is now working toward finding the best ways to write maintainable JavaScript code.

Through this time, he developed a love of the JavaScript language and is very excited by the possibilities that server-side JavaScript environments can provide.

brian@brianmavity.com



Article Pages:  1  2 3 4 5 - Next Page: 'Web Browser vs. node.js' >>

Page 1: An Introduction to node.js
Page 2: Web Browser vs. node.js
Page 3: Built-in Modules and Asynchronous Programming
Page 4: The Node Package Manager, npm
Page 5: Fitting the Pieces Together

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.2 out of 5

8 people have rated this article.

Instantly Search Terabytes Of Text
“Lightning Fast”
– Redmond Mag
“Covers all data
sources” – eWeek
25+ fielded & full-text search options
dtSearch’s own document filters highlight hits in popular file types
Web Spider supports static & dynamic data
APIs for .NET, Java, C++, SQL, etc.
Win / Linux (64-bit & 32-bit)
www.dtSearch.com
 

      LearnNow

 

SSWUG