DEV Community

Kekayan
Kekayan

Posted on

Explain nodejs to me like Im five

Latest comments (17)

Collapse
 
alanguir profile image
Alan Languirand

“JavaScript is the most commonly used programming language on earth. Even Back-End developers are more likely to use it than any other language.” [source: insights.stackoverflow.com/survey/...]

And so JavaScript was taken from the web browser and put on servers too (that’s Node). More minds ~~ more creative solutions to all sorts of problems.

Collapse
 
onkarjanwa profile image
Onkar Janwa

Here a great blog written on medium about nodejs.

medium.com/@samerbuna/you-dont-kno...

Collapse
 
thatwasawkward profile image
Ben Wolman

You used to need a web browser to run JavaScript.

NodeJS takes JavaScript out of the browser so you can write software with it, too.

It's pretty cool.

Collapse
 
matthras profile image
Matthew Mack

I'd amend the second sentence to "With Node.JS, you can run Javascript scripts and software on your desktop."

That said, props for simplicity of expression.

Collapse
 
danieljsummers profile image
Daniel J. Summers

Explain what about Node.JS? :) Not trying to be a smart-aleck - there are so many ways to take that question. Here's my take if I interpret the question as "why does it exist?"

Remember in Mexico, after the earthquake, when we saw the people who were searching for kids at that school? It was hard, but sometimes it was even harder because there were people there who didn't speak the same language. (You remember the translator - you asked me what that was.)

Computers can be like that; when we use the Internet, our computers ask questions, and the other computers answer. Even though the Internet translates them, the computers usually speak different languages. Node.JS let the computers use the same language to both ask the questions and to answer them as well.

Collapse
 
csallen profile image
Courtland Allen • Edited

When someone wants to make their website interactive, there's only one language they can use: JavaScript. As a result, JavaScript has become such a popular language that virtually every programmer knows how to speak it.

Unfortunately, only one program knows how to understand JavaScript — browsers.

So even though we all know JavaScript, we can't use it for anything but interactive websites. If we want to write code for something that's not an interactive website, we have to use a different language. This is a lot of wasted potential.

Enter Node.js.

It's like we took the part of browsers that can understand JavaScript, ripped it out, and gave it as a gift to all programmers everywhere. Node.js is so small and flexible that we can use it anywhere we want. We can write JavaScript to create any type of program, not just interactive websites, and Node.js will be able to run it!

Collapse
 
kayis profile image
K

Software can do work for you.

Most software stands in everybodies way when it's still running but doesn't have any work left to do.

If you don't have any work for Node.js, it will get out of your way till you give it new work.

Collapse
 
jvanbruegge profile image
Jan van Brügge • Edited

Imagine you have a toy (browser). This toy has a crappy lcd display to play games (javascript). But instead of allowing you to buying the display, seperately so you can choose the cool color display (any other language) they just improved the pixel size a bit (ES6). Now, if you use a toy for a long time, without having other, better toys to play with, you begin to like that toy. Including its crappy lcd (Stockholm Syndrome). So one day, you get your first PC. In theory very useful, but you've grown to like the crappy lcd so much that you replace your fancy OLED display (e.g. Haskell) with that black/white lcd from your toy. It can only display one thing at a time and is much slower than the other one, but you still somehow love it (still Stockholm Syndrome).

Collapse
 
bgadrian profile image
Adrian B.G. • Edited

Hmm I think I got this one too

You like to play with your sand toys (trucks, shovels etc) in your garden, especially after a good rain.

NodeJS is a Sandbox for your living room! You can play with your sand toys inside your clean & beautiful house, without your parents yell at you and making a mess.

Kids: developers
Sand: JavaScript language engine (like V8)
Garden: browsers
Sandbox: NodeJS
Parents: DevOps
Living room: servers

NodeJS is something huge, it changed the world. In order to realize the difference between what it used to be (a language made in 10days as a reply to Flash) vs nowdays see my article about how many things you can build with JavaScript, and most of them exists thanks to V8 and NodeJS.

sandbox

Collapse
 
jochemstoel profile image
Jochem Stoel

Javascript is the language used in browsers to enable dynamic stuff/interaction. By dynamic I mean interactive. Not a static page but things can happen like popups and color changes and sliding menus.
Because Javascript is a very nice language to work with and a lot of people are using it, they have decided to use this same language on the server side of things. Here the same language is used for things that happen on the server. (like database connection for login)
A major cool thing is that the browser and the server have no trouble understanding eachother because they speak the same language. It is also very resource efficient. That means it is fast and does not need a lot of memory.
Node.js is a program that is a standalone Javascript language interpreter. It is the same Javascript interpreter the Chrome browser uses. It is made in such a way that it can run on almost any computer. Node simplifies it for developers like us by having done that already. That is why Node is awesomesauce.

