Why Microsoft programmers prefixed their variables with cryptic codes like lAccountNum and szName

Why Microsoft programmers prefixed their variables with cryptic codes like lAccountNum and szName
Image: Intellect (generated)

In short: Hungarian notation is a naming convention where variable names start with lowercase mnemonics indicating their purpose or data type. Invented by Charles Simonyi at Xerox PARC, the system was designed to help programmers track information in languages that lacked robust type systems, eventually becoming a hallmark of Windows development.

Hungarian notation originated with Charles Simonyi, a programmer at Xerox PARC between 1972 and 1981. The name is a nod to Simonyi’s Hungarian heritage, where family names precede given names, mirroring how the notation places type indicators before a variable's name. According to Andy Hertzfeld, the convention also made code appear as if it were written in an inscrutable foreign language.

The system split into two distinct dialects at Microsoft. 'Apps Hungarian,' used by the applications division, focused on the semantic purpose of a variable—such as marking a string as 'unsafe' (usName) to signal it requires sanitization. Conversely, 'Systems Hungarian,' adopted by the Windows division, encoded the physical data type, such as 'l' for a long integer or 'arru8' for an array of unsigned 8-bit integers.

While the notation is language-independent, it found its most significant application in C, particularly within the Windows API. Because C’s type system could not always distinguish between different data structures, such as a pointer to a single character versus a null-terminated string, these prefixes provided necessary clarity. The practice was famously popularized by Charles Petzold’s book, Programming Windows.

Unlike language-enforced sigils—where symbols like $ or % dictate how a compiler interprets a variable—Hungarian notation is purely a naming convention. It has no effect on machine execution. While some modern developers view the prefixes as redundant, the system remains a historical testament to the challenges of managing complex codebases in the early days of personal computing.

Opens the Intellect+ feed with this card first. Swipe up for the next one.

Sources

To cite this card, link to https://intellectplus.co.uk/app/technology-hungarian-notation.

How we source, check and correct cards: Editorial standards.

General information, not professional advice. Spotted an error? Flag the card or see corrections and complaints.

Intellect Plus is a visual educational discovery platform for exploring fascinating facts and ideas. Brain Food, Not Brain Rot. What is Intellect Plus?

Related

Finding something worth knowing…