I recently learned that JIT compilers are used to compile platform independant code to native code. JVM and the .net runtime environments use this, for better performance and significant reduce in compiling time. My question is that why not the ordinary compilers that compile directly into native code (like c compilers) also be made as JIT? Is there a restriction or a specification for the usage if JIT compilers?
I recently learned that JIT compilers are used to compile platform independant code to
Share
Modern javascript implementations also do JIT, as do some PHP, Python, and Ruby implementations (at least). The trick with JIT, though, is that they are a relatively recent development, and part of what makes them work is that you rely on a framework or runtime of some type that lives on the end-user machine that is capable of making the correct optimizations for that machine and instance of the application.
For languages that want to be close to the "bare metal" of your computer, relying on that extra abstraction layer does not always make sense.
The other issue with JIT is it can add startup time to the application. Since the original answer, software development as a whole has moved a LOT more towards the cloud and continuous integration/deployment, where pure cold startups are more common and the time used for the JIT pre-compile step absolutely matters to perceived performance where it did not in the past.
This is why, e.g., .Net, which has historically been all-in with JIT, has in recent versions made large strides towards better AoT (Ahead of Time) support.