▶  Watch

Static vs Dynamic Typing: Proofread Now, or Find the Typos Live?

When are a program's types checked — before it runs, or while it runs? Static typing catches mismatches at compile time; dynamic typing only discovers them when that exact line executes. The difference is when you pay for the mistake, not whether you pay.

Programming Languages CS Fundamentals
What this teaches

Static typing (Java, Rust, Go, TypeScript) checks types before the program runs, rejecting mismatches up front at the cost of more ceremony. Dynamic typing (Python, JS, Ruby) lets a variable hold anything and only fails when a mismatched line actually executes — quicker to write, but bugs can hide until production. Gradual typing (TypeScript, Python + mypy) bolts static checks onto a dynamic language.

Transcript

Your code has a bug — you passed text where it expected a number. Does the computer catch it before the program runs, or only when a user hits that line? That's static versus dynamic typing. Really one question: proofread the whole thing before you print, or find typos as readers hit them?

Static typing checks every type BEFORE your code runs. The compiler reads the whole program and rejects it if the types don't line up. So a whole class of bugs dies on your screen, never in production — and the compiler's knowledge powers razor-sharp autocomplete and refactors you can trust. Java, Rust, Go, TypeScript.

Dynamic typing checks types at RUNTIME. A variable holds anything, and a mismatch only exists once the exact line that trips over it actually runs. So it might crash on the first run — or ship silently and blow up in front of a customer weeks later. Quick to write; the safety's on you. Python, JS, Ruby.

Neither is better — they're opposite bets on WHEN you pay. Static pays now, in ceremony; dynamic pays later, in surprises. One front-loads safety, the other front-loads speed — and the right bet depends entirely on how long your code has to live.

That's why the line is blurring. TypeScript adds compile-time checks over JavaScript; Python's type hints let tools like mypy check your code. Write loose, then add types where safety matters most. You don't have to pick one forever.

So match it to what you're building. A big, long-lived system? Lean static — catch bugs at compile time. A quick script? Dynamic's speed wins. It comes down to one question: proofread before you print, or fix the typos live?

← All videos · Vibe Engines · 2026