this post was submitted on 24 Feb 2026
619 points (97.7% liked)

Programmer Humor

30112 readers
442 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
[–] 404@lemmy.zip 9 points 5 days ago* (last edited 5 days ago)

For programming languages that make use of {}, the reason is (almost always) scope.

Take for instance this:

for i in 0..10
do_thing();
do_other_thing();

compared to this:

for i in 0..10 {
    do_thing();
}
do_other_thing();

The intent of the first one is unclear. In the second one it's clear you should loop do_thing() and then run do_other_thing() afterwards. The indentation is only for readability in the above though. Logically there would be no difference in writing

for i in 0..10 { do_thing(); } do_other_thing();

Languages that use indentation and line breaks for scope look more similar to this:

for i in 0..10:
    do_thing()
do_other_thing()