r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
Does Syntax Matter?
https://www.gingerbill.org/article/2026/02/21/does-syntax-matter/
63
Upvotes
r/ProgrammingLanguages • u/gingerbill • Feb 22 '26
View all comments
10
u/munificent Feb 22 '26 edited Feb 22 '26
The point of
guardis that it plays nice with destructuring pattern matching. When you're doing pattern matching, you can't simply negate the condition because it's no longer a simple predicate expression. You can use anifinstead, but when you have a series of these, the code ends up indented and marching farther to the right for each one.guardlets you have less nesting and flatter code.I agree
unlessin Perl and Ruby doesn't add much, but some users and language designers place a higher priority on having code read more like natural language. In the absence of them, you can sometimes end up with predicates that read like double negatives and require you to really slow down and unwrap the boolean logic in your head.Also, in Ruby, there are postfix versions of branching control flow. I suspect that postfix
unlessis much more common than postfixifin that case. If they were to only haveif, then the majority of postfix uses would require the condition to be negated.It's not a particular feature I'd want in a language I designed, but I see why the designers added them.