Type systems

I’ve been writing a lot of Ruby lately, and also a lot of Scala. One thing that’s struck me is the difficulty of confidently removing code in Ruby. If your function name or variable is called something unique, grep can do the job just fine, but what if your function is called “get”? In Scala, you can ask IntelliJ to figure out what calls that function, no matter what its name is (barring, of course, unknowable calls such as those conjured by reflection or those in other projects). No such tool exists for Ruby.

Scala also warns me at compile time if I passed the wrong number of arguments to a function, or if I gave a string where I was supposed to give a number. There’s a class of errors which are eliminated by Scala’s static analysis of the structure of a program.

I like it when computers help me not to make mistakes. My poor monkey brain isn’t so good at writing correct code, and if a computer can help me catch a mistake before it causes any damage, I’d like it to do that please. So I’m kinda skeptical about the wisdom of Rich Hickey’s dismissal of the usefulness of types.

Best of luck trying to model the world in type systems, I personally have better things to do with my time.
Rich Hickey

I think Rich is a smart person though, and a seemingly-wrong thing said by a seemingly-smart person is cause for confusion and warrants attention. To what extent is a type system a hindrance, rather than an asset? In extricating oneself from the muck of inheritance hierarchies and mixins, is there such elegance and agility to be found that it’s worth leaving the safety net of a type system behind? Is the class of errors that a type system eliminates really a large one?

I’m starting to learn clojure, in hope of finding out.

Show Comments