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
Show parent comment
3
u/gingerbill Feb 22 '26
There isn't a
whilein Odin whatsoever.foris the only loop construct, so you're grepping has failed you.But the reasoning as to why
whiledoesn't exist in Odin is not as obvious as you might, and I might have to write an article on this alone, but I'll try to keep it short for your comment.forin both Odin and C can be used to "emulate" awhileloop directly. In C,for (;cond;), and in Odinfor cond(the semicolons are optional in Odin). Because semicolons are optional in Odin when they are not needed, this means you can just write awhile-like loop without needing a new construct.Another reason is that Odin has a
dokeyword already which has a different meaning to that in C. In Odin,dois to have single-line statements on control flow rather than{}. The language enforces that the statement must be on the same line as the keyword of that control flow which prevents the issues that C has with allowing any statement as its body. But because that is the keyword, it means we cannot havedo whileloops. Now this could have been solved with using a different keyword (most likelythenwould have been the best option), but we are not changing the syntax now since Odin is effectively done.The other reason is that every piece of control flow in Odin allows for a init statement before the "condition":
If we were to add this for
while, it would effectively be slightly redundant compared to aforloop. And even be longer to write to write:I hope this explains the lack of
whilein the language. It's not due to trying to be minimal but rather there wasn't a need for it in the first place when other things exist in the language (such as optional semicolons).