I can't possibly simplify this more sorry :P my brain hurts now.

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I like your explanation except for this bit:

Because Javascript is a very nice language to work with ...

It's getting there, but still has a ways to go. I think the "because" probably has more to do with it being basically zero steps to start using (open a browser console (F12) and start typing), and it is the only viable option for browser-based apps. Whether they love it or hate it, web developers are required to know some Javascript. The other options that now exist still "compile" to Javascript.

WebAssembly may one day allow us to develop web front-ends in any language without touching Javascript.

Then when you start with Javascript, at some point you have to communicate with a backend to do things like save to database. A lot of back-end techs are intimidating to get into. You have to learn (potentially a lot) of incidental platform knowledge to even get started. Node came in and made it relatively simple to get started on the back end too, additionally so by using a language familiar to every web developer, Javascript. For developers who get into development via web or who work heavily with web front-ends, Node.js is a natural choice for a back-end.

Even if you don't use it for a back-end, web developers probably have Node.js installed for all the tools available via npm to build their web front-ends.

Collapse
 
jochemstoel profile image
Jochem Stoel • Edited

Although I was being sarcastic when I wrote that Javascript is a very nice language, I do actually stand behind this. Yeah you're right, it's getting there but so is everything else. I am very satisfied with the (not so) recent (anymore) developments of the language we have come to love and implement and the people responsible for it have done a great job adjusting to the requirements of modern browsers and even completely other realms Javascript was not expected to ever appear.

Javascript is universal. There are small context specific implementations sure but overall nearly everything can be ported from one realm to the other. Javascript can be typed procedurally and static as well as the most absurd high level abstraction design patterns because it is a script language without a lot of 'rules' on how to approach something. This freedom we have created a lot of 'styles' over time which I like to personally refer to as dialects. Which dialect you prefer and choose to use is up to you.

A good example of this is that a few years ago people started writing their event handler register function as on(). In stead of object.addEventListener('click', function() { }) we started doing object.on('click', ...). To some people this is blashphemy, to me it is beauty. Where else do you find code that is this semantic?

Another thing to love about Javascript is the collaborative effort. It is by far the most 'social' language in the sense that we are all constantly influencing its direction by the code we write and share with the world daily and the proposals we make for future syntax. I have my own preferences and dialect and sometimes I see other people copying my methods in often completely different contexts. There is no other language where you can see the origin, cause and effect so clearly.

We can use Javascript to write low level backends and interactive frontends using the same interpreter. Besides, even though there are multiple interpreters out there (V8, NiL, etc) they all do their best to have identical implementations rather than competing who gets to be right.

Then there is Electron/NW.js/app.js, the various crap like React and Express and don't get me started on super sets like TypeScript.

And yes, like you said even without acknowledging all this, the NPM ecosystem is still the largest one in the world and that has a reason.

OK. I will stop here I can go on for hours I think I might have a problem. Thanks for commenting on my post, it is really motivating to communicate with somebody about stuff like this.

Thread Thread
 
nhsz profile image
Nicolás Quiroz • Edited

Besides familiarity with the language if you've been on web dev before, I think the main "selling point" of NodeJS for devs is that it was able to greatly simplify the problem of concurrency. You have only one thread available so you forget to deal with threads and all that stuff.

Of course you now have to deal with other problems, i.e.: callback hell and async thinking.

Resource efficiency (hence lower costs) and scalability is the other one.

Thread Thread
 
jochemstoel profile image
Jochem Stoel

I would like you to elaborate on the problem of concurrency. What practical problem did this solve for you? What were you struggling with every day that Node solved by being single threaded? Do you even know why it is single threaded? I am very curious because the majority of web developers that are considered competent have zero understanding of this.

Thread Thread
 
nhsz profile image
Nicolás Quiroz

I mean, you don't have to deal with multiple threads like you do if you're working with other server-side languages.

Multi-threading is hard, like sharing data between threads. If you are working with server-side web programming in PHP, Java, Python, etc you will have to deal with it unless you have very low traffic APIs or services.

I think Go's approach to concurrency with "light threads" and goroutines is better than the async model though, but Node's was quite clever.

Thread Thread
 
jochemstoel profile image
Jochem Stoel

I think I have never reached any point where I needed to deal with multi-threading when I was writing something in for instance PHP. I suspect that I do this all the time.

Collapse
 
neuron profile image
Kekayan

Thank you :) .