Stefan Tilkov's Random Stuff

Steve Yegge on Static Typing

Steve Yegge:

[W]e also know that static types are just metadata. They’re a specialized kind of comment targeted at two kinds of readers: programmers and compilers. Static types tell a story about the computation, presumably to help both reader groups understand the intent of the program. But the static types can be thrown away at runtime, because in the end they’re just stylized comments. They’re like pedigree paperwork: it might make a certain insecure personality type happier about their dog, but the dog certainly doesn’t care.

Long, but well worth the time, as usual.

Comments

On February 18, 2008 4:44 AM, Robert Fischer said:

But the static types can be thrown away at runtime, because in the end they’re just stylized comments.

This betrays a deep and grave misunderstanding about contemporary languages. In particular, the wide prevalence of run-time optimizations (most notably, the JVM’s HotSpot runtime) means that the type information can’t be thrown away at that point, because there are additional compilation requirements coming out of the way run time is done.