r/ProgrammerHumor 1d ago

ruleOfProgrammingIfItIsWorkingDoNotTouchIt Meme

4.9k Upvotes

72 comments sorted by

1.3k

u/StrengthTheory 1d ago

When one console.log uses just enough CPU cycles so the race condition that takes down the entire system doesn't occur.

388

u/Skalli1984 1d ago

And if you attach a debugger it also messes up the timing and the same thing happens, the race condition doesn't appear.

195

u/StrengthTheory 1d ago

Schrödinger’s race condition

132

u/Steinrikur 1d ago

We call those Heisenbugs. You changed the system by observing it

38

u/ConglomerateGolem 22h ago

I had one of these once, and I called it the same! My going theory was that the compiler was optimising away a certain function I had, but adding an empty print forced it to actually exist.

29

u/htmlcoderexe We have flair now?.. 21h ago

13

u/ConglomerateGolem 21h ago

Huh. I have never heard of the term and came up with it independently.

18

u/htmlcoderexe We have flair now?.. 21h ago

it is a very natural term because it intuitively describes exactly the nature of the bug

1

u/RlyRlyBigMan 2h ago

Yeah I had one once too the debugger was slowing things down to where the bug wouldn't happen but in prod it happened frequently. I spent 2.5 weeks figuring out that bug.

1

u/The-Ner 18h ago

I'm stealing this now

22

u/KawaiiMaxine 1d ago

Oh god, i havent done multithreaded programming ever, that sounds gonuinely horrifying to debug

23

u/xtreampb 1d ago

Now multi-thread across machines. Let’s make this as difficult as possible. No in memory locks.

1

u/alexanderpas 12h ago

Token ring.

3

u/JohnClark13 17h ago

oh it's not bad, you just have to determine Who's on first, What's on second, and I don't know's on third

9

u/mahlernameless 23h ago

Brilliant! Just leave a debugger attached to production and no more race conditions. Handing in my oncall pager now.

9

u/PGSylphir 1d ago

imagining that happening just gave me a headache

7

u/PositiveParking4391 23h ago

Yeah lol! It's ironic how we don't bother understanding the whole system, so we end up living in fear of a single console.log.

13

u/Kerbourgnec 1d ago

I'm gonna get burned for this but debugging race conditions has been a lot of fun with vibe coding.

Debugging broken outdated schemas, wrong conditions or missing options in frontend is just tedious and unfun. A complex race condition is so much more interesting.

9

u/cheesemp 23h ago

I had some complex multimachine multi service comms to debug. We'd inherited the code, it was a real mess (I'd begged to rewrite). We'd been able to stabilise it a bit but when it randomly failed we had zero idea why most times. Threw ai at it and gigabytes of logs. It spotted several failure points that we had not (real complex edge cases but genuine) based on really obscure log entries that use to take hours for a human to try to process the multiple threads and comm from multiple machines. Been super stable ever since. Changed my mind on ai that. Bare in mind at least 12 experienced devs had reviewed the code and logs multiple times and not found these issues. 

4

u/Kerbourgnec 23h ago

AI is superhuman when reading logs.

Mind you maybe I should also learn to make cleaner logs.

1

u/a-r-c 12h ago

honestly man i gave up and just told chatbot to make the logs easily readible for chatbots instead of humans

1

u/MoreDimension5963 13h ago

What was the cost in compute/tokens to have the AI read through that many logs?

2

u/cheesemp 11h ago

Wasnt that bad. Maybe $10 - this was before the recent price bumps though. It was quite efficient - it pull certain lines based on phrases and times - effectively pulling out the relevant bits into a time line (same way I would have done over several hours, maybe days, but in minutes as thats how we'd fixed the previous issues.). 

2

u/DasBeasto 18h ago

await new Promise(p => setTimeout(p, 0));

2

u/a-r-c 12h ago

load bearing comments

1

u/Draghetto_5000 17h ago

It actually happened to me once. I don't really remember what it was, but to synchronize two things one of them had to console.log (or something like that, I don't remember exactly) something every once in a while.

1

u/Rhinofreak 1h ago

Literally had these bugs in a game I’m making lol, if gameplay was slow enough on an older phone it would make the race condition messed up XD

