this post was submitted on 17 Dec 2025
474 points (96.1% liked)

Programmer Humor

27937 readers
531 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] fruitcantfly@programming.dev 4 points 1 day ago

Loop labels are rare, but they lead to much simpler/clearer code when you need them. Consider how you would implement this kind of loop in a language without loop variables:

'outer: while (...) {
    'inner: while (...) {
        if (...) {
            // this breaks out of the outer loop, not just the inner loop
            break 'outer;
        }
    }

    // some code here
}

In C/C++ you'd need to do something like

bool condition = false;
while (...) {
    while (...) {
        if (...) {
            condition = true;
            break;
        }
    }
    if (condition) {
        break;
    }

    // some code here
}

Personally, I wouldn't call it ugly, either, but that's mostly a matter of taste