4 ms·
Yes that is ugly and no complaining about syntax peculiarities is not bike shedding. Code aesthetics is directly related to its readability and to programmers
by stephc_int13 4y ago
Yes that is ugly and no complaining about syntax peculiarities is not bike shedding.
Code aesthetics is directly related to its readability and to programmers quality of life.
Code should be made as simple to read as possible, the writing part is less important.
- MrJohz 4y agoIt seems obvious that bad syntax harms readability, in that it's very easy to construct an example of a programming language that is truly unreadable (use commas to indicate generics, everything must be upper case, backslash to call functions and pipe to separate arguments, the letter `H` is used to start a class declaration, etc - the Intercal of syntaxes). But the reverse seems more difficult to argue: that there is some ideal syntax that is objectively more reasonable than all other syntaxes. I have preferences (do/end blocks feel like unnecessary noise, I like my types to be written inline in my functions, angle brackets feel right for generics), and some of them even have a veneer of logic behind them (significant indentation is a nuisance when I want to paste a block of code that has the wrong indentation). But clearly other people have different preferences, because they keep on designing languages that don't fit my ideal aesthetics. The other side of this is that the more I write different languages, the less important syntax becomes. The places where I appreciate the syntax of a particular language are usually because the syntax fits particularly well with the language's semantics, rather than because the syntax itself is good or bad. Partial application in ML-family languages is syntactically very neat, but I don't feel the need to remove parentheses from Javascript because of it. What I really like is partial application, and using space as the function application operator works well with those semantics.
- stephc_int13 4y agoI think that many recent or a bit less recent languages uses too many symbols instead of words. Words are less ambiguous and cleaner.
- MrJohz 4y agoI mean, sure. I disagree, but I can see what you mean. But that's not an argument for one being better than the other, it's an argument of preference. You happen to like words over symbols. In my experience, when I actually start getting to grips with a new language, the syntax very quickly becomes one of the least interesting things about it.
- rascul 4y ago> it's very easy to construct an example of a programming language that is truly unreadable I submit for your consideration Brainfuck and Whitespace. There are others but these two came to mind first. https://en.wikipedia.org/wiki/Brainfuck https://en.wikipedia.org/wiki/Brainfuck https://en.wikipedia.org/wiki/Whitespace_(programming_language) https://en.wikipedia.org/wiki/Whitespace_(programming_langua...
- pornel 4y ago"Make it simple" is easy to throw around, but it's almost meaningless. Perception of simplicity and readability is incredibly subjective and dependent on previous experience. Beyond that it also depends on what goals the language has, because "simple" from one point of view can be oversimplified and unclear from another POV. Rust is a systems programming language concerned with several low-level details. Programmers aren't reading Rust code for entertainment, but need to be aware of things like ownership, mutability, lifetimes, trait bounds, dynamic dispatch, and so on. Beyond being eye-pleasing, Rust also needs to be locally explicit to communicate costs, limitations, and unsafety of the code. As the article shows, beyond just bikeshedding which ASCII sequence you use for what, the aren't many ways to simplify the syntax that don't involve hiding information or changing language semantics that could worsen performance or create unpredictability.
- stephc_int13 4y agoSimplicity is partially in the eye of the beholder, I agree. And there is always a subjective part about any design decisions, but overall there are better designs and worse designs. And concerning programming language syntax, I tend to prefer a bit of verbosity over any terseness / compactness. I prefer Java/C# style over Perl/Sed. And I think that modern system programming languages tend to drift a bit too much towards the Perl style. Writing powerful but unreadable on-liners should be considered harmful.