Chapter 20. Blending OOP and FP: Comparing Java and Scala

This chapter covers

  • An introduction to Scala
  • How Java relates to Scala and vice versa
  • How functions in Scala compare to Java
  • Classes and traits

Scala is a programming language that mixes object-oriented and functional programming. It’s often seen as an alternative language to Java for programmers who want functional features in a statically typed programming language that runs on the JVM while keeping a Java feel. Scala introduces many more features than Java: a more-sophisticated type system, type inference, pattern matching (as presented in chapter 19), constructs that define domain-specific languages simply, and so on. In addition, you can access all Java libraries within Scala ...

Get Modern Java in Action now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.