29
$\begingroup$

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?

$\endgroup$
1

2 Answers 2

43
$\begingroup$

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.

$\endgroup$
5
  • 2
    $\begingroup$ And back in the old days compliers where not run interactively at all you had to submit a job to a batch queue in order to compile your program $\endgroup$ Commented May 31, 2017 at 18:49
  • $\begingroup$ And some language implementations (GNU's awk, cpython and so on) compile the whole input to an internal representation as the first step at run-time, which mixes some of the properties described here. $\endgroup$ Commented May 31, 2017 at 19:32
  • 1
    $\begingroup$ @dmckee most if not all language implementations, actually $\endgroup$ Commented Jun 1, 2017 at 11:26
  • $\begingroup$ Another ambiguity: Tools called batch compilers existed for MSDOS operating systems, these compiled batch files into executable files.... $\endgroup$ Commented Jun 1, 2017 at 12:17
  • $\begingroup$ Of course there always is an internal representation. But sometimes it is a language in its own right, as in Gcc, Llvm or .Net. This is due to the front-end/middle/back-end architecture, the front-end transforming the language (C,C++,Java,fortran..) to a common lower-level language, then the optimization algorithms are run, and finally this optimized code in the common language is transformed by the back-end into bytecode or assembler, executable or static or dynamic library. $\endgroup$
    – reuns
    Commented Jun 1, 2017 at 14:22
13
$\begingroup$

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

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.