What does it mean that a language is "interpreted"?

Are there any languages ​​like for example. Ruby (if MRI is being executed, I mean, that it does not compile into bytecode), is it actually being analyzed every time that execution, for example, of a method or body of a loop is required? I mean, in order to execute a loop, do you need to parse its body N times?

I always thought that all these programs are analyzed once in the bootstrap, converted to a "strongly typed instruction tree", etc. This is not true?

+4
source share
2 answers

Now I just will be in the know and say that only EVERY programming language is interpreted, whether it is software (Ruby, Python, Java) or a hardware (C, C ++) interpreter :)

For the real answer, although I do not know about the Ruby internal implementation, I am sure that the hell they do not analyze the statement again and again. Although you are not using bytecode in the original implementation (or have they already migrated a moment?), They use some intermediate representation (you can see it beautifully when you want to write C extensions for it), thus simply repeating them over and over again .

+4
source

Interpreted is a word with a very loose definition. Even machine code instructions are interpreted by the processor.

In general, a distinction is made between languages ​​that are compiled before they are launched, and languages ​​that do not have a compilation process, and run inside another program called an interpreter. The latter types of languages ​​are often referred to as interpreted languages .

In some cases, the line is not so clear:

  • Some languages ​​may be compiled or interpreted, for example. PHP
  • Some interpreted code can be compiled at runtime in an instruction on machines ( JIT compilation ).
  • Some compiled languages ​​may have exec functionality that allows you to generate and run code at run time, bypassing the normal compilation process.
+4
source

Source: https://habr.com/ru/post/1309659/


All Articles