[Avg. reading time: 4 minutes]
Programming Paradigms
Procedural
- Code as step by step instructions
- Functions + state + control flow
- Easy to learn, hard to scale
- Examples: C, early Pascal
Object Oriented
- Code organized around objects and state
- Encapsulation, inheritance, polymorphism
- Examples: Java, C++, C#
Functional
- Computation as function evaluation
- Immutability, pure functions, no side effects
- Scales well, forces discipline
- Examples: Haskell, Elixir, F#, functional Rust
Declarative
- You describe what you want, not how
- Execution strategy is hidden
- Powerful but abstract
- Examples: SQL, HTML, Terraform
Rust is multi-paradigm. It supports multiple styles. Rust borrows proven ideas from multiple paradigms. It rejects bad ideas, even if they are popular.
Popular concepts Borrowed by Rust
From procedural
- Explicit control flow
- Predictable execution
From functional
- Immutability by default
- Pattern matching
- Algebraic data types
From systems programming
- Zero-cost abstractions (high level code is compiled as fast as machine code)
- No garbage collector
- Deterministic performance
From concurrency models
- Message passing
- Compile-time safety
Popular concepts rejected by Rust
- Inheritance hides complexity
- it hides behavior and creates fragile, tightly coupled hierarchies
- Nulls hide absence
- absence causes runtime failures instead of compile-time checks.
- Shared mutation hides bugs
- it makes concurrency unpredictable and correctness unverifiable.