# Ministry of silly loops

**URL:** <https://ziggit.dev/t/ministry-of-silly-loops/11383>\
**Category:** Challenge\
**Tags:** language\
**Created:** [August 9, 2025, 2:10am UTC](https://ziggit.dev/t/ministry-of-silly-loops/11383 "2025-08-09T02:10:39Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![matklad](https://ziggit.dev/user_avatar/ziggit.dev/matklad/32/2462_2.png) [@matklad](https://ziggit.dev/u/matklad)\
**Post date:** [August 9, 2025, 2:15am UTC](https://ziggit.dev/t/ministry-of-silly-loops/11383/4 "2025-08-09T02:15:55Z")

</div>

Stay a while and listen:

```zig
var i: u32 = 0;
while (i < 10) {
    defer i += 1;
    print("{d}\n", .{i})
}

```

Tricked you, this one is a serious loop, not a silly loop!

**I think `while (condition) : (increment)` loops are redundant and should be removed from the language.**

```zig
while (condition) : (increment) {
    body;
}

```

is, as far as I can tell at 3AM, fully equivalent to

```zig
while (condition) {
    defer increment;

    body;
}

```

But the latter is so much more readable! You don’t need to guess semantics of `) : (` and how it interacts with continue and what not. And you know why is that hard to intuit? Because it’s the single violation of “no control flow without keyword” principle! `:` is control flow, and a particularly tricky one! Execution goes from the condition, _past_ the increment, to the loop body, and then back to the increment again.

`while (condition) : (increment)` loops are a bit more concise than while-defer loops, and that was important when a counting for loop was written as a `while`. But, since we have explicit counting `for(0..10)` loops, I’d say, down with the while with increment! Даёшь while defer!

---

_[View the full topic](https://ziggit.dev/t/ministry-of-silly-loops/11383)._
