DEV Community

Discussion on: if javascript only needs the browser to compile why can't other languages do it

Collapse
 
sfleroy profile image
Leroy

I think the short answer is that all languages need some kind of runtime. For js this ships with all browsers, for dotnet it ships with windows, for C, C++ this ships with all operating systems.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

C doesn't really need a runtime.

Collapse
 
saptakbhoumik profile image
SaptakBhoumik • Edited

It does have a runtime called crt which will initialize the argv and argc and call the main function , however it is extremely lightweight

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

You don't need a separate runtime environment though. Depending on what system you're compiling for, your compiler could easily just turn argc and argv into two globals, one being 0 and the other an empty array, or add some boilerplate code that reads them from somewhere else, like some external sensor. One could get creative with that.

Thread Thread
 
saptakbhoumik profile image
SaptakBhoumik

That's not how it morks most of the time

Thread Thread
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

But that's not what we're talking about; it doesn't need a runtime, regardless of whether it usually has one.