Hacker News new | ask | show | jobs
by pjmlp 3399 days ago
Another thing that has helped Java was the decision to use a JIT.

Most Java JITs are able to remove code if it is proven unreachable, which allows to use pure Java code for what would be #ifdef in C, with the caveat that all branches must compile.

1 comments

You would think that AOT would be the right time to remove dead code.
Only if it can be fully determined at compile time.

For example a debug flag can depend on a command line parameter, but it will be used to initialize a constant variable.

So the code can be shipped with both versions, and the JIT will just remove the unused branches.