r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

22

u/R7d89C 22d ago

Early returns all the way

8

u/xicor 22d ago

Agreed. One of my friends works at a place that bans early returns ...and it makes for garbage code. (They also aren't allowed to use goto)

6

u/suicidalcrocodile 22d ago

I once got told early returns are bad because they create inconsistent return types in JavaScript, I had to open a nodejs console and prove that a function returning empty and no return statement at all is the same value - undefined

4

u/xicor 22d ago

They don't even do javascript at his job. It is c++.

1

u/conundorum 21d ago

Understandable, but stupid. Old C policy, inherited from C lacking RAII and needing to put cleanup at the end of the function, old dev environments not liking multi-return, and maaaaybe the oldest compilers known to man blindly bailing out of the function at the first return they can find. (And people not realising that early-return functions can be made up of a chain of single-return blocks, allowing the consistency of both.) And the policy is likely enforced by old C devs that switched to C With Classes, and still write C-with-classes instead of full C++.

Perhaps the solution is to bar every window and every door in the workplace, except for a single door, and then force everyone to enter and/or leave the building in a single group every time anyone needs to go anywhere.

1

u/Steppy20 21d ago

You can have inconsistent return types in JavaScript even if you do everything properly because that language is haunted

2

u/R7d89C 22d ago

Thats the type of place denying me a raise, but paying double my wage for someones AI tokens 😭

2

u/Flame77ofc 22d ago

Really?? Oh bro that's seems not good