The debate around types often centers on simplicity. But since simplicity is subjective, is this debate just for show, or do we have any empirical evidence to support our assertions? And personally, do I prefer types or no types?

I see types as another form of documentation. When I type a dot in the editor, I get suggestions for what comes next in the code. This is the “killer feature” of types. Static type checking helpfully warns me when I’m about to make a mistake.

Go mostly stays out of the way until needed because it’s statically and strongly typed.

func main() {
	i := 1                                // int
	output := "hello: " + strconv.Itoa(i) // explicit conversion needed due to static typing
	fmt.Println(output)                   // hello: 1
}

Try the same thing in dynamically and strongly typed Ruby/Python, however, and it crashes with no warning:

def main
  i = 1                  # Integer
  output = "hello: " + i # no implicit conversion of Integer into String (TypeError)
  puts output
end

JavaScript, a dynamically and weakly typed language, runs it with no error and no conversion needed:

function main() {
  const i = 1;                   // Number
  const output = "hello: " + i;  // Implicit conversion to string
  console.log(output);           // hello: 1
}

Do I prefer types or no types?

I see it first as a matter of ergonomics. I experience types as a form of IDE-integrated documentation. Most recently I have experienced the type systems of TypeScript and Go. Having types is really useful when data structures get complex (looking at you GraphQL).

Secondly, it’s a kind of safety. As a teenager, I drove my car differently than I do now with my family in the back. I wish there was an objectively correct answer here. Sometimes you just need to pull out all the stops and write some beautiful code with no safety or documentation. Sometimes you want the safety, even if it’s not perfect and adds steps to your workflow. The popularity of JavaScript, PHP, Ruby, Python and the recent development of type systems for these languages seems to me that there is no one size fits all answer.