This repository contains the source code used in the book Functional and Concurrent Programming: Core Concepts and Features, published by Addison-Wesley Professional. It is laid out as follows:
-
Scala
contains all the Scala code used in the book. Illustrations are organized by chapter and section. Code snippets that are not standalone classes or functions are implemented as demos. Demos sometimes rely on arguments for data that is not mentioned in the book. Data that the book references but does not provide explicitly are implemented in terms of mock objects, often using unrealistic code. Some unit tests are written using Scalatest. Note that mock objects and unit tests tend to use dirty, uncommented code that is fairly unreadable. You are advised to stay away from them. -
Java
contains almost all the Java code used in the book (seeMoreJava
for exceptions). This code is used in a jointsbt
project withScala
code and depends on mock objects written in Scala. -
MoreJava
contains additional Java code that is not part of thesbt
project:- Code from Chapter 14 that uses Java records. Due to a bug, Java records are not currently supported in Scala 3 (scala/scala3#14846).
- Code from the appendix that uses features only available as a preview in Java 19.
-
Kotlin
contains all the Kotlin code. It is setup as agradle
project, independent from the mainsbt
project. -
Python
contains (very little) Python code, with no particular setup. -
JavaScript
contains (very little) JavaScript code, with no particular setup. -
Bash
contains (very little) Bash script code, with no particular setup.
The Scala
and Java
source repositories are setup as a single sbt
project, which should make it easy to load and compile the code using sbt
or any IDE that is sbt
aware, like JetBrains' IntelliJ
.
The project specifies the following dependencies:
tiny-scala-utils
: This is my own library, used mostly to implement tests and mock objects, though it also occasionally appear in the main code (e.g., to display time and thread information in demos).scala-parallel-collections
: A semi-standard Scala library that implements collections with parallel processing (see section 21.4).dotty-cps-async
: An experimental "async/await" implementation in Scala (see section 27.4).akka-actor-typed
: The Akka actors framework (see section 27.5).slf4j-simple
: The logging framework used by Akka.reactor-core
: The Reactor project, a popular Java implementation of reactive streams (see section 27.6).
The last four dependencies are used only in Chapter 27.