C Casting

dead-metaphor ManufacturingType System

Categories: computer-science

What It Brings

To “cast” a value is to pour it into a new mold. The metaphor comes from metalwork and foundry practice: molten metal is poured into a shaped mold (a cast), and when it solidifies, it takes the shape of the mold. In C, casting converts a value from one type to another — an integer becomes a float, a void pointer becomes a char pointer, a wider type is forced into a narrower one. The manufacturing metaphor frames type conversion as a process of reshaping: the raw material (the value) is forced into a new form (the target type) by the constraint of the mold.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The term “cast” for type conversion appears in early programming language literature, likely entering through Fortran and its contemporaries in the 1950s and 1960s. The metallurgical metaphor was a natural fit for the computing culture of the era: many early programmers had engineering backgrounds and would have recognized the foundry reference immediately. By the time C formalized the cast operator in the early 1970s, the term was already established in programming vocabulary.

C’s cast syntax — placing the target type in parentheses before the expression — was Ritchie’s design. It is terse, powerful, and dangerous: a C cast can convert between any scalar types and between any pointer types, with no runtime checking. This permissiveness reflects C’s philosophy of trusting the programmer, but it also means that the “mold” in C has no safety rails. Bjarne Stroustrup’s decision to split C’s single cast into four named operators in C++ was an explicit acknowledgment that the original metaphor was doing too much work. Each C++ cast names a specific kind of conversion, replacing one overloaded metaphor with four specific ones.

References