nodejs it is a server side platform, non-blocking, and most important single thread. now, what does this means in short answer it means it incredibly fast and the none blocking means it has no locks. what that not means it has no cons also nodejs have no limited to just server side have set of tools like an electron that can make as well desktop app. on this post, we will cover what good and what bad on nodejs to my perspective we will talk about a bit of the tool.
WHAT IS IT?
nodejs it is a server side platform, non-blocking, and most important single thread.
now, what does this means in short answer it means it incredibly fast and the none blocking means it has no locks. what that not means it has no cons also nodejs have no limited to just server side have set of tools like an electron that can make as well desktop app.
on this post, we will cover what good and what bad on nodejs to my perspective we will talk about a bit of the tools.
SO WHAT IS THE PRO?
well like every tech ever existed it got few reasons as to why so many people are using this tech.
so here I will list some the advantage it has.
node js it is basically based V8 Engine of google it one of the reasons why it is so fast the Engine itself is writing on C++ , what also make this more powerful that nodejs allow the user to write modules with c++ and that will be exported/compile that will make stuff that nodejs make not possible will be possible.
EVENT-DRIVEN, NON-BLOCKING I/O
now how it connected to non-blocking and why this good well let take database connection that need do a query and say there is no locking with the DB or external server that work with API X (such PayPal and more) and you don’t want wait so the call be finished and you want multiple parallel workflows.
with nodejs it possible this for the reason the event-driven flow basically this means when I did the call whatever if it DB or server they will not be blocked at any time.
This is why Node.js does such a great job managing thousands of simultaneous connections.
this one my favorite and why I love so much nodejs basically let take I have package that I have to write to the client for example let take existing project open source like moment.js now so fun here and agile that package can work for both client and server and can save tons of time in write the code for client or server and can just copy for both of them.
EASY TO LEARN
nodejs has an advantage that can say it more like java node itself can run anywhere (Linux / Windows / Mac) but it not limited to this it has many packages that you can build a hybrid application for mobile and as well build an application for a desktop that supports all platforms.
just give you bit understanding about the tools you have electron and iontic or nativescript and it has many more good packages that do cool stuff and DevOps tools many are built upon nodejs for its agile style I may, later on, will cover some of the tools in depth or just give overview on some of the packages to help you work and build faster.
ho, the nodejs community for my personal view can say one best thing is that it has many packages that allow me short develop time so many ways improve my workflow let give few of my favorite projects that I know.
- Async – more traditional library with one method for each pattern. I started with this before my religious conversion to step and subsequent realization that all patterns in Async could be expressed in Step with a single more readable paradigm.
- Express Great Ruby on Rails – a framework for organizing websites. It uses JADE as an XML/HTML templating engine, which makes building HTML far less painful, almost elegant even.
- Mocha competitor to Vows which I’m starting to prefer. Both frameworks handle the basics well enough, but complex patterns tend to be easier to express in Mocha.
SO WHAT IS THE CONS?
well, so far all nice and shiny well not really like everything in real work it lacks in many areas.
what this means basically it means nodejs has lacked the complexity that you may need like in such as C#/PHP/JAVA.
the API sometimes unstable (many packages can be hell understand or they lack documented or just not work so need to watch out)
Well, this one of the things need to updated understand lest say if you got a server with 4 cores when u will run the script it will be run only on one core and will not run on every one of the core this critical when developing there is a way get around this more correct there is two ways:
- For big heavy compute tasks it best work with child processes what dose this mean in nodejs can fire up child processes or send messages to additional worker processes. in such way, thou is not an actual multi-thread but more multi processes there is a way to exchange data between the processes with sendmessage event but will cover at later date. in this way, the processes can cover to the rest of the CPU and make at work with a better way in the server.
- For scaling throughput on a web service, you should run multiple Node.js servers on one box, one per core, using cluster
this one it a hard call it one of the main reason why nodejs so fast but what can give spaghetti code the fastest what I mean the asynchronous work by sending a method and when the method will be done will trigger the callback this is part of the event loop that will be cover later on.
now there are 2 ways to counter this issue but in general, this one worse that can lead to bad code.
the way counter this is either use of promise this will sort some of the issues but can still lead to the spaghetti effect
and nowadays with the ES6/7, there is a support to async/await that will sort this issue mostly.
nodejs leans make the production system lot more complex from PHP/ruby and so on.
also, raise the issue on Unhandled exceptions will bring down the entire process, necessitating logic to restart failed workers (see cluster). Modules with buggy native code can hard-crash the process. Whenever a worker dies, any requests it was handling are dropped, so one buggy API can easily degrade service for other co-hosted APIs.
all in all like in every language it missing parts have lots plus it depends really on the end how you setup what tool u chose to use and how.
By Sivan Wolberg