4 ms·
Yes, but it shows that the language was designed for interpretation. E.g. lazy static initializers is weird in AOT compilation.
by qznc 11y ago
Yes, but it shows that the language was designed for interpretation. E.g. lazy static initializers is weird in AOT compilation.
- pjmlp 11y agoIt is not weird in functional programming languages.
- qznc 11y agoI think you misunderstood me, because I used "lazy". It has nothing to do with Haskell lazyness. In Java static fields are initialized when a class is loaded by the class loader. A class is only loaded when used. If anything (IO,scheduler,etc) changes the order in which classes are used, then initializers are called in a different order and their side effects as well. This semantic is mandatory by language definition. In a Java AOT compiler this means every access to a static field must be prefixed with a (synchronized) check if the class is already initialized and optimizing it away is rarely possible. A JIT compiler does not even care, because it knows the class is already loaded. For contrast, in C++ static fields are all initialized before main is called.
- pjmlp 11y agoActually I don't know how the current AOT compilers approach that situation. Now with Oracle taking the steps to eventually make AOT compilation also a feature in the reference JDK, I suppose whatever issues might still exist they will be tackled.