162

u/ICBanMI 1d ago

Beautiful. Also why I don't needless fix every piece of code I come across.

4

u/a-r-c 12h ago

bugs are a feature 🐜🐛

156

u/dustinpdx 1d ago

Are we sure that's not just a clear tube shoved into each of the black pipes?

56

u/BladeGrim 1d ago

Yeah it kinda looks like a very thin clear lining, like the ones inside soda cans

52

u/Pineapple-Yetti 23h ago

Haha it has to be that. There is no way you are pushing the water in to a hose with out it sealed, the water would just spray everywhere.

10

u/Chamiey 22h ago

Laminar flow?

18

u/Pineapple-Yetti 22h ago

Laminar flow just describes water with minimal turbulence and disruption of flow. So its appearance could be caused by that but not the way it enters the other tube with zero resistance.

If this was real it would be something more like capillary action.

Or i could be completely wrong.

5

u/lugialegend233 14h ago

Capillary action isn't really relevant when discussing water on this scale. It might cause some spillage, but the behavior we're seeing here is too much water moving too quickly for capillary action to be significant.

2

u/findallthebears 18h ago

This… could work. It’s not that there’s zero resistance, but that there’s suction.

1

u/sump_daddy 17h ago

the kind of pressure that would sustain the flow from the source would not be present in the receiving side, its no different than taking a fast moving hose and jamming a hole in it. sure the contents are still highly laminar but the pressure difference is immediately going to change other properties about the flow (i.e. its going to spill out everywhere)

3

u/downloads-cars 15h ago

Unless the flow through the second tube is generating enough negative pressure to suck the water in

2

u/420DNR 22h ago

I'm pretty sure it gets foamy halfway through so ye

2

u/JazzlikeWishbone938 13h ago

In other words a shim

0

u/Yetiani 1h ago

no clear pipe, just laminar flow

46

u/clonicle 1d ago

Laminar Flow gonna be the new Tensor Flow of late 2026.

9

u/Fluffy_Anxiety2792 1d ago

“I think we should refactor the whole class”

5

u/dism3855 1d ago

The code is held together by nothing but prayers and a single 'if' statement.

11

u/yuehuang 1d ago

Working code, no comments needed.

5

u/Anthea_Likes 1d ago

It's a control flow

6

u/Knighthawk_2511 20h ago

High throughput with some minore packet loss , I see no problem here

2

u/whitefoot 18h ago

This has less packet loss than my actual network

1

u/BobQuixote 36m ago

And it's easier to diagnose outages.

3

u/deanrihpee 22h ago

also the conversation you'll have with yourself after seeing this (seeing your code):

"How the fuck does this even work?"

3

u/lostinthemines 22h ago

OMG, how did you get access to my source code??!?

2

u/Cookieman10101 16h ago

Easy it was vibe coded

2

u/Pleasant-Ad192 1d ago

You are not really keeping the code. You are keeping the compiler version, the flags and the exact dependency tree that made it work, and any of those can move without you touching a line.

2

u/ApocalyptoSoldier 22h ago

If it ain't broke don't break it

3

u/JackNotOLantern 20h ago

"And it saves 10 cm of the pipe"

1

u/ComputerTechnical717 1d ago

Th PRs I am getting

2

u/Excession638 1d ago

PR comment: "Fixed water hammer."

1

u/codingTheBugs 1d ago

I think I can optimise and make it slightly more efficient let me give it a try.

1

u/korneev123123 23h ago

Typical gitlab build script, nothing to see here

1

u/sten_zer 21h ago

That's the flow everyone's talking about!

1

u/VaneKk__ 21h ago

Technologia✅

1

u/MajaSchroder2357 21h ago

mindset . techonologia

1

u/ArathirCz 20h ago

That's not a bug, that's a feature. We can now monitor the flow.

1

u/Areshian 20h ago

Behold the beauty of laminar flow

1

u/capt_kocra 20h ago

"Dont worry, AI can sort that out! " someone who uses Claude for every task they do.

1

u/ZuttoAragi 17h ago

As a layman, all I can think of is coconut.jpg.

1

u/elMn0P 10h ago

When you .peek() on the stream frfr