Another Tour of Scala

UnifiedTypes

The Gist

Unified Types is an overview of Scala’s types and classes at a very high level.

My Interpretation

All Scala values are objects; there is no formal “primitive” type as there is in Java. However, there is a distinction in the main object tree.

Every object is a subtype of Any, however in practice, most objects will be a direct subtype of AnyRef. AnyVal is a superclass for the types that, in Java, are considered “primitive” (that being things like int, byte, and float). Further, all classes implicitly extend scala.ScalaObject (which is a trait) and AnyRef (yes, there is multiple inheritance). Finally, classes you can access from the Java runtime do not extend scala.ScalaObject , but just extend AnyRef.

My Thoughts on this Feature

Thank GOD we don’t need Java’s stupid primitive types any more (even though they are actually still there, since this is the JVM and all). However, I find the concepts of Null, Nothing, and null less than intuitive. Stuff like this just makes me scratch my head. Especially Nil being the empty list. What’s so wrong with EmptyList?