Being a dumbass is a human right

Katrine Louise Kølleskov Bryn
The Wanda.space blog
4 min readFeb 17, 2022

--

I ask a lot of dumb-dumb questions. I know that no questions are dumb, but some things a developer should perhaps just ask the internet instead of losing the respect of their colleagues. But I want to go forth as an example that it’s very possible to be both a developer and a dumbass. And I want to put it on the internet so that my employer can see it.

Part 1

You would probably do well to read a book.

- Josh

What is nodeJS and where does it show up in the code?

I’ve read this sentence a million times:

Node.js (Node) is an open source development platform for executing JavaScript code server-side.

I still don’t understand what that means practically. I come from a background of -insert background no one cares about- , but it didn’t really involve JavaScript, Node or even how a browser works. But I sure know how Dijkstra works (no, I don’t).

I asked my colleague Josh (his real name, please don’t look him up) about it:

What is NodeJS? Where does it fit into our codebase?

Think of it like the code you write is the directions and NodeJS is the car. Nothing happens until you start the car. If you give it bad directions then it will crash. Typescript compiler is like someone reviewing your directions to make sure you don’t drive your car into the ocean once you get going.

Is NodeJS JavaScript code that uses Node, and Node is just the umbrella for the whole deal-o?

NodeJS is actually C++ 😅. But there is no difference. Node is just short for NodeJS. Like you can see React or ReactJS.

Ok, so is it a bit of an unfortunate naming?

No, NodeJS executes JavaScript code.

So every time I write a code snippet where I think that you need to address the runtime environment, I’m using NodeJS?

No, you can take a small code and run it in the browser, right? But it might not be compatible because the browser is a different kind of car. For example, it might be a truck, and not a normal car. There are different kind of runtime environments, and the syntax might not always be the right kind.

Ah-ha, but it gives you the opportunity to run certain code snippets, right? So if I DON’T have NodeJS installed and running, and I write process.env in the code, it will make no sense?

Right. Those are examples of calls to the runtime API.

Oh, so when you write certain snippets like process.something, you’re calling the Node runtime API? For example when you write Window.something, you’re calling the browser runtime API?

*Thumbs-up-reaction*

But is there certain syntax that is exclusive to only NodeJS? Like process.env only works for NodeJS, and not other runtime environments like Deno?

There is an equivalent feature. All runtimes have environment variables.

What about import statements vs. require? Require is a runtime import, but aren’t imports also Node?

NodeJS follows the CommonJS module system, and the built-in require function is the easiest way to include modules that exist in separate files. The basic functionality of require is that it reads a JavaScript file, executes the file, and then proceeds to return the exports object. I guess your IDE uses Node before you run things, like checking import paths for example. The thing with the IDE checking the import paths isn’t different than running the program, it’s just like getting a head start so it can check these things for you.

(He later told me that this is from the documentation: https://nodejs.org/en/knowledge/getting-started/what-is-require/)

Where does NPM come in? Is it a package manager that uses Node?

It is a directory of packages that run in Node. I doubt NPM is written in JavaScript but I don’t know. Also there can be node packages that aren’t written in JavaScript. There are native dependencies for example.

I see, so are development and production examples of a runtime environment?

A runtime environment is not the same as a production, staging or development environment. They are just duplicate instances of our stuff. Our stuff includes it’s own runtime environment. You would probably do well to read a book on the core concepts like compilers, runtime environments, etc.

Ouch, then I will try to conclude:

  1. NodeJS (or Node) executes JavaScript code, and is not in use unless you are running the code. Examples of this from the codebase can be calls to the Node runtime API like process.env to get the environment variables, require or import to get packages.
  2. All runtime environments have certain concepts that overlap. All runtimes have environmental variables, for example.
  3. It makes no sense to “write Node code”, because Node isn’t a programming language, rather it’s something that allows JS to be executed outside the browser.

Here is a picture I made of my understanding on Node:

Bonus, this is my understanding of how Node works in context of compiling:

Thank you for reading.

--

--

Katrine Louise Kølleskov Bryn
The Wanda.space blog
0 Followers

Fullstack developer, comic creator and illustrator. I write about working in the startup environment, the arts and mooching off of my colleagues.