One file. Many languages. One runtime won't tell you.
A CS lecture on polyglot files — single files that are simultaneously valid in multiple languages or formats.
examples/
demo.c C + Python polyglot (the main demo)
bash_python.sh Bash + Python polyglot
presentation/
app.py Flask slide deck server
requirements.txt
templates/
index.html 12-slide terminal-aesthetic presentation
# C + Python polyglot
python examples/demo.c
gcc examples/demo.c -o demo && ./demo
# Bash + Python polyglot
bash examples/bash_python.sh
python3 examples/bash_python.shcd presentation
pip install -r requirements.txt
python app.py
# open http://localhost:5000Navigate slides with arrow keys, Space, or the on-screen buttons.
- What is a polyglot file?
- How parsers work (ignored regions, skip directives)
- HTML + CSS + JavaScript — the web is already polyglot
- Binary polyglots — JPEG+ZIP, GIFAR, PDF+ZIP
- The C+Python trick —
#if 0+ triple-quoted strings - Live demo —
examples/demo.c - Bash+Python — the quoted exec trick
- polycompiler — Python+JS (github.com/evanzhoudev/polycompiler)
- Why it matters — CTF, security, parser literacy, art
- Exercises