💾 Archived View for yujiri.xyz › software › braceless-body.gmi captured on 2024-03-21 at 15:31:54. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-09-08)

➡️ Next capture (2024-08-18)

-=-=-=-=-=-=-

yujiri.xyz

Software

Braceless body in semicolon languages is bad design

In C, Javascript, and Zig, conditions of `if` and `while` statements always have to be wrapped in parentheses, while in Rust and Go, they don't. It's because in C, Javascript and Zig, the *body* of such a statement *doesn't* have to be wrapped in braces, if it's only one line, and there has to be a way for the parser to tell the separation between condition and body. In these languages the syntax is: `if (condition) body`, while in Rust and Go the syntax is `if condition { body }`.

What Rust and Go do here is better, for two reasons: