by joha4270 · 4mo ago · 0 comments
The big tradeoff you're making is that you have significantly less time to run your optimizer, since not everybody has a beefy machine or the patience to wait a day for their browser to start first time.
You could try doing optimization ahead of time, but I think (I could be wrong here) you would inevitably end up adding in some CPU assumptions if you went much further. This also somewhat conflicts with an advantage of VM based execution, that new optimizations apply to old binaries.
I'll also note that hand rolled assembly/SIMD code still beats compilers at the extreme end and you would either have to throw that away, or get all the disadvantages mentioned above without all the advantages
Not necessarily, you work around this with JIT caches, which allow the optimiser not to start always from zero.
Additionally your can also AOT compile, with or without PGO data.
All modern bytecode implementations, at least for Java and .NET, use a mix of JIT with caching/AOT/PGO.
Adding another workaround, shipping the JIT cache metadata alongside the program, and dynamically sharing it across all devices of the same category, as done in Android.
Some people might write some native code that is faster, but that is hardly the norm.
There are many classes of programs that dont work particularly well if written in java, such as video editing or graphics because you know the rest.