NEW
A program that translates source code from a high-level language into a lower-level target for execution, often optimizing during translation.
DESCRIPTION
Compilers transform source code into a target form such as machine code, bytecode, or another language. Typical phases include lexical analysis, parsing, semantic analysis, optimization, and code generation. Some compilers produce binaries ahead of time, while others integrate with just-in-time (JIT) compilation at runtime. Optimizations improve performance and size using intermediate representations and analyses. Toolchains often combine compilers with linkers, assemblers, and build systems. Modern ecosystems use frameworks like LLVM to build reusable compiler components. Compilers underpin software portability, performance, and safety enforcement via type and memory checks.
ALTERNATIVE DEFINITIONS
Encyclopaedia Britannica
Compiler, computer software that translates a program written in a high-level language into a machine-language program.
Classical definition focusing on translation from high-level to machine language.
Wikipedia
A compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language).
Stresses translation between source and target languages, not limited to machine code.
Microsoft Learn
The Microsoft C/C++ compiler reads source code and produces object files that are later linked to create executables or libraries.
Vendor-specific view of compiler outputs and toolchain integration.
RELATED TERMS
Assembler Linker Just-in-Time Compilation Ahead-of-Time Compilation Intermediate Representation Optimization LLVM Bytecode Type Checking
COMPETING TERMS
KNOWLEDGE AREAS
Programming Languages Software Engineering Platform & Tooling
TARGET AUDIENCE
Software Developer Software Architect Full Stack Developer Data Engineer DevOps Engineer AI Engineer
EXTERNAL SOURCES
- Wikipedia - Compiler
- LLVM - Documentation on compiler drivers
- GCC - GNU Compiler Collection manual
- Microsoft - MSVC and C++ compiler docs
TOP QUESTIONS
What does a compiler do in the software build process?
It translates source code to a target representation, often object files, which are then linked into executables or libraries. It may optimize code for performance and size.
Category: Concepts
How is a compiler different from an interpreter?
A compiler translates code ahead of execution, while an interpreter executes code directly step-by-step. Many modern runtimes blend both via JIT.
Category: Comparison
What are common phases of a compiler?
Lexing, parsing, semantic analysis, optimization, and code generation are typical phases. Some compilers also include link-time optimization.
Category: Concepts
What is JIT compilation and why use it?
JIT compiles hot code paths at runtime using profile data, improving performance while retaining portability and dynamic features. It trades startup time for steady-state speed.
Category: Topic
What is an intermediate representation (IR) in a compiler?
An IR is a normalized code form used for analysis and optimization. LLVM IR is a popular example enabling powerful, reusable optimizations.
Category: Concepts
What are common mistakes developers make related to compilers?
Misconfiguring optimization flags, ignoring warnings, and mixing incompatible ABI options. These lead to performance regressions and runtime errors.
Category: Mistakes
How do compilers impact performance?
Optimization passes improve instruction selection, inlining, vectorization, and memory usage. Correct flags and profiles can yield large speedups.
Category: Performance
When should I use ahead-of-time vs. JIT compilation?
Use AOT for predictable startup and constrained environments; use JIT for dynamic languages and workloads benefitting from runtime profiling.
Category: Advice
What is the role of linkers with compilers?
Compilers produce object files; linkers resolve symbols and stitch them into final binaries. Link-time optimization can cross-module optimize.
Category: Concepts