Search code examples
bytecodeinterpreted-language

is the code for interpreted languages re-interpreted every time the line is reached?


suppose that no bytecode is generated for a program, like in Ruby, Perl, or PHP, in this case, is line 1 below re-interpreted every time the execution reach line 1 again?

while ($indexArrayMoviesData < $countArrayMoviesData + $countNewlyAddedMoviesData) {
  # do something
}

that is, if the loop runs 100,000 times, then that line will be re-interpreted 100,000 times?

and if so, the bytecode creation helps not only the initial start up of he program, but also during the execution? (because code doesn't need to be re-interpreted again)


Solution

  • Typically, it'll be converted into byte code and that byte code will then be executed.

    But in the case of PHP for example, the byte code is regenerated on every request/page view. Unless you install a byte code (or opcode as it's called often in the case of PHP) cache, such as XCache, APC or EAccelerator.