re: Python for JavaScript Developers VIEW POST


Python interpreter doesn't create machine code. The code it creates is called p-code (or "intermediate representation", or "bytecode"). Incidentally the "p" does not stand for Python, but for Pascal, because the concept was first used in UCSD Pascal implementation. At that time majority of interpreters were interpreting the source text directly (which is much slower than parsing into AST or P representation).

However that is starkly different to what modern JavaScript runtimes do. JavaScript is converted to an AST intermediate representation in the first run but in subsequent runs it is compiled in much the same way that C, or Go, for example, are compiled. I.e. all the way to native, binary machine code for the CPU it's being executed on.

This design is based on JVM, and it's called JIT (just in time) compilation. Obviously due to it's dynamic typing systems a lot of object/variable handling is still done by the runtime rather than the direct code (but in many cases JIT optimizes code paths if it can infer it's exclusively dealing with, say, strings), which is why even V8 often executes code slower than, say, HotSpot, even if they both are very optimized JIT VMs.

code of conduct - report abuse