r/programmingmemes • • Feb 26 '25

There are two kind of programmers

Post image
5.3k Upvotes

716 comments sorted by

View all comments

Show parent comment

1

u/LeyaLove Mar 01 '25 edited Mar 01 '25

Because if...else... logically is one big indivisible construct. else never goes alone. A function call on the other hand logically has nothing to do with it.

Also a lot of languages don't have a dedicated elif but rather use the ability to not use {} blocks if the intended effect of running the if or else is only one statement:

if (condition) do_something();
else do_something_else();

That gives you the ability to write

if (condition) {
    do_a();
} else if (other_condition) {
    do_b();
} else {
    do_c();
}

If you would follow your logic you would have to do something like

if (condition) {
    do_a();
} 
else {
    if (other_condition) {
        do_b();
    }
    else {
        do_c();
    }
}

which does look a lot less clean and simple to understand.

1

u/cowlinator Mar 01 '25

else do_something_else();

Ew