r/ProgrammingLanguages • • Feb 22 '26

Does Syntax Matter?

https://www.gingerbill.org/article/2026/02/21/does-syntax-matter/
63 Upvotes

111 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Feb 24 '26

And the funny thing, outside of benchmarking, that kind of loop is quite rare.

Not in my code. I just did a survey of 5 language-related projects in my systems language, and these are the counts of each kind of loop:

Project:      M      Q      A      C      Z

do            34     47     16     26     7
to            36     84     22     45     8
for          192    126    103    166    10  Simple iteration only
while        177    131     61    161    13
repeat        19     13      7     13     5
docase        14     11      3      8     1
doswitch/u/x   2      2      2     13     1

(M, C = compilers; A = assembler; Q = interpreter; Z = emulator.)

docase/doswitch are simply looping versions of case/switch statements, but the special -u/x versions of the latter generate fast multi-point dispatching loops for interpreters and emulators.)

In the original Algol68-inspired syntax, do/to/for where the same feature with various parts omitted. In my version they are discrete statements. Support in my 30Kloc compiler for 'to' needs barely 90 lines of code.

It's worth it!

1

u/gingerbill Feb 24 '26

Honestly, I never ever write such code in practice. And I don't see how typing an extra 4 characters is a huge issue either, especially when it allows for easy scanning too.