Jump to content

Compile time: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Adding short description: "The time during which source code is validated and converted to machine code by a compiler" (Shortdesc helper)
m correcting link after RM
 
(14 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{Short description|The time during which source code is validated and converted to machine code by a compiler}}
{{Short description|The time during which source code is validated and converted to machine code by a compiler}}
{{Unreferenced|date=December 2009}}
{{more citations needed|date=January 2023}}


{{Program execution}}
{{Program execution}}
In [[computer science]], '''compile time''' (or '''compile-time''') describes the time window during which a language's statements are converted into [[Machine code|binary instructions]] for the processor to execute.<ref>{{Cite web|title=A History of Computer Programming Languages
In [[computer science]], '''compile time''' refers to either the operations performed by a [[compiler]] (the "compile-time operations"), [[programming language]] requirements that must be met by [[source code]] for it to be successfully compiled (the "compile-time requirements"), or properties of the program that can be reasoned about during compilation. Compile time refers to the time duration in which the programming code is converted to the machine code (i.e binary code) and usually occurs before [[Run time (program lifecycle phase)|runtime]].
|url=https://cs.brown.edu/~adf/programming_languages.html|language=en|access-date=2022-12-25}}</ref>
The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concepts related to the context of program execution ([[Run time (program lifecycle phase)|runtime]]).
For example, ''compile-time requirements'' are [[programming language]] requirements that must be met by [[source code]] before compilation and ''compile-time properties'' are properties of the program that can be reasoned about during compilation.
The actual length of time it takes to compile a program is usually referred to as ''compilation time''.


== Compile time/Early binding vs Run time ==
== Compile time/Early binding vs Run time ==
The determination of execution model have been set during the compile time stage. Run time- the method of execution and allocation have seen set during the run time and based on the run time dynamicity.
The determination of execution model have been set during the compile time stage.
Run time- the method of execution and allocation - have been set during the run time and are based on the run time dynamicity.


==Overview==
==Overview==
The operations performed at compile time usually include [[syntax analysis]], various kinds of [[semantic analysis (computer science)|semantic analysis]] (e.g., [[datatype|type checks]] and [[instantiation of template]]) and [[code generation (compiler)|code generation]].
Most compilers have at least the following compiler phases (which therefore occur at compile-time): [[syntax analysis]], [[semantic analysis (computer science)|semantic analysis]], and [[code generation (compiler)|code generation]].
During optimization phases, constant expressions in the source code can also be evaluated at compile-time using [[compile-time function execution|''compile-time execution'']], which reduces the constant expressions to a single value.
This is not necessary for correctness, but improves program performance during runtime.


Programming language definitions usually specify compile time requirements that source code must meet to be successfully compiled. For example, languages may stipulate that the amount of storage required by types and variables can be deduced.
Programming language definitions usually specify compile time requirements that source code must meet to be successfully compiled.
For example, languages may stipulate that the amount of storage required by types and variables can be deduced.


Properties of a program that can be reasoned about at compile time include [[range check|range-check]]s (e.g., proving that an array index will not exceed the array bounds), deadlock freedom in concurrent languages, or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time).
Properties of a program that can be reasoned about at compile time include [[range check|range-check]]s (e.g., proving that an array index will not exceed the array bounds), [[deadlock (computer science)|deadlock]] freedom in [[concurrent language]]s, or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time).


Compile time occurs before [[link time]] (when the output of one or more compiled files are joined together) and [[Run time (program lifecycle phase)|runtime]] (when a [[computer program|program]] is [[Execution (computing)|executed]]). In some programming languages it may be necessary for some compilation and linking to occur at runtime. There is a trade-off between compile-time and link-time in that many compile time operations can be deferred to link-time without incurring extra run-time.
Compile-time occurs before [[link time]] (when the output of one or more compiled files are joined) and [[Run time (program lifecycle phase)|runtime]] (when a [[computer program|program]] is [[Execution (computing)|executed]]).
Although in the case of [[dynamic compilation]], the final transformations into [[machine language]] happen at runtime.


There is a trade-off between compile-time and link-time in that many compile time operations can be deferred to link-time without incurring run-time cost.


"Compile time" can also refer to the amount of time required for compilation.


==See also==
==See also==
Line 26: Line 33:
*[[Compiling]]
*[[Compiling]]
*[[Type system]]
*[[Type system]]
*[[Just-in-time_compilation | Just in time compilation]]
*[[Dynamic compilation]]
* [[Just-in-time compilation|Just in time compilation]]

==References==
{{reflist}}


{{DEFAULTSORT:Compile Time}}
{{DEFAULTSORT:Compile Time}}
[[Category:Compiler construction]]
[[Category:Compiler construction]]



{{Comp-sci-stub}}
{{Comp-sci-stub}}

Latest revision as of 19:04, 20 August 2024

In computer science, compile time (or compile-time) describes the time window during which a language's statements are converted into binary instructions for the processor to execute.[1] The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concepts related to the context of program execution (runtime). For example, compile-time requirements are programming language requirements that must be met by source code before compilation and compile-time properties are properties of the program that can be reasoned about during compilation. The actual length of time it takes to compile a program is usually referred to as compilation time.

Compile time/Early binding vs Run time

[edit]

The determination of execution model have been set during the compile time stage. Run time- the method of execution and allocation - have been set during the run time and are based on the run time dynamicity.

Overview

[edit]

Most compilers have at least the following compiler phases (which therefore occur at compile-time): syntax analysis, semantic analysis, and code generation. During optimization phases, constant expressions in the source code can also be evaluated at compile-time using compile-time execution, which reduces the constant expressions to a single value. This is not necessary for correctness, but improves program performance during runtime.

Programming language definitions usually specify compile time requirements that source code must meet to be successfully compiled. For example, languages may stipulate that the amount of storage required by types and variables can be deduced.

Properties of a program that can be reasoned about at compile time include range-checks (e.g., proving that an array index will not exceed the array bounds), deadlock freedom in concurrent languages, or timings (e.g., proving that a sequence of code takes no more than an allocated amount of time).

Compile-time occurs before link time (when the output of one or more compiled files are joined) and runtime (when a program is executed). Although in the case of dynamic compilation, the final transformations into machine language happen at runtime.

There is a trade-off between compile-time and link-time in that many compile time operations can be deferred to link-time without incurring run-time cost.

See also

[edit]

References

[edit]
  1. ^ "A History of Computer Programming Languages". Retrieved 2022-12-25.