sobota, 15 września 2012

What is a type?

There's a nice and humorous metaphor in Luca Cardelli's "On Understanding Types, Data Abstraction, and Polymorphism" paper about how we can view types in programming languages which I really like and wanted to share:
A type may be viewed as a set of clothes (or a suit of armor) that protects an underlying untyped representation from arbitrary or unintended use. It provides a protective covering that hides the underlying representation and constrains the way objects may interact with other objects. In an untyped system untyped objects are naked in that the underlying representation is exposed for all to see. Violating the type system involves removing the protective set of clothing and operating directly on the naked representation.
You can download freely the paper from author's site, and please take care of your objects, buy them a warm sweater during winter, don't rip their clothes off too often! Have a nice read ;)