Skip to content
Tech News
← Back to articles

Stroustrup's Rule (2024)

read original more articles
Why This Matters

Stroustrup's Rule highlights the evolving preferences in syntax design, where new features are initially expressed explicitly to aid understanding, but become more terse as users gain familiarity. This insight is crucial for language designers and developers to balance clarity and efficiency, especially when onboarding beginners versus catering to experienced programmers. Recognizing this pattern can influence how programming languages evolve and how documentation is tailored for different user levels.

Key Takeaways

Just finished two weeks of workshops and am exhausted, so this one will be light.

Hanuka Sale

Logic for Programmers is on sale until the end of Chanukah! That's Jan 2nd if you're not Jewish. Get it for 40% off here.

Stroustrup's Rule

I first encountered Stroustrup's Rule on this defunct webpage:

One of my favorite insights about syntax design appeared in a retrospective on C++ by Bjarne Stroustrup: For new features, people insist on LOUD explicit syntax.

explicit syntax. For established features, people want terse notation.

The blogger gives the example of option types in Rust. Originally, the idea of using option types to store errors was new for programmers, so the syntax for passing an error was very explicit:

let file = match File :: open ( "file.txt" ) { Ok ( file ) => file , Err ( err ) => { return err ; } }

Once people were more familiar with it, Rust added the try! macro to reduce boilerplate, and finally the ? operator to streamline error handling further.

... continue reading