r/ProgrammingLanguages • u/[deleted] • Jul 31 '24
Blog post Clean Syntax?
All my replies and the original contents of this OP have been withdrawn. They were a complete waste of time.
From what I can gather, everybody is happy with poor syntax in their languages, nobody is interested in 'clean'.
Someone posted, with a dozen upvotes:
Your example is optimized to your language's special capabilities.
I replied:
"No, pretty much everything in my syntax is cleaner than the C equivalent."
That got multiple downvotes for stating a fact.
There was also this:
For your own toy language by all means use your own syntax
This reinforces my original implication that simple syntax is only suited for toy languages, and not serious ones.
However too much of this was about my language, but that was only an example. There seems to be much irrational distrust of clear syntax for any language.
Maybe, clear code is associated with older languages which no one likes anymore?
(Original examples.)
28
u/sysop073 Jul 31 '24
First, "why isn't a 50 year old language as simple as my language when doing a task I specifically chose to be simple in my language" is not a serious question. But taking it seriously for a moment, your version isn't particularly simpler.
typedefis unnecessary, people just don't like needing to includestructin the type name. You could dostruct R1 {...}and then refer to it asstruct R1and it would be very similar to your version.#pragma packis unnecessary, you can juststruct __attribute__((__packed__)) R1to makeR1packed. This is a little more verbose than$caligned, but that comes from backwards-compatibility in a half-century-old language; I don't think any newer languages use that syntax, even if they stick to C-like grammar.Defaulting to "natural alignment" is a bold decision -- most languages pad struct fields for a reason, not just to "look the business".
I don't see any particular benefit to
R1.bytesoversizeof(R1); if anything it seems less obvious what that means. And havingR1.breturn the offset ofbis really weird -- you rarely need the offset of a particular field, and I would never expect it to be the default thing you get back when asking for that field.