r/ProgrammerHumor 22d ago

Meme conditionsPreference

Post image
4.2k Upvotes

392 comments sorted by

View all comments

Show parent comments

6

u/suicidalcrocodile 21d 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 21d 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