3

I've been trying to understand what a runtime environment really means after I searched what Node js is

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

I get that Node js uses V8 as its Javascript engine which can read Js Code, interpret it and run it, and that the runtime environment provides extra functionalities to your Javascript.

but if someone asks me what a runtime environment is, should I say it is a program which has two main jobs:

  • to use a JS engine to read JS code and run it
  • to provide extra functionalities to Javascript

if it is not a program, what should I call it?

GirkovArpa
  • 4,427
  • 4
  • 14
  • 43
Eduardo
  • 407
  • 1
  • 4
  • 12
  • Why not call it a "runtime environment"? – Pointy Sep 20 '20 at 02:34
  • 3
    anything that is a compiled executable (e.g. a `.exe` in windows) can be called a program (though program isn't limited to compiled executables) - here's one definition of program - https://techterms.com/definition/program - so, yeah, it's a program – Jaromanda X Sep 20 '20 at 02:34
  • 2
    Yes, node.js is a program. It is an executable and you run it on the host OS like you would run your editor or any other program. On the command line, you give it the path of a script you want it to run. – jfriend00 Sep 20 '20 at 02:34
  • It's not *necessarily* a "program", however. Or to put it differently, calling it a "program" is less accurate than calling it a "JavaScript runtime environment". Node is a program whose only real purpose is to be a runtime environment for JavaScript code. However, another application might be devoted to a much broader purpose, but still embed a JavaScript runtime for some particular reasons. So just calling it "a program" doesn't mean very much. – Pointy Sep 20 '20 at 02:37
  • Another obvious example is right here in front of us: your web browser. Yes, your web browser is "a program". But as a JavaScript runtime environment, it has a vast amount of detail that's completely lost by calling it simply "a program". The runtime environment of a browser encompasses all the DOM APIs, in particular. Yes, the browser is "a program", but it's an example of how each runtime environment can be wildly different from the next one. – Pointy Sep 20 '20 at 02:40
  • @Pointy I understand what you mean but, the main point is that I've been trying to understand how the SO sees a runtime environment – Eduardo Sep 20 '20 at 02:51
  • The "SO"? What does that mean? – Pointy Sep 20 '20 at 03:07
  • @Pointy OS* it was a typo, my bad. – Eduardo Sep 20 '20 at 03:08
  • Well the OS (generally) does not know that JavaScript exists. It's a language that by its design is intended to live inside some kind of "cocoon", with connections to the outside world provided externally. That's why "runtime environment" is an accurate term. – Pointy Sep 20 '20 at 03:09
  • Consider that there are JavaScript environments for micro-controllers like Raspberry Pi that are basically the native programming language for the device. That's a "runtime environment", but it's also more-or-less the operating system. Is that a "program"? Well, maybe or maybe not, but the term is so generic that it doesn't add much information. – Pointy Sep 20 '20 at 03:12
  • @Pointy so you think that would be more apropriate to say that a Javascript Runtime Enviroment is a sort of container for running Javascript and extending its functionalities ? – Eduardo Sep 20 '20 at 03:12
  • 1
    @Eduardo yes, exactly, that's a great way to put it. There are many possible variations but they all do that basic thing. – Pointy Sep 20 '20 at 03:13
  • @Pointy thank you so much for your time and patience, helped me a lot!! – Eduardo Sep 20 '20 at 03:14
  • Does this answer your question? [What is the difference between JavaScript Engine and JavaScript Runtime Environment](https://stackoverflow.com/questions/29027845/what-is-the-difference-between-javascript-engine-and-javascript-runtime-environm) – alotropico Oct 08 '20 at 03:22

0 Answers0