0

Seemingly you can compile the bytecode into native during some installation of application, without loosing the cross-platform-issue.

Installation doesn't necessarily means a GUI installation. That can optionally be just a silence process that happens on the first running of the executable. (With or without a graphical process bar)

That would be (I think) much easier for the developers of the languages, and result in a faster executable, without loosing the adaptations to the current machine.

Letterman
  • 4,076
  • 5
  • 29
  • 41
  • Read this QA: http://stackoverflow.com/questions/2106380/what-are-the-advantages-of-just-in-time-compilation-versus-ahead-of-time-compila – Joanvo Jun 13 '14 at 11:52
  • 1
    Well, this is a very interesting subject indeed, but I don't think that it's a good question for StackOverflow... Not in this form. – Kamil T Jun 13 '14 at 11:53

2 Answers2

1

Something similar does happen behind the scenes (at least with .NET). NGen can cache native images in the native image cache, so that your code won't have to be compiled a second time on that machine.

Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead of using the just-in-time (JIT) compiler to compile the original assembly.

dcastro
  • 66,540
  • 21
  • 145
  • 155
  • I'm not asking HOW to do that. I'm asking why that was the choice of the designers in the first place, while it seems much more difficult – Letterman Jun 13 '14 at 11:59
  • You asked "Why does C# and Java compile JustInTime instead of compling everything once first run/installed?", and my answer is "The question is moot, because the code *is* compiled once, when you run it for the first time". – dcastro Jun 13 '14 at 12:01
  • I'm quite sure the JIT is still doing work even in the second run. – Letterman Jun 13 '14 at 12:15
-1

JIT compilation makes the code much faster while running than using an interpreter, but the initial cost can be prohibitive, depending on what is being done.