logoalt Hacker News

Stroustrup's Rule (2024)

57 pointsby bmacholast Saturday at 9:01 PM9 commentsview on HN

Comments

MarkusQyesterday at 10:09 PM

There's a missing dimension: orthogonality. Having terse notation that implements a feature that you can reason about in isolation is fine for both beginners and experts. But features that have complex interactions with their environment are hard to reason about regardless of the syntax (though bad syntactic choices can certainly make it worse).

You can introduce a notation that's terse without problem, so long as it's comprehensible when encoutered. Example: the (!·!) operator (which I just made up), which can be placed around any expression to log the value of the expression to STDOUT. Its value is the same as the expression (so `(!3+7!)` equals `10`).

quietbritishjimyesterday at 10:41 PM

I would modify Stroustrup's rule like so:

* For new features, people insist on LOUD explicit syntax.

* For established features [that turned out to be used disproportionately often], people want terse notation.

So, I argue, it's not really people getting used to the feature that allows it to be terser. It's that enough time passes that you figure out what features are used enough that they warrant the terse syntax (like the Rust example he gave).

It's a form of selection bias: there are many other established features that are rarely used and left with a verbose syntax but you don't notice them later because, well, they're rarely used.

alok-gyesterday at 11:22 PM

Something similar for human languages:

"The principle of least effort is another possible explanation: Zipf himself proposed that neither speakers nor hearers using a given language want to work any harder than necessary to reach understanding, and the process that results in approximately equal distribution of effort leads to the observed Zipf distribution.[5][31]" -- From: https://en.wikipedia.org/wiki/Zipf%27s_law

"Explicit syntax" would initially be less cognitive effort. Soon that effort would be gone and "terse notation" would lead to lesser typing effort.

Jtsummersyesterday at 10:32 PM

The discussion for the (linked by Hillel) defunct web page when it was submitted a decade ago here:

https://news.ycombinator.com/item?id=13192052 - 16 December 2016, 73 comments

aidenn0yesterday at 11:28 PM

One corollary:

Your students will be mad right away if you teach them the terse syntax, but mad later if you teach them the verbose syntax.

show 1 reply
sakexyesterday at 11:59 PM

Another thing in that vein is features that were built because the previous approach was obtuse. For instance, find it harder to explain async/await in JS to people who never experienced callback hell, or why there is a borrow checker in Rust to people who never tried C++.

fsckboyyesterday at 10:54 PM

But that's not a rule, it should be Stroustrop's Observation:

For new features, people insist on LOUD explicit syntax.

For established features, people want terse notation.

show 1 reply