La enfermedad de Hanahaki

Algo tan hermoso pero doloroso y cruel a la vez.. “La enfermedad del Hanahaki” is published by Arantza Muro in La enfermdad del Hanahaki.

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




This is how I sell Node.js to curious kids

My peeps just out of college often ask me what Node.js is. And I often tell them the same thing.
With this post, I intend to share my answer and give a brief introduction about Node.js to a person who might be unfamiliar to it.
I’ve tried to introduce some essential points as simply as possible. I’ve also provided links to some great sources that are worth taking the time to read. So, if you find that I missed something important or said something inaccurate, please feel free to comment 😁

Since the outside environment is much larger and so very different from that of a browser, we consider JavaScript-on-the-table as a separate entity in itself and call it Node.js.

If I still have their attention after all the theory, I also tell them that just like JavaScript, Node.js is asynchronous (or non-blocking).
I believe it is important to note here that while JavaScript is a programming language, Node.js is not. A Node.js program is still a JavaScript program. It is just not written to run on web-browsers.

What it means to be asynchronous is that, code on line 10 may start executing before code on line 1 completes. It doesn’t always go line-by-line in a synchronous manner.

Here, in Node.js, the program execution won’t w̶a̶i̶t̶ be blocked for an asynchronous method (a method that deals with I/O operations, network requests, database queries, etc. as such methods are highly time-consuming) to return a result. So, if you write:

So, if the execution doesn’t stop for slower methods to return, that must be a real problem, right?
If you make a simple select query on your database. But you can’t store the result, how do we ever get anything done in Node.js?

Well, there are a couple of ways:

Sounds pretty interesting right? IT IS! 😄
What these things actually are, I might explain in another post though.

Unlike in an Apache server, where a thread is spawned on a per-request basis, a single thread is responsible for handling all the client requests in Node.js.

The plus side is that since there’s only one thread running, it is significantly less intensive on the server RAM. But, the obvious downside is that a single unhandled error can kill the thread and bring the entire site down.
(Imagine the chaos if a big service like Netflix had its servers down for an hour all over the world because some random guy used a special character in his username; which somehow nobody at Netflix had anticipated 😳)

And yet, if your application does a lot of CPU-intensive work, clustering might still not be enough.

While in the traditional client-server architecture, the client always initiates communication and the server sends back a response, we can have two-way communication with the help of web-sockets.
Ideal for real-time applications such as chat-apps where a server-side emitter can be created that emits an event to its clients whenever a message is received.

All in all, these are the features that people love Node.js for.

I believe you would want to use Node.js if you:

You might not want to go with Node.js if you

If you’re still not clear about why the hell would you use Node.js, you might wanna read a blog post by Node.js Foundation on it.

Thanks for reading! 😊
If you liked the post, don’t forget to clap, comment and share 😋

Add a comment

Related posts:

A focus on the future

The future condition of our middle class generates a large lack of hope when polling the American people. As mentioned in my previous posting, economists point to the increasing income inequality…

Afinidade

Ando curioso tentando entender o que nos faz sentir tamanha afinidade com pessoas que mal convivemos, mas que quando encontramos, nos fazem sentir enorme alegria e semelhança. Essa curiosidade…

Rejeki dan Ikan Peliharaan di Kolam

Milyaran manusia yang hidup di muka bumi mutlak mengerti apa yang dimaksud dengan rejeki. Berbagai macam makna akan bermunculan jika kita bertanya kepada setiap orang yang kita temui setiap hari…