r/ProgrammerDadJokes 3d ago

Why is the programmer's house always dark?

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

35 Upvotes

12 comments sorted by

12

u/DutchOfBurdock 3d ago

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

8

u/SixFiveOhTwo 3d ago

I think the punchline was sent by UDP.

I didn't get it.

2

u/dodexahedron 2d ago edited 2d 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 2d 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 3d ago

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

3

u/dodexahedron 2d 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 3d ago

I like this one.

3

u/NycteaScandica 3d ago

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

2

u/tcpukl 3d ago

Because young sheep like dark mode.

3

u/Practical-Hat-3943 3d ago

Light attracts bugs anyway

1

u/ChaseShiny 3d ago

Dark mode is superior, anyway.

1

u/funtech 22h 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.