Overview of #529: Computer Science from Scratch
This episode of Talk Python to Me (ep. 529, recorded Oct 26, 2025) features David Kopech talking with host Michael Kennedy about his new book, Computer Science from Scratch. The book is aimed at programmers who learned to code first (often in Python) and now want to understand the deeper CS ideas and the software stack that underpin modern tools—interpreters, low-level hardware behavior, emulation, parsing, bits/bytes, and creative computational projects.
Guest & context
- Guest: David Kopech — computer science professor (Albright College), program director, and author. Previously at Champlain College; author of Classic Computer Science Problems in Python.
- Host: Michael Kennedy — Talk Python to Me.
- Audience: intermediate/advanced Python programmers, self-taught devs, engineers preparing for interviews or deeper-system roles.
- Book positioning: Not a “how-to ship this app now” book; instead a hands-on survey of core CS ideas implemented in Python to make low-level concepts accessible.
Main topics covered
Purpose & approach of the book
- Build the software stack from the bottom up so Python programmers understand what runs under their code (interpreters, emulators, memory, file formats).
- Use Python as a teaching language for accessibility; many projects are implemented so readers can actually run and tinker with them.
- Practical payoff: better intuition for parsing, interpreters, file formats, performance trade-offs, and debugging generated or LLM-produced code.
Small / minimal languages
- BF (esoteric language with eight symbols): demonstrates Turing completeness; implementing an interpreter (~30 lines of Python) shows how little is needed to compute everything.
- Tiny BASIC: a real, historically relevant dialect reimplemented to show how practical languages ran on tiny machines (2–4 KB RAM).
Interpreters & parsers
- Writing interpreters and parsers: understanding tokens, syntax, semantics, and why that knowledge helps in real engineering tasks (e.g., custom config formats).
Computational art & file formats
- Dithering for old black-and-white Macs: teaches what a pixel is, bit/byte layout, run-length encoding (RLE), and file-format construction (MacPaint).
- “Impressionist” program: produce art that looks painted using simple vector-placement heuristics rather than ML — shows how simple algorithms can produce powerful output.
NES emulator (crown-jewel chapter)
- Implemented in pure Python: CPU (6502 subset), simplified PPU (graphics), no APU (audio omitted).
- Can run real NES games (Donkey Kong demonstrated); runs slower than native (15 fps vs. 60 fps on tested machines).
- Teaches CPU cycles, memory mapping, sync between CPU/PPU (timing constraints like PPU running 3 cycles per CPU cycle), and why exact timing is crucial for emulators.
Education & pedagogy
- Curriculum work: Albright College is launching refreshed CS major plus new AI and Cybersecurity majors (firm CS/math foundation, ethics courses, and internships).
- AI in education: LLMs/ChatGPT dramatically change assessment—David has experimented with moving to paper tests, controlled offline environments, and rethinking assignments to ensure students learn fundamentals rather than outsourcing basics to LLMs.
- Recommendation: teach fundamentals first (loops, functions), enforce through exams or monitored environments, then show how to leverage LLMs as productivity tools that still require human oversight.
Language, performance & tooling tradeoffs
- Python vs. C/C++/Rust:
- Python is much more accessible—great for onboarding and providing early wins.
- Lower-level details (pointers, malloc/free) are still important and should be taught later (e.g., in systems/OS classes).
- Learn one language well before jumping around; transferable concepts make later low-level learning easier.
- Performance and ecosystem:
- Pure Python has runtime cost; some book projects will be noticeably slower than C equivalents.
- Options to accelerate: Cython, Numba, native extensions, or newer CPython improvements (Free-threaded Python / 3.14+), Mojo, PyPy, etc.
- Packaging and deployment friction (desktop and mobile apps, notarization, app stores) remains a barrier for Python as a native GUI/mobile platform.
- Game dev and tooling:
- There’s precedent for higher-level languages powering successful game engines (e.g., Unity / C#); a similar “Python-first with high-performance lower layer” scenario is plausible but requires solving deployment/package/signing issues.
Notable quotes & insights
- “Python is the most accessible language in the world.” — reason for choosing Python to teach low-level CS.
- “To interpret BF, you only need about 30 lines of Python.” — demonstrates minimalism of computational power.
- “If students only go into computer science for the job, they’re probably not going to be successful.” — on motivation and persistence in CS education.
Key takeaways
- Implementing tiny languages and emulators gives intuition that demystifies higher-level systems (e.g., CPython, engines, file formats).
- Python is a great teaching vehicle for low-level CS ideas; accessibility helps broaden participation.
- LLMs are powerful but create assessment/learning challenges—educators must design assignments and controls to ensure foundational learning.
- Performance trade-offs exist; Python can be accelerated or integrated with native code where needed, and recent CPython work is improving real-world performance.
- Hands-on projects (interpreters, emulators, computational art) are effective for learning because they produce tangible, fun results and force you to understand low-level mechanics.
Recommended hands-on projects (from the book)
- Implement the BF interpreter (≈30 lines of Python) to learn minimal Turing-complete design.
- Build a Tiny BASIC interpreter to run historical programs and learn parsing, memory model.
- Implement dithering and export a MacPaint-format file (bits, RLE, file headers).
- Build the “Impressionist” painter to explore simple heuristics producing complex imagery.
- Build the NES emulator (CPU + simplified PPU) and then optimize it (exercise: accelerate with Cython or native code to reach 60 fps).
Who should read this book
- Self-taught Python programmers who want to deepen system-level knowledge.
- Engineers preparing for systems-oriented interviews or roles that require understanding interpreters, file formats, or hardware/software interfaces.
- Computer science students who want practical, runnable projects to cement theory.
- Hobbyists interested in emulation, retrocomputing, computational art, or language design.
Practical next steps & resources
- Book: Computer Science from Scratch — projects and sample code available at computersciencefromscratch.com
- Author/contact: David Kopech (website and X handle referenced in show notes).
- Try these immediate exercises:
- Run/modify the BF interpreter and a Tiny BASIC example.
- Convert a modern photo to a dithered MacPaint image.
- Clone the NES emulator from the book and experiment with Cython/Numba to speed it up.
- Additional reading: Classic Computer Science Problems in Python (David’s earlier book) for complementary data-structures/algorithm practice.
For readers who want practical mastery: pick one project from the book, run it, and then try one optimization (e.g., Cython or a native extension) to see the performance trade-offs firsthand.
