Incremental compiler

From HandWiki
Revision as of 07:14, 27 June 2023 by LinXED (talk | contribs) (over-write)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

An incremental compiler is a kind of incremental computation applied to the field of compilation. Quite naturally, whereas ordinary compilers make a so-called clean build, that is, (re)build all program modules, an incremental compiler recompiles only modified portions of a program.

Definition

Imperative programming

In imperative programming and software development, incremental compilation takes only the changes of a known set of source files and updates any corresponding output files (in the compiler's target language, often bytecode) that may already exist from previous compilations. By effectively building upon previously compiled output files, an incremental compiler avoids the wasteful recompiling of entire source files, where most of the code remains unchanged. For most incremental compilers, compiling a program with small changes to its source code is usually near instantaneous. It can be said that an incremental compiler reduces the granularity of a language's traditional compiling units while maintaining the language's semantics, such that the compiler can append and replace smaller parts.

Many programming tools take advantage of incremental compilers to provide developers with a much more interactive programming environment. It is not unusual that an incremental compiler is invoked for every change of a source file, such that the developer is almost immediately informed about any compilation errors that would arise as a result of their changes to the code. This scheme, in contrast with traditional compilation, shortens a programmer's development cycle significantly, because they would no longer have to wait for a long compile process before being informed of errors.

One downside to this type of incremental compiler is that it cannot easily optimize the code that it compiles, due to locality and the limited scope of what is changed. This is usually not a problem, because for optimization is usually only carried out on release, an incremental compiler would be used throughout development, and a standard batch compiler would be used on release.

Interactive programming

In the interactive programming paradigm, e.g. in Poplog related literature,[1] and [2] an interactive compiler refers to a compiler that is actually a part of the runtime system of the source language. The compiler can be invoked at runtime on some source code or data structure managed by the program, which then produces a new compiled program fragment containing machine code that is then immediately available for use by the runtime system. If the newly compiled fragment replaces a previous compiled procedure the old one will be garbage collected. This scheme allows for a degree of self-modifying code and requires metaprogramming language features. The ability to add, remove and delete code while running is known as hot swapping. Some interactive programming platforms mix the use of interpreted and compiled code to achieve the illusion that any changes to code are accessible by the program immediately.

List of incremental compilers

Imperative and functional languages
Interactive environments and runtime systems

See also

References

  1. http://www.cs.bham.ac.uk/research/projects/poplog/primer/node14.html , teaching primer to Poplog
  2. The Smith, Sloman and Gibson 1992 paper below (now available online)
  3. "Steven P. Reiss Home Page". Brown University. 9 June 2011. Archived from the original on 10 February 2013. https://web.archive.org/web/20130210083842/http://cs.brown.edu/~spr. Retrieved 8 August 2014. 
  4. Popple, James (1987). Incremental Compilation and its Implementation in the PECAN Programming Environment Generator (PDF) (Honours thesis). Australian National University. Archived (PDF) from the original on 15 August 2014. Retrieved 8 March 2013. Alt URL Also available at Google Books.
  5. https://gcc.gnu.org/ml/gcc/2007-07/msg00496.html , the announcement made beginning the IncrementalCompiler branch of GCC
  6. http://www.eclipse.org/jdt/core/index.php , a description of the JDT Core Component
  7. https://docs.gradle.org/2.1/release-notes.html , release notes of Gradle version 2.1
  8. "Announcing Rust 1.24 | Rust Blog". https://doc.rust-lang.org/edition-guide/rust-2018/the-compiler/incremental-compilation-for-faster-compiles.html. 
  9. "Go 1.10 Release Notes - the Go Programming Language". https://golang.org/doc/go1.10#build. 

External links