CSE411

CSE411: Introduction to Compilers

Overview

Jooyong Yi (UNIST)

2026 Fall
CSE411

What is a Compiler?

2026 Fall
CSE411

What is a Compiler?


Source Program →  ································· → Binary

2026 Fall
CSE411

Why do we need a compiler?

Why is not an interpreter enough?

2026 Fall
CSE411

Interpreter Example

import operator

def execute(cmd_seq, stack):
    cmd = cmd_seq[0]
    if isinstance(cmd, int):
        stack.insert(0, cmd)
        cmd_seq.pop(0)
    elif cmd in ['add', 'sub']:
        if not len(stack) >= 2:
            raise Irreducible
        n1 = stack.pop(0)
        if not isinstance(n1, int):
            raise Irreducible
        n2 = stack.pop(0)
        ans = int(operator.__dict__[cmd](n2, n1))
  • Consider input: [5, 2, 'add']
2026 Fall
CSE411

Interpreter

  • Computation is performed indirectly using software instructions (e.g., the Python arithmetic functions)
|------------------------|
|       Program          |
|------------------------|
|      Interpreter       |
|------------------------|
|       Hardware         |
|------------------------|
2026 Fall
CSE411

Interpreter

  • An interpreter typically handles each line of input one by one, and it loses an opportunity for code optimization.
def foo():
    return 1234 * 1234

print(foo() + foo())
2026 Fall
CSE411

Compiler = Translator


Source Program →  ································· → Binary

  • A compiler translates a source program into a target program.
2026 Fall
CSE411

Translator


Program in L1 →  ································· → Program in L2

2026 Fall
CSE411

Transpiler = Source-to-Source Compiler

Source Program in Python →  ···························· → Source Program in JavaScript

Source Program in C →  ································· → Source Program in Rust
2026 Fall
CSE411

Basic Questions Regarding Compilers

  • How does a compiler work as a whole?
  • What are the major components of a compiler?
  • How does each component of a compiler work?
2026 Fall
CSE411

Advanced Questions Regarding Compilers

  • How can we optimize a program?
  • How can we make sure that (source program) ≡ (target program)?
  • How can we prove the correctness of compiler optimizations?
  • ...
2026 Fall
CSE411

Grading

  • Individual assignments: 30%
  • Attendance and participation: 30%
  • Final exam: 40%
2026 Fall
CSE411

Assignment

  • Individual assignments: 30%
    • 4 assignments are planned.
    • Student presentation is planned.
  • Attendance and participation: 30%
  • Final exam: 40%
2026 Fall
CSE411

Attendance and Participation

  • Individual assignments: 30%
  • Attendance and participation: 30%
    • More actively participating students will receive higher scores.
  • Final exam: 40%
2026 Fall
CSE411

Final Exam

  • Paper-based exam
    ○ ○ ○ ○ ○
  • Oral exam
    ○—○—○
    ╲│╱│╲
    ○—○—○
2026 Fall