title: Why is Java faster when using a JIT vs. compiling to machine code?
body: <p>I have heard that Java must use a JIT to be fast. This makes perfect sense when comparing to interpretation, but why can't someone make an ahead-of-time compiler that generates fast Java code? I know about <code>gcj</code>, but I don't think its output is typically faster than Hotspot for example.</p>
  
  <p>Are there things about the language that make this difficult? I think it comes down to just these things:</p>
  
  <ul>
  <li>Reflection</li>
  <li>Classloading</li>
  </ul>
  
  <p>What am I missing? If I avoid these features, would it be possible to compile Java code once to native machine code and be done?</p>