Pattern Overloading by Ramsey Nasser.
From the post:
C-like languages have a problem of overloaded syntax that I noticed while teaching high school students. Consider the following snippets in such a language:
foo(45)
function foo(int x) {
for(int i=0;i < 10; i++) {
if(x > 10) {
case(x) {A programmer experienced with this family would see
- Function invocation
- Function definition
- Control flow examples
In my experience, new programmers see these constructs as instances of the same idea:
name(some-stuff) more-stuff
. This is not an unreasonable conclusion to reach. The syntax for each construct is shockingly similar given that their semantics are wildly different.
You won’t be called upon to re-design C but Nasser’s advice:
Syntactic similarity should mirror semantic similarity
Or, to take a quote from the UX world
Similar things should look similar and dissimilar things should look dissimilar
is equally applicable to any syntax that you design.