Object-Functional and Beyond

Object-oriented and functional programming were once seen as rivals. Objects hide changing state behind methods, and functions avoid state altogether. A newer generation of languages combines them on purpose, and a few research languages go further and mix even more models.

What Defines the Family

  • Objects and functions are equals. You can model a domain with classes or interfaces and transform its data with lambdas and pipelines, in the same file.
  • Immutability is easy. A short keyword (val, let) declares a fixed value, and data classes or records make immutable structures cheap to write.
  • Algebraic data types and pattern matching. A sealed hierarchy or an enum lists every case, and the compiler checks that each one is handled.
  • Null handled by the type system. A value that can be missing has a different type (T?, Option), so forgetting to check is a compile error.
  • Type inference. You write few annotations, so the code stays short even though it is statically typed.

Representative Languages

LanguageWhy study it
ScalaObjects and functions unified on the JVM, with case classes, traits, and a powerful type system.
KotlinA pragmatic, concise blend with null safety and coroutines, and full Java interoperability.
SwiftValue types and protocol-oriented design, with optionals and closures, for Apple platforms and beyond.
F#Functional first on .NET, with units of measure and object support when you need it.
Oz (Mozart)A research language that puts functional, object, logic, constraint and concurrent models in one kernel.

How They Compare

LanguagePlatformLeans towardSignature feature
ScalaJVM, JavaScript, nativeBoth equallyTraits, case classes, givens
KotlinJVM, Android, JavaScript, nativeObjects, with functional toolsNull safety, coroutines
SwiftApple platforms, Linux, WindowsObjects and protocols, with functional toolsValue types, optionals
F#.NETFunctional firstUnits of measure, pipelines
OzMozart virtual machineAll modelsDataflow variables, one kernel

Beyond Object-Functional

Object-functional languages combine two paradigms that already share a lot: both are about organising data and behaviour. Oz is different. It was designed to show how many paradigms (functional, object-oriented, logic, constraint, concurrent) can grow out of one small kernel language. That makes it less practical for production, but excellent for seeing how the models relate to each other.

Trade-offs

  • Many ways to do one thing. A language that supports both styles lets teams write very different code, so conventions matter.
  • Learning both worlds. You need to understand classes and also immutability, higher-order functions and type inference.
  • Performance. Most of these languages use a garbage collector or reference counting, which gives less control than the systems family.

Go back to Popular Hybrid Languages or the PGP roadmap.