Jump to content

Compile time: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
Clarified the article overall, removed some near-gibberish paragraph about early binding.
Line 3: Line 3:


{{Program execution}}
{{Program execution}}
In [[computer science]], '''compile time''' (or '''compile-time''') describes the time window during which a computer program is [[compiled]].
In [[computer science]], '''compile time''' (or '''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]].
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, the ''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 seen set during the run time and 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 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 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 together) and [[Run time (program lifecycle phase)|runtime]] (when a [[computer program|program]] is [[Execution (computing)|executed]]).
Although in the case of [[Dynamic compilation|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]]
*[[Dynamic compilation ]]
*[[Just-in-time_compilation | Just in time compilation]]
*[[Just-in-time_compilation | Just in time compilation]]



Revision as of 09:11, 15 April 2022

In computer science, compile time (or compile-time) describes the time window during which a computer program is compiled. 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, the 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

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.

Overview

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 together) 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