this post was submitted on 04 Apr 2024
370 points (96.0% liked)
Programmer Humor
32361 readers
388 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I don't work on any widely-used languages (I've made my own but not anything important) but I do think the designers of Zig and Rust have very good reasons for using semicolons โ I read some reasons from the Rust devs themselves somewhere but I can't remember them other than it vaguely being about how Rust is expression-based and intended to be lightweight and how whitespace significance can create confusion around how to read and write certain things and bla bla bla...
but my personal opinion, what I generally I would imagine it's for other than readability, is because the code can look a lot cleaner when an expression returned from a block is just the expression, and not expression plus some token like
return
. It's especially nice in long closures or extremely short and simple blocks. I would rather consistently have to write expressions broadly likelet a = { b + c };
rather thanlet a = { return b + c }
. The semicolon has significance as a "result discarder" so expressions can be the default, so it's on the surface a lot more functional-friendly.Also this is more specific but I hate the way WS languages generally handle quotes