HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

How is a JIT compiler different from an ordinary compiler?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
ordinarydifferentcompilerhowfromjit

Problem

There's been a lot of hype about JIT compilers for languages like Java, Ruby, and Python. How are JIT compilers different from C/C++ compilers, and why are the compilers written for Java, Ruby or Python called JIT compilers, while C/C++ compilers are just called compilers?

Solution

JIT compilers compiles the code on the fly, right before their execution or even when they are already executing. This way, the VM where the code is running can check for patterns in the code execution to allow optimizations that would be possible only with run-time information. Further, if the VM decide that the compiled version is not good enough for whatever reason (e.g, too many cache misses, or code frequently throwing a particular exception), it may decide to recompile it in a different way, leading to a much smarter compilation.

On the other side, C and C++ compilers are traditionally not JIT. They compile in a single-shot only once on developer's machine and then an executable is produced.

Context

StackExchange Computer Science Q#257, answer score: 17

Revisions (0)

No revisions yet.