The Language of Types


Jon Udell is talking about types and languages. Having taught undergraduate programming language concept courses and graduate level programming language theory courses, I know that just the terminology can mess a lot of people up. Here's some definitions:

  • Strongly typed: the language checks the types of variables so that things "cannot go wrong" in Milner's words, at least because of type mismatches. This doesn't rule out array bounds overflows and other runtime errors, but it does keep you from assigning a pointer to a character.
  • Weakly typed: in weakly typed languages, types are merely a suggestion--if the programmer wants to do something in contrast to the types, its allowed.
  • Statically typed: whenever you see the word "static" in programming language discussions, it means that it happens at compile time. Statically typed languages produce type errors at compile time.
  • Dynamically typed: The type checking happens at run-time.

So, here's a table with some of my favorite languages thrown in to illustrate this:

StaticDynamic
StrongSML, JavaScheme
WeakCPERL, Forth

Note that "strong" does not mean that all variables have declared types. SML is an example of a strongly typed language that uses type inference so that users can avoid declaring types. Also, keep in mind that classifications like the one above are always rife with exceptions. Even static, strong languages like Java have facilities for dynamic typing in certain cases.

I've always found typing fascinating. If you do as well, you'll enjoy the thinking of Luca Cardelli and Benjamin Pierce to name a few. You might also want to check in the Haskell programming language, which has some very innovative typing.