I need to use a type (any type) as a marker in an implicit as a type parameter, to distinguish it from another implicit. It's weird, but this may be another question.
Since I can use any type, I was thinking of using the cheapest one, in terms of memory footprint and initialization time. It may not affect performance too much in this case, but the question is interesting: Which one is Scala's cheapest type?
In Java, the answer is obviously java.lang.Object
. But Scala has a few "interesting" types: Any
, AnyVal
types, and bottom types with possible optimizations around them. The Nothing
type cannot be instantiated, so it is excluded from this comparison.