Difference between Ahead-Of-Time and Just-in-Time compilation

Asked

Viewed 718 times

3

While you were reading about templates for ASP.NET I saw that one had support for AOT (Ahead of Time) and the other said nothing.

I have been researching on the subject and I could not understand very well the difference and definition Ahead of Time and Just in Time on the issue of compilation because I do not fully understand the process.

How do the two above actually work? Could you give me an example?

1 answer

3


The AOT compiler is the most traditional where you develop, in it you invoke the compiler and it does the whole process culminating in the executable that can be called on time or transported to another location. Usually it doesn’t need to be that fast and can do more extreme optimizations.

The JIT compiler is invoked at the time of execution, so in each executable call there is a compilation process. It is common to have a previous compilation process that already ensures that some things are correct and maintains an easier format to manipulate. As it will run every time it is important that the process be quick. That’s why it’s common for him not to be good at doing optimizations, except for the more sophisticated ones who detect that something is executed many times (hot path) and make it worth doing a larger optimization process, and then it can even give a better result by already having more information about the current execution environment and context (called tiering). More can be seen in What is a Jitter?.

In a certain way we can say that the interpreters are Jitters, although the term is not usually used, it seems to me even more appropriate than "interpreter", at least in most current implementations.

The best known Jitters are from Java and C#, both have a previous compilation process before. If we consider the interpretation we can talk about almost all implementations of Javascript )PHP will have). Other languages that are usually considered interpreted may have a more classical Jitter process. The best known Aots are C and C++, as well as Delphi, Go, D, Rust. But note that all these languages can and do have both forms. One does not prevent the other unless the language has specified different for some reason, but this does not usually happen.

When it is common to use Jitter and the technology allows AOT can give a gain in the running load, and this can be very important where it has many calls to the executable and needs to respond fast.

In the case of templates can only refer to the fact that the feedback turn a code that assembles the strings directly without having to interpret the feedback code. I wouldn’t exactly call it JIT or AOT compilation in this case, although it’s something like that, I’d say it’s just a generation of code.

  • Why C and C++ are considered AOT and C# for example not, since there is a previous build process running your applications?

  • Because in C and C++ there is only this previous process, there is no later before the execution.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.