5 ms·
> faster than C or Rust in some circumstances how?
by axiosgunnar 5y ago
> faster than C or Rust in some circumstances
how?
- jph 5y agoDynamic optimizations for the specific target machine and also long lifetimes. For example when a specific target machine has a specific CPU instruction that the JIT can leverage, or has a ton of RAM that the JIT can use for caching such as for memoized methods.
- olau 5y agoI remember asking the same question about Java many years ago. Some optimizations become much easier in the actual running environment. You know the hardware so don't have to cater to lowest common denominator, and you know what's actually happening and don't have to guess. Profile-guided optimizations later showed up to bridge some of the gap, but I think JITs are typically built with a different mind set, so there are some things they excel at. A funny example is something like a regexp matcher where a JIT might take an actual regexp built on the fly, say based on a user searching for "foo bar", and optimize code for it.