To understand the significance of specialization, it is important to first grasp the concept of object boxing. The JVM defines primitive types (
double) that are stack-allocated rather than heap-allocated. When a generic type is introduced, for example,
scala.collection.immutable.List, the JVM references an object equivalent, instead of a primitive type. In this example, an instantiated list of integers would be heap-allocated objects rather than integer primitives. The process of converting a primitive to its object equivalent is called boxing, and the reverse process is called unboxing. Boxing is a relevant concern for performance-sensitive programming because boxing involves heap ...