Syntax salts and language design


Continuing the discussion from C++ has vector(n, value). c has calloc(). rust has, uh,:

That’s because syntax salts aren’t design motivation, they are ways you achieve a design. They are tools rather than a goal. Even if the given case of lack of vec_from_elem! gets up added in the language, the motivation won’t be - syntax salt, it will be popular demand for feature X. Syntax salt/sugar is just an aspect of how its designed.

Syntax salts are part of the language UX. I consider them the programming language analogue of anti-affordances - things that restrict your choices and funnel you to a correct path, like for example a fake rubber pole to prevents cars/cyclists.

Consider the following case, how many people read the manual for their phone/microwave? And when do they read it? In product design if you have to get out the manual to understand how your clock works, you’re making a really poor clock.

Likewise, relying only on manuals or lectures to teach a language is IMO a similarly poor way to achieve such goal. From my experience, I tend to look at few starting examples and then start mutating the code, attempting to learn it, once I’ve hit every possible wall of what’s possible in a compiler. I look at manual only when things go south or I want to perfect knowledge of the part of the language.