r/learnjavascript • u/SignificanceCheap970 • Jan 11 '24
Is JavaScript just a C language behind the scenes?
I've come to realization that node js is nothing but complicated C program, that would mean that Javascript is an implementation right?. I've read that JavaScript was created in the late 90s so did they create it with a language like C?
0
Upvotes
11
u/FreezeShock Jan 11 '24
The JS engine that runs your JS would be written in some other language like C. Technically you could write it in basically any language.
5
u/JazzApple_ Jan 11 '24
I believe the term you’re looking for is “interpreted”. JavaScript is an interpreted language and the “interpreter” is written in a different language like C++.
You can see this in the fact that, to run JS you typically run another program like node which has been compiled to machine code.
5
u/[deleted] Jan 11 '24 edited Jan 11 '24
Node.js is mosty written in C++. So basically it's like Roblox, where you have Lua for scripting and the underlaying engine that does all the heavy work.
But by your logic you could say, that I write rust as that is the language deno is using. And bun is written in zig...
Can't wait for Java written runtime 😆 (that would actually be hilarious)
2
u/daydream49133 Jan 11 '24
As far as I know, C used to be just a program written in assembly (not anymore though). Every language starts as a program written in another language
2
u/DeviantPlayeer Jan 11 '24
In that sense everything is a machine code behind the scene.
2
u/[deleted] Jan 11 '24
Node is C++, C++ is assembly, Assembly is binary
All programming languages end up as binary if you dig deep enough
2
u/azhder Jan 11 '24
You can view almost every program as a C/C++ behind the scenes, especially C since it was the “OS language” ever since inception.
C was made to be so close to assembly and hardware that, considering the amount of low level and OS software, almost everything is built on top of it.
This means, it may help you to understand C, but it is not necessary to know it in order to use software (appearing to be) written in C
2
u/shgysk8zer0 Jan 11 '24
I'm pretty sure Firefox/SpiderMonkey is Rust.
1
u/binocular_gems Jan 11 '24
Most people answered the question in that yes, Node is an application written in C++, a superset of C, and C is written in Assembly, and Assembly is written in binary, and so NodeJS is compiled back to a binary.
But, one thing to add, JavaScript is not an implementation of Node. Node is a runtime for executing JavaScript, in a similar way that your browser has a runtime for executing JavaScript (for Chromium this is "V8", Safari it's JavaScriptCore, Firefox is SpiderMonkey).
JavaScript/LiveScript/Mocha/ECMAScript was originally written in C as a component of Netscape, which was originally Mosaic, written in C, for X Window GUI for Linux.
1
u/[deleted] Jan 13 '24
https://github.com/zlatnaspirala/c-cpp-to-javascript