what to expect while building your first nodejs application
DESCRIPTION
Here is a small list of things that one who is starting NodeJS based development should expect. Most of these are basically the problems that one might face in course of developing a NodeJS application. Preparing for them in advance by taking specific notice can help in reducing later time wastage on these already identified problems.TRANSCRIPT
Building your first NodeJS
Application
Here is what to expect!
NodeJS applications typically
Module ALPHA
A module mashup.
Module BETA
This is a typical NodeJS
application.
Module OMEGA
BY what to expect I mean this.
Things to expect to go wrong! Because
good things you would already be expecting .
NodeJS Debugging
NodeJS debugging is one of the things that might evoke a WHAAAATTT response in you. It is
quite basic level of debugging in which even the breakpoints need to be added statically to
your code.
A way to circumvent this is to keep methods and modules small and build loosely coupled
modules. If you have been working in a non-functional programming language till now then
you better believe in this advice now or you will feel the pain later.
NodeJS Event Loop
From the initial documentation you must have already read about how the NodeJS works
and that it has something called an event loop.
Well the event loop is something like a double edged sword, if you use it correctly it is friend,
otherwise it will cut you.
NodeJS Event Loop II
NodeJS makes use of callbacks for I/O operations. Well let me break this news for you, you
should use callbacks even for the CPU intensive operations.
Since the Event Loop runs on single thread, if you go on to do huge amounts of processing in
the event loop then it would slow the whole application down, not just for one request but for
all requests!!!
So this makes it imperative that processing in Event Loop is done just to delegate incoming
requests to call back based asynchronous processing and kept at the bare minimum if you
wish to achieve those juicy throughput numbers in your application.
NodeJS Remembering Documentations
You may not find a good IDE for NodeJS just yet. You will have to rely and remember the
documentations a bit more than you did in Java or C++.
But since the included code(dependencies) are all in JavaScript, you can just go ahead
open that dependency file and have your documentation.
NodeJS Quickly Crafting Untenable Code
NodeJS, well is a framework that supports JavaScript (a functional programming language)
for its programming. As in other functional programming languages here also you can create
code quickly and that code might become untenable.
Example of such a thing happening are incomprehensible use of function compositions, call
back hell,. Etc.
SO, just stay sharp in keeping your code’s maintainability in check, especially with NodeJS
since the code written here uses starkly different lingo that what you might have written for
browser.
Ashish Sharma
Find me at @ashish424242 and @kartaa