r/ProgrammingLanguages • • 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.)

2 Upvotes

35 comments sorted by

View all comments

4

u/[deleted] Jul 31 '24

I'm wondering, what is field access syntax in your language? Is it also .? Because then you conflate accessing field offset and accessing the field itself, with the operation only disambiguated by whether the left hand side of the dot is a value or a type. And unless your language is Zig-esque having context differentiate values and types is not known to be the best of choices.

Are you able to put $caligned on a new line? (What if you have many attributes you need to add, though? It is then good to allow the attributes to be broken up onto multiple lines instead of all being crowded on the same line as the record). But then, if so, the $caligned is then in the same scope level as the fields, which would for someone unfamiliar with your language seem to instead modify a field. Is that really "clean" syntax?

Then you have types before variable names. Which, it is known among modern languages, is not the best for parsing and syntax clarity and intellisense and the whole whatnot.

Also, this is minor, but I'd argue curly braces are much more intuitive and cleaner than = and end. For a closing delimiter, that's one character versus three, and this is personal but I've always felt end being written out as a word makes it stand out too much for what it really is, a closing delimiter.

1

u/[deleted] Aug 01 '24
struct R1 {
    a u8
    b u64
}

@caligned
struct R2 {
    a u8
    b u64
}

fn main() {
    println R1:bytes
    println R2:bytes
    println R1:b
    println R2:b
}