I'm reading a book about the programming language Scala ("Functional Programming in Scala" by Paul Chiusano and Rúnar Bjarnason). They introduce the concept of an algebraic data type (ADT), which is a kind of data type used in functional programming languages, defined as being composed of other types. For example, a Tree ADT (representing the equivalently named data structure) can be defined as made of two separate types: Branch and Leaf, where a Branch has one or more children, while a Leaf has none. Clearly, any Tree can be defined in this fashion.
Now, the authors note the following:
We say that the data type is the sum or union of its data constructors, and each data constructor is the product of its arguments, hence the name algebraic data type.
This sentence has a footnote attached, which is the root of my question:
The naming is not coincidental. There's a deep connection, beyond the scope of this book, between the "addition" and "multiplication" of types to form an ADT and addition and multiplication of numbers.
My question is, what are they referring to? What is this relationship? What is the field of mathematics that studies this relationship, and where can I learn more about it?
Type systems can be taken to have semantics given by certain categories (categorical semantics), and in these semantics product types correspond to the categorical product $\times$ and sum types correspond to the categorical coproduct $\sqcup$.
The relationship between these things and the usual product and sum is that if the category is chosen to be the category $\text{FinSet}$ of finite sets, then the categorical product is the cartesian product and the categorical coproduct is the disjoint union. In paticular, writing $|X|$ for the cardinality of a finite set $X$, we have
$$|X \times Y| = |X| \times |Y|$$
and
$$|X \sqcup Y| = |X| + |Y|.$$
In the categorical semantics the recursive construction of algebraic data types such as
Treeis formalized using the notion of an initial algebra for an endofunctor.