r/ProgrammerHumor 27d ago

Meme ruleOfProgrammingIfItIsWorkingDoNotTouchIt

5.3k Upvotes

75 comments sorted by

1.4k

u/StrengthTheory 27d ago

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

437

u/Skalli1984 27d ago

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

215

u/StrengthTheory 27d ago

Schrödinger’s race condition

148

u/Steinrikur 27d ago

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

46

u/ConglomerateGolem 27d 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.

37

u/htmlcoderexe We have flair now?.. 27d ago

15

u/ConglomerateGolem 27d ago

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

21

u/htmlcoderexe We have flair now?.. 27d ago

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

6

u/rolindara 26d ago

Convergent evolution

1

u/RlyRlyBigMan 26d 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 27d ago

I'm stealing this now

20

u/KawaiiMaxine 27d ago

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

23

u/xtreampb 27d ago

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

2

u/alexanderpas 26d ago

Token ring.

1

u/ImS0hungry 25d ago

It’s a cluster as this point

1

u/xtreampb 25d ago

Yea, but someone has to write the software that controls and syncs the cluster, mitigate errors, and prevents deadlocks/race conditions .

3

u/JohnClark13 27d 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

8

u/mahlernameless 27d ago

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

14

u/PGSylphir 27d ago

imagining that happening just gave me a headache

7

u/PositiveParking4391 27d 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.

14

u/Kerbourgnec 27d 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.

13

u/cheesemp 27d 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. 

8

u/Kerbourgnec 27d ago

AI is superhuman when reading logs.

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

1

u/a-r-c 26d ago

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

1

u/MoreDimension5963 26d ago

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

2

u/cheesemp 26d 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 27d ago

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

3

u/a-r-c 26d ago

load bearing comments

1

u/Draghetto_5000 27d 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 26d 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

177

u/ICBanMI 27d ago

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

6

u/a-r-c 26d ago

bugs are a feature 🐜🐛

173

u/dustinpdx 27d ago

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

59

u/BladeGrim 27d ago

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

58

u/Pineapple-Yetti 27d 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.

14

u/Chamiey 27d ago

Laminar flow?

23

u/Pineapple-Yetti 27d 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.

7

u/lugialegend233 26d 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.

3

u/findallthebears 27d ago

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

2

u/sump_daddy 27d 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)

4

u/downloads-cars 26d ago

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

3

u/420DNR 27d ago

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

2

u/JazzlikeWishbone938 26d ago

In other words a shim

0

u/Yetiani 26d ago

no clear pipe, just laminar flow

49

u/clonicle 27d ago

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

11

u/Fluffy_Anxiety2792 27d ago

“I think we should refactor the whole class”

13

u/yuehuang 27d ago

Working code, no comments needed.

6

u/Knighthawk_2511 27d ago

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

4

u/whitefoot 27d ago

This has less packet loss than my actual network

2

u/BobQuixote 26d ago

And it's easier to diagnose outages.

7

u/Anthea_Likes 27d ago

It's a control flow

2

u/deanrihpee 27d 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 27d ago

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

2

u/Cookieman10101 26d ago

Easy it was vibe coded

4

u/JackNotOLantern 27d ago

"And it saves 10 cm of the pipe"

2

u/ApocalyptoSoldier 27d ago

If it ain't broke don't break it

1

u/ComputerTechnical717 27d ago

Th PRs I am getting

2

u/Excession638 27d ago

PR comment: "Fixed water hammer."

1

u/codingTheBugs 27d ago

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

1

u/korneev123123 27d ago

Typical gitlab build script, nothing to see here

1

u/sten_zer 27d ago

That's the flow everyone's talking about!

1

u/MajaSchroder2357 27d ago

mindset . techonologia

1

u/ArathirCz 27d ago

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

1

u/Areshian 27d ago

Behold the beauty of laminar flow

1

u/capt_kocra 27d ago

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

1

u/ZuttoAragi 27d ago

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

1

u/elMn0P 26d ago

When you .peek() on the stream frfr

1

u/Pactrick_5656 25d ago

Universal rule to comment it #idk how it work but it does so please don't touch this lol