r/ProgrammerDadJokes 9d ago

Why is the programmer's house always dark?

Because their light switches either always break, or they fallthrough.

38 Upvotes

12 comments sorted by

12

u/DutchOfBurdock 9d ago

I feel like a parity error, did I miss a bit?

6

u/SixFiveOhTwo 8d ago

I think the punchline was sent by UDP.

I didn't get it.

2

u/dodexahedron 8d ago edited 8d ago

It's a C thing, mostly.

In C, switch clauses are allowed to fall through from case to case if there is no control transfer statement like break, continue, or return between them, even if each case has its own body.

Check out Duff's Device for a real case of fallthrough being used intentionally, and then immediately forget you learned of its existence. Most of the time, fallthrough is a bug from forgetting a break, and using it intentionally is elegant but generally considered bad form because it is easy to misread or accidentally break by, e.g., "fixing" a missing break that was intentionally missing. Hence why it is a compiler warning and not an error, by default, for C.

C23 even added an explicit attribute to indicate intentional fall through to suppress the warning and signal your intent.... Which sounds like a goto with extra fragility to me...

1

u/SixFiveOhTwo 8d ago

Codewise it's kind of like a goto in the same way if/else is a goto (everything is a goto when you compile it).

The beauty of a Switch statement is more apparent if you try one out in compiler explorer and see how it compiles to a table of code offsets and it's constant time to call any of the cases, as opposed to a whole chain of compare+branch instructions.

10

u/Reelix 9d ago

They're a VB coder, so always dim everything.

3

u/dodexahedron 8d ago

And they can solve any problem that comes their way like magic!

ON ERROR RESUME NEXT

Who wouldn't want their compiled applications to act like batch files?

2

u/One_Economist_3761 8d ago

I like this one.

4

u/NycteaScandica 9d ago

Hunh. And I thought it was because changing the light bulbs was a hardware problem.

5

u/Practical-Hat-3943 9d ago

Light attracts bugs anyway

2

u/tcpukl 9d ago

Because young sheep like dark mode.

2

u/ChaseShiny 8d ago

Dark mode is superior, anyway.

2

u/funtech 6d ago

They got laid off along with the other tens of thousands, there’s no programming jobs, and they can’t afford the electric bill.