Target code generation – translates the optimized intermediate code into assembly or machine code.
Assembly and linking – assembles object files and resolves external references to produce the final executable.
Suggested diagram: A flowchart showing the sequential compiler phases from source code to executable.
5. Why a compiler is essential for high‑level languages
The following points illustrate the necessity of a compiler:
Performance – Compiled code runs at near‑hardware speed. For algorithms with time complexity \$O(n \log n)\$, the constant factors introduced by interpretation can make a practical difference.
Resource constraints – Embedded systems often lack the memory or processing power to host an interpreter, making a pre‑compiled binary the only viable option.
Distribution – End users typically receive executables, not source code, protecting intellectual property and simplifying deployment.
Static analysis – Compilers can perform extensive checks (type safety, unreachable code) before the program ever runs, reducing runtime failures.
6. Summary
A compiler bridges the gap between human‑friendly high‑level languages and the low‑level
instructions a computer can execute. By translating the entire program ahead of time,
compilers provide speed, safety, and portability that are essential for many real‑world
applications, especially where performance and resource usage are critical.