Programming Language Theory
Multi-paradigm Languages
The OOP vs FP debate is a relic. The most popular languages of the last decade (Kotlin, Rust, Swift, TypeScript) are all multi-paradigm. The question is not 'which paradigm to use' but 'when to use which'.
- **JetBrains Kotlin**: full Java compatibility plus FP features. Over 60% of Android developers switched from Java in four years
- **Mozilla Rust**: the ownership paradigm eliminates whole classes of vulnerabilities. Google has said 70% of Android CVEs would disappear with a move to Rust
- **Twitter Scala**: the migration from Ruby to Scala produced a 10x throughput gain and strict typing for a 2000+ engineering team
Scala: OOP + FP
Scala proved that OOP and FP can coexist in one language. Every value is an object, every function is a value. Traits replace both interfaces and mixins. Pattern matching plus case classes make algebraic data types first-class.
Spark (2M+ users), Kafka, and Akka are written in Scala. Twitter migrated from Ruby to Scala for performance and type safety.
Why is a sealed trait in Scala better than an ordinary abstract class for modeling algebraic data types?
Kotlin: pragmatic multi-paradigm
Kotlin chose pragmatism over theoretical purity. Full Java compatibility, coroutines for async, extension functions to add methods without inheritance, null safety through the type system.
How does Kotlin solve the NPE problem at the type-system level?
Rust: ownership as a paradigm
Rust introduces a new paradigm: ownership and borrow checking. It is neither OOP nor pure FP. Memory safety without a GC, zero-cost abstractions, trait-based polymorphism instead of vtables by default.
Rust has been the most loved language in the StackOverflow Developer Survey 9 years in a row (2015 to 2024). Linux kernel, Android, Windows kernel, Chrome: all are adopting Rust code.
What is monomorphization in Rust, and why is it zero-cost?
Language Evolution
Languages evolve. Java added lambdas (Java 8), records, sealed classes, and pattern matching. Python added types (PEP 484). C++ has grown to look like Rust with modern C++. Languages borrow the best ideas from other paradigms.
The trend: languages are moving toward safety by default. Rust borrow checker, Swift optionals, Kotlin null safety, TypeScript strict mode. All solve the same class of problems. The next-generation language will probably combine formal verification with everyday productivity.
Multi-paradigm languages are a compromise: neither good OOP nor good FP
The best multi-paradigm languages take the strong points of each paradigm and apply them where they fit
Scala Spark uses FP for data transformations and OOP for configuration. Rust uses ownership for safety and traits for abstraction. The power is in choosing the right tool
Why did Java 21 add sealed classes and pattern matching, despite Java being an OOP language?
Key Ideas
- **Scala**: sealed trait + case class = algebraic types with exhaustive pattern matching. Traits = mixins without the diamond problem
- **Kotlin**: pragmatism over purity. Null safety in types, extension functions without inheritance, coroutines as first-class concurrency
- **Rust**: ownership is the third paradigm after OOP and FP. Monomorphization gives zero-cost generics without a vtable
- **Evolution**: Java 21, Python, and C++ are borrowing FP concepts. Languages are converging on safety by default
Related Topics
Multi-paradigm design intersects with other concepts:
- Functional programming — The FP concepts that get integrated into multi-paradigm languages
- OOP theory — The OOP concepts that multi-paradigm languages rethink
Вопросы для размышления
- Rust has no classes, but it has traits and impl. Is Rust object-oriented? What does the answer say about the definition of OOP?
- Kotlin and Scala both run on the JVM and are both multi-paradigm, yet Kotlin chose pragmatism and Scala chose theoretical completeness. Which approach is better for industrial development?
- If languages borrow the best from every paradigm, why bother studying pure paradigms (Haskell, Prolog, Smalltalk) at all?