Okay so what is compilation? Well, to start off, computers make no effort to learn your language. So we came up with ways to translate things so that it can understand what we are trying to say.
We started with Assembly languages which used an assembler to convert into machine(computer understands) language. When that started taking most of our time, we made HLL(High Level Languages) which was more English like and was easier to learn for all. To convert that into machine code we used a compiler.
So broadly speaking, a compiler is nothing but a translator. We write something in English, it converts it into gibberish(0’s and 1’s) for the machine. Then came ways of optimising things. As in how fast can the translation work or how small will be the translated file.
AOT vs JIT
If you are familiar with developing apps or websites, you might have come across terms like development and production. Well, these are more than just terms. During development we want to see instant changes while we are editing. We don’t care how much size it takes all we concerned is it should show up on the screen instantly. Compared to production where we want the size to be small and create a smooth UX.
A JIT(Just-In-Time) compiler is what works during editing code. It compiles as displays you the output maybe on your device or simulator. It’s faster because it just compiles what you need. So you move to page1 it compiles that, you move pag2 it compiles that. All in real-time.
Whereas an AOT(Ahead-of-Time) compiler compiles the entire code and is then released, which helps to optimise the code and size.
A popular example is dart which uses JIT during debug and AOT during production or actual installation.