29

I have the following quotation from my compiler's course (in the context of graph coloring):

Because it is slow, graph coloring tends to be used in batch compilers, while linear scan tends to be used in JIT compilers.

I couldn't find a clear definition online. So, what makes a compiler be a batch compiler?

user1868607
  • 2,224
  • 14
  • 23

2 Answers2

43

A JIT (Just-In-Time) compiler compiles code at run-time, i.e. as the program is running. Therefore the cost of compilation is part of the execution time of the program, and so should be minimized.

The opposite of this is an ahead-of-time (AOT) compiler which is basically synonymous with "batch compiler". This converts the source code to machine code and then just the machine code is distributed. Therefore, the compiler can be very slow as it doesn't impact the execution time of the resulting program.

Nowadays, when people say "compiler" they typically mean an AOT compiler. Indeed, the term "AOT compiler" only really started becoming popular relatively recently when people started making AOT compilers for JIT compiled languages, particularly JavaScript. Many of these languages, e.g. C#, compile to an intermediate language for a VM which is then JIT compiled to machine code at run-time. The term "AOT compiler" has the connotation that the source code will be compiled directly to machine code, so no form of JIT compilation is required at run-time.

"Batch compiler" is a bit of an archaic term at this point. The real contrast to a batch compiler when the term was popular was an incremental compiler. Incremental compilation is often associated with languages like Lisp where you had a REPL and you could interactively request the language implementation to compile a specific function. If a function was executed whose compilation had not been requested before, it would typically be interpreted. A batch compiler, by contrast, compiled all functions at once, i.e. in a batch.

psmears
  • 481
  • 3
  • 8
Derek Elkins left SE
  • 12,179
  • 1
  • 30
  • 43
13

The meaning is implied within the quote you give! It stems from the computing term batch processing which is used when the task is not performed in real-time, but it scheduled for later execution by the operating system when the load (often for real-time activities) is less.

A batch compiler is one that does the compiling when a user is not waiting for the result of the compilation. It is one that we would say, using more modern terminology, done in the background.

This is the converse of a JIT (Just-In-Time) which is done "live" at the exact time it is needed without the luxury of spending the extra time to do the processing more thoroughly.

The slower speed of batch compiling can be illustrated by this:

enter image description here

Source: https://xkcd.com/303/

Or even this:

enter image description here

Source: http://dilbert.com/strip/2013-06-22