K
K
KnightForce2018-04-26 09:02:24
Programming
KnightForce, 2018-04-26 09:02:24

Loading code into memory in different programming languages?

I read somewhere, but did not find again that all JS code is loaded into RAM and then works. Which is logical.
Is it the same in other languages ​​or are there differences?
Interested in C, C++, Java, C#, PHP.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-04-26
@KnightForce

The most primitive interpreters, such as bash, read the script file from disk line by line and simultaneously execute each line read. Ordinary interpreters read the file, parse the code, build the ASTand are already doing it. Modern advanced interpreters (such as PHP, CPython and Javascript V8) after building the AST compile it into bytecode and execute the bytecode already. Most often, in interpreted languages, this bytecode remains only in memory and is not saved to disk. Unlike them, in Java and C#, the stages of code analysis and compilation into bytecode are separated from the stage of bytecode execution. The compiled code is stored in files and then executed by the virtual machine. Compiled languages ​​(C, C++ and others) compile AST not into bytecode, but directly into machine instructions. However, they have recently been increasingly using LLVM .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question