dynamic typing
A language design where a variable can hold a value of any type and types are only checked while the program runs.
In more detail
Types belong to values rather than to variable names, so the same variable can hold a number now and a string later, and you never declare its type. Mixing incompatible types shows up as an error only when the bad line executes. JavaScript and Python are dynamically typed, while statically typed languages such as Java and Go check types before the program runs.
Example
Because JavaScript is dynamically typed, V8 watches which types really occur and optimises for those.Related terms
- JavaScript — The programming language of web browsers, also widely used on servers through Node.js.
- speculative optimization — Compiling code on the bet that values will keep the types seen so far, with checks that fall back to slower code if the bet fails.
- deoptimization — When a just-in-time compiler throws away optimised machine code because the assumptions it was built on no longer hold, and falls back to slower code.
- data type — The kind of a value, such as a whole number, text or a date, which decides what you can do with it and how it compares and sorts.
- type hint — A note in a function heading or variable declaration saying what type a value should be, such as def total(prices: list[float]) -> float:.
- TypeError — The exception raised when an operation or function gets a value of the wrong type, such as adding a number to a string.
- static type system — Rules a compiler uses to check, before the program runs, that every value is used in a way its type allows.
- run time — The moment when a program is actually executing, as opposed to when it is written, compiled or built.
Taught in
- V8 Engine & JIT Pipeline: Bytecode & Turbofan — Node.js Internals & Backend Services
- What Python Is, And Where It Came From — Hands-on Python: Complete Video Course & Book
- Why TypeScript: Contracts, Erased Types And Soundness — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript