Answer the question
In order to leave comments, you need to log in
What are the interpreters and compilers of different languages written in?
Might be a dumb question, but what are the interpreters or compilers of programming languages like JavaScript or C++ written in? In what language? And how is their code "understood", where is it stored? That is, I wrote a program in JS, for example, it was read by the interpreter and executed, but what did the interpreter do?
Answer the question
In order to leave comments, you need to log in
JavaScript is a programming language. It is impossible to write it, compilers, interpreters write it (in this case, probably engines). Core js engines:
SpiderMonkey - first ever js engine (written in C++)
V8 - written in C++ and js
Rhino - written in java.
but what did the interpreter do?this is a very big topic, it is impossible to give an answer here.
As other answers have already said, compilers and interpreters write the same way in programming languages.
As for compilers, it is also believed that a mature language allows you to write your own compiler on yourself. And for many compiled languages, compilers are actually written in themselves. But nevertheless, the very first compiler will still have to be written in another language, in the modern world, OCaml is very often chosen for this, although other languages are quite suitable.
Interpreted languages need an interpreter that is written in compiled languages. The scope of choice here is huge, but the most common is either C or C++.
There is also JIT compilation (js (not always), lua), in which the entire compilation process occurs immediately before execution, as well as hybrid AOT + JIT compilation (C#, Java), when the source code is compiled into bytecode during development (AOT ), and before execution, the bytecode is compiled to machine code (JIT), which allows you to get pluses from both types of compilation. JIT compilers, like interpreters, are usually written in AOT-compiled languages.
Well, we must not forget that almost every language has a standard library that can be written both in the language itself (C, C ++, Go, Rust), in the language itself + in another, more often in C or C ++ (js (not in all engines), C#, Java, python (not sure if it's not the next type anymore)), or completely in another language (php, python (?)). It all depends on how much low-level communication with the OS and hardware is available in the language, as well as how quickly it can be done without breaking the "sugar" of the language.
The engine (interpreter) of the programming language is also written in the programming language. Those. there is, for example, a js or php interpreter, and you call the strlen() function inside the php file. At this time, the C function described in the php system files is called. In any case, some code in another language will interpret / compile all the built-in constructions and functions of the language. But in order to understand more deeply what is a compiler / interpreter, and what is a PL (specification), you should read prof. literature of the article, it is possible to watch a video on this topic.
The source code of the program is executed by passing to the processor instructions for execution (machine code) obtained from the bytecode (object code).
Generation from source code to machine code can be implemented in the same programming language as the listing of the executable program, or in any other.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question