Skip to main content

4 Reasons to use Node.js


There are many great reasons to use Node.js, regardless of experience level. Take a look into what some of the greatest practical reasons are to use Node and why you should love it.

I get it. You're not a bandwagon developer. You don't use the cool, trendy platform just because everyone else is. That's why you haven't looked seriously at Node.js yet. (Or your boss hasn't let you yet.) Well, it's time to look again. There are many great, practical reasons to use Node. Here are ten of them.

1. You Already Know JavaScript

             Let me guess. You're using a rich client framework (Angular, Ember, Backbone) and a REST-ful server-side API that shuttles JSON back and forth. Even if you're not using one of those frameworks, you've written your own in jQuery. So if you're not using Node.js on the server, then you're constantly translating. You're translating two things: 1) the logic in your head from JavaScript to your server-side framework, and 2) the HTTP data from JSON to your server-side objects.

By using JavaScript throughout your app, you not only gain mental energy, you gain practicality as well. By potentially re-using your models, and templates, you reduce the size of your application which reduces complexity and chance for bugs.

JavaScript as a language is eating the world. It is not going away soon. There is a JavaScript runtime on every personal computer in the world, and it looks to stay that way for awhile.

2. It's Fast

             Node.js is a JavaScript runtime that uses the V8 engine developed by Google for use in Chrome. V8 compiles and executes JavaScript at lightning speeds mainly due to the fact that V8 compiles JavaScript into native machine code.

In addition to lightning fast JavaScript execution, the real magic behind Node.js is the event loop. The event loop is a single thread that performs all I/O operations asynchronously. Traditionally, I/O operations either run synchronously (blocking) or asynchronously by spawning off parallel threads to perform the work. This old approach consumes a lot of memory and is notoriously difficult to program. In contrast, when a Node application needs to perform an I/O operation, it sends an asynchronous task to the event loop, along with a callback function, and then continues to execute the rest of its program. When the async operation completes, the event loop returns to the task to execute its callback.

In other words, reading and writing to network connections, reading/writing to the file system, and reading/writing to the database–all very common tasks in web apps–execute very, very fast in Node. Node allows you to build fast, scalable network applications capable of handling a huge number of simultaneous connections with high throughput.

3. You get to use MongoDB

             So you've decided to use JavaScript on the server, and you're proud of your decision that avoids all that translating from client data to server data. But persisting that data to the database requires even more translations!

There's good news. If you're using an object database like Mongo, then you can extend JavaScript to the persistence layer as well.

 Using Node.js allows you to use the same language on the client, on the server, and in the database. You can keep your data in its native JSON format from browser to disk.

4. Streaming data

Traditionally, web frameworks treat HTTP requests and responses as whole data objects. In fact, they’re actually I/O streams, as you might get if you streamed a file from the filesystem. Since Node.js is very good at handling I/O, we can take advantage and build some cool things. For example, it’s possible to transcode audio or video files while they’re uploading, cutting down on the overall processing time.

Node can read/write streams to websockets just as well as it can read/write streams to HTTP. For example, we can pipe stdout from a running process on the server to a browser over a websocket, and have the webpage display the output in real-time.

Comments

Popular posts from this blog

Silent headset lets users quietly commune with computers

Advances in voice recognition technology have seen it become a more viable form of computer interface, but it's not necessarily a quieter one. To prevent the click-clacking of keyboards being replaced by noisy man-machine conversations, MIT researchers are developing a new system called AlterEgo that allows people to talk to computers without speaking and listen to them without using their ears. At first glance, the AlterEgo headpiece looks like the product of a design student who didn't pay attention in class. Instead of the familiar combination of an earpiece and microphone, the device is a cumbersome white plastic curve like the jawbone of some strange animal that hangs off the wearer's ear and arcs over to touch the chin. It might look strange, but it's based on some fairly sophisticated technology. Inside the Alterego are electrodes that scan the jaw and face from neuromuscular signals produced when the wearer thinks about verbalizing words without

Qualcomm showcases the Snapdragon S4 ahead of Mobile World Congress

We’ve already heard about Qualcomm’s latest processor, the Snapdragon S4 , which will be quad-core and utilize LTE. Qualcomm took the time to give us some details ahead of Mobile World Congress. The new SoC now supports up to three cameras (two in the back for 3D and one front-facing), 20-megapixels, and recording video at 1080p (30fps). We can also expect zero shutter lag, 3A processing (autofocus, auto exposure and auto white balance), and improved blink/smile detection, gaze estimation, range finding and image stabilization. Last but not least, it supports gesture detection/control, augmented reality , and computer vision (via Qualcomm’s FastCV). Hit the break for a couple of videos featuring image stabilization and gestures.

Water purification: Running fuel cells on bacteria to purify water

Researchers in Norway have succeeded in getting bacteria to power a fuel cell. The "fuel" used is wastewater, and the products of the process are purified water droplets and electricity. This is an environmentally-friendly process for the purification of water derived from industrial processes and suchlike. It also generates small amounts of electricity -- in practice enough to drive a small fan, a sensor or a light-emitting diode. In the future, the researchers hope to scale up this energy generation to enable the same energy to be used to power the water purification process , which commonly consists of many stages, often involving mechanical and energy-demanding decontamination steps at its outset. Nature's own generator The biological fuel cell is powered by entirely natural processes -- with the help of living microorganisms. "In simple terms, this type of fuel cell works because the bacteria consume the waste materials found in the water," explains SINTEF