Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Compile time
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|The time during which source code is validated and converted to machine code by a compiler}} {{more citations needed|date=January 2023}} {{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 |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)|run time]]). 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''. == Overview == 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 an immediate, single value.<ref>{{Cite web |last=Yongwei |first=Wu |date=October 7, 2024 |title=C++ Compile-Time Programming |url=https://accu.org/journals/overload/32/183/wu/ |access-date=2025-04-26 |website=accu.org |language=en-gb}}</ref><ref>{{Cite web |title=Compile Time Evaluation |url=https://c3-lang.org/generic-programming/compiletime/ |access-date=2025-04-26 |website=C3 |language=en}}</ref> This is not necessary for correctness, but to improve 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 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). For statically-typed languages such as [[Java (programming language)|Java]] or [[Rust (programming language)|Rust]], types are checked at compile time to ensure [[type safety]].<ref>{{Cite web |title=Data Types - The Rust Programming Language |url=https://doc.rust-lang.org/stable/book/ch03-02-data-types.html |access-date=2025-04-26 |website=doc.rust-lang.org}}</ref> 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]]). However, in the case of [[dynamic compilation]], the final transformations into [[machine language]] happen at run time. Some compile-time operations can also be deferred to link-time while still not incurring a run-time cost. == See also == * [[Compiling]] * [[Type system]] * [[Just-in-time compilation]] * [[Ahead-of-time compilation]] == References == {{reflist}} [[Category:Compiler construction]] {{Comp-sci-stub}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Comp-sci-stub
(
edit
)
Template:More citations needed
(
edit
)
Template:Program execution
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)