Now, that’s what I call Static Typing!

Wednesday, December 15, 2021

Just to be clear, this is not a complete history of static typing, nor a complete introduction to the topic. It’s an explanation for why I, a programmer who likes some highly dynamic langauges (Clojure and Python), have been partly persuaded of the merits of static typing.

A complete (or at least, complete-er) history or coomparison would include C++, ML, Haskell, and Scala, but I don’t really have familiarity with those languages.

Pretty Weak C

Now, weak is not well-defined, but I think it’s safe to say C has the weakest typing on this list.

There are definite reasons for C’s type system being the way it is. For one thing, some typing features hadn’t been invented yet, and for another, it was relatively system-focused and low-level1. It’s been called “portable assembler,” although the picture has gotten more complicated since then.

C is a relatively “low level” language. C is a relatively “low level” language. This characterization is not pejorative; it simply means that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be com- bined and moved about with the arithmetic and logical operators implemented by real machines.

Implicit arithmetic conversions work .much as expected.”

Type-Check Once, Run Everywhere: Java #

A Step Higher: C#

C# is in many ways a better Java, and its type system is one such case.

Rust

Some people are tired of pro-Rust posts, so I feel the need to


  1. I wondered about this characterization (am I selling its abstraction capabilities short?), but here’s K&R: