• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

High-level programming languages (C, C++, Java, Python) are human-readable but machines only understand binary machine code. Without a compiler, every program would need to be written in assembly or machine code — a tedious, error-prone, and non-portable process.

Core Idea

A compiler is software that translates a program written in a high-level source language into an equivalent low-level target language (machine code or assembly). It acts as the bridge between human-readable code and machine-understandable instructions, automating translation, checking correctness, and reporting errors.

How It Works

A compiler operates in multiple phases organized into two major parts: the analysis (front-end) and synthesis (back-end). The front-end analyzes the source program and creates an intermediate representation. The back-end uses this representation to generate target code. The phases include lexical analysis, syntax analysis, semantic analysis, intermediate code generation, code optimization, and final code generation.

Visual Explanation

compiler_flow Source Source Code (High-Level Language) Frontend Front End (Analysis) Source->Frontend input IR Intermediate Representation Frontend->IR produces Backend Back End (Synthesis) IR->Backend input Target Target Code (Machine/Assembly) Backend->Target produces

Semantic Network

semantic_compiler THIS Compiler PRE1 Phases of Compiler THIS--PRE1 built from PRE2 Lexical Analysis THIS--PRE2 built from OUT1 Code Generation THIS--OUT1 builds into CON1 Interpreter THIS--CON1 contrasts with REL1 Compiler Construction Tools THIS--REL1 related REL2 Programming Language Generations THIS--REL2 related

Key Properties

  • Two-part architecture: Front-end (analysis) + Back-end (synthesis)
  • Language translation: Source language → Target language (not execution)
  • Error detection: Reports lexical, syntactic, and semantic errors
  • Portability: Same source can be compiled for different target machines
  • Optimization: Can improve code quality without changing semantics

Connections

Edge Cases & Gotchas

  • Compiler vs Cross-Compiler: A compiler that runs on one platform but generates code for a different platform is a cross-compiler
  • Just-In-Time Compilation: Modern JVMs use JIT compilation — bytecode is compiled to native code at runtime, blurring the line between compiler and interpreter
  • Incremental Compilation: Not all compilers recompile everything — many (like javac) support incremental compilation for faster development cycles