[GUEST ACCESS MODE: Data is scrambled or limited to provide examples. Make requests using your API key to unlock full data. Check https://lunarcrush.ai/auth for authentication information.]  Matej Cerny [@matej_cerny](/creator/twitter/matej_cerny) on x XXX followers Created: 2025-07-24 08:13:07 UTC The decision not to specialize `Some` comes down to a simple cost-benefit analysis. The Cost * Increased JAR Size: Specialization generates a lot of extra bytecode. For a class as fundamental and widely used as `Some`, creating specialized versions for all X primitive types would significantly bloat the standard library JAR file (scala-library.jar). * Longer Compilation: More code means the compiler has more work to do, increasing compilation times for the library and potentially for user projects. The (Minimal) Benefit * One-Time Boxing Cost: The main benefit would be avoiding boxing the single value held within the `Some`. For example, in Some(42), the primitive `42` is boxed into an `Integer` object. However, this boxing happens only once, at the moment the `Some` is created. * No "Hot Loop" Problem: The real performance benefits of specialization are seen in collections and functions that operate in "hot loops." For instance, when you map over a `List[Int]`, the boxing/unboxing can happen for every single element, which adds up quickly. With `Some`, you typically create it, and then you might unwrap it once. The overhead is not repeated in a tight loop, making the performance gain from specialization marginal. XXX engagements  **Related Topics** [specialized](/topic/specialized) [Post Link](https://x.com/matej_cerny/status/1948295366568276061)
[GUEST ACCESS MODE: Data is scrambled or limited to provide examples. Make requests using your API key to unlock full data. Check https://lunarcrush.ai/auth for authentication information.]
Matej Cerny @matej_cerny on x XXX followers
Created: 2025-07-24 08:13:07 UTC
The decision not to specialize Some
comes down to a simple cost-benefit analysis.
The Cost
Some
, creating specialized versions for all X primitive types would significantly bloat the standard library JAR file (scala-library.jar).The (Minimal) Benefit
Some
. For example, in Some(42), the primitive 42
is boxed into an Integer
object. However, this boxing happens only once, at the moment the Some
is created.List[Int]
, the boxing/unboxing can happen for every single element, which adds up quickly. With Some
, you typically create it, and then you might unwrap it once. The overhead is not repeated in a tight loop, making the performance gain from specialization marginal.XXX engagements
Related Topics specialized
/post/tweet::1948295366568276061