Lingo, lingo, lingo

Some time ago I tweeted about the importance of learning the lingo and the difference it can make when trying to learn something new. Up until that point I hadn’t been very bothered with learning the exact right word for things. My reasoning was something along the lines of: “as long as it’s sort of correct that’s enough, people will get the gist of what I’m saying”.

Even if that’s true, what I didn’t understand was the negative impact on my learning it would have to not learn the right (specific) terms for things. One day I was reading up on general Haskell stuff and came across this sentence:

Haskell’s algebraic data types are sum types of product types.

Algebraic data types in Scala (my main language) are usually encoded by subclassing (see example below).

sealed trait Pokemon
case class Pikachu(color: Color, level: Int) extends Pokemon
case class Charmander(color: Color, level: Int) extends Pokemon
case class Bulbasaur(color: Color, level: Int) extends Pokemon

val pika: Pokemon = Pikachu(Yellow, 1)

And because I had recently made a point of memorizing what sum and product types are in Haskell, this sentence actually made _complete sense_.

Product type: combine two types with “and”. I.e. the different pokemons all have a color and a level.

data Pikachu = Pikachu Color Level
data Charmander = Charmander Color Level
data Bulbasaur = Bulbasaur Color Level

Sum type: combine two types with “or”. I.e. a pokemon is either a Pikachu, Charmander or Bulbasaur in this case.

data Pokemon
  = Pikachu Color Level
  | Charmander Color Level
  | Bulbasaur Color Level

And with that came the realization that unless I make sure I actually learn the specific terms for things, reading Haskell documentation/tutorials/guides etc will take so much longer. So there you have it folks, it’s really worth the effort, I promise!