r/ProgrammerHumor • • Mar 27 '19

That famous function

Post image
5.8k Upvotes

176 comments sorted by

View all comments

1.3k

u/Alokir Mar 27 '19

A few years ago we downloaded a stopwatch javascript libarary and inspected the code. There was a funny line in it:

// if you delete this it will stop working in IE8
while (false) {}

We tried it and they were correct. We had no idea wtf was going on or how they figured this out.

549

u/Milleuros Mar 27 '19

how they figured this out.

That will stay as one of the great mysteries of history.

395

u/cbusalex Mar 27 '19

have working code with loop "while (condition) { doTheThing(); }"

some change makes loop no longer needed

remove loop

code no longer works in IE8

spend weeks trying to figure out why code is broken

make no progress

arduously test every commit in branch history until you find the one that broke it

looksFineToMe.jpg

begin to experiment piecemeal with every part of the commit

code works when "while (condition) { doTheThing(); }" loop is present

code works when loop is present, even when condition never evaluates to true

code works when loop is present, even when doTheThing() does nothing

code works when loop is present, even when condition is literally just "false" and loop contents are empty

code still does not work without useless, completely neutered loop

fuck it, blame it on ghosts or something

50

u/[deleted] Mar 27 '19

Thank you for making my day, stranger.

17

u/Milleuros Mar 27 '19

Sounds incredibly relatable

12

u/Python4fun does the needful Mar 27 '19

updoots to you

→ More replies (4)

257

u/Sckaledoom Mar 27 '19

Probably somebody was having trouble getting it to work right and his intern added that as a joke. That intern later got a recommendation.

135

u/JuhaJGam3R Mar 27 '19

"Has demonic powers. Hire if at all possible."

16

u/cysghost Mar 27 '19

That is a helluva recommendation!

93

u/[deleted] Mar 27 '19

I appreciate your flair.

129

u/Milleuros Mar 27 '19

Thanks, I stole it somewhere

110

u/[deleted] Mar 27 '19

A true programmer

81

u/Python4fun does the needful Mar 27 '19

I saw this thread posted earlier, and then found it in the wild here and now.

15

u/SavvySillybug Mar 27 '19

It feels cliche to just say "me too" but, me too!

→ More replies (5)
→ More replies (1)

112

u/[deleted] Mar 27 '19

Lmfao this is absolutely fucking brutal. God IE8 is the cancer of our earth

29

u/Shrewd_Shrew Mar 27 '19

Still not as bad as the alternate reality of IE6, but IE8 really hung on despite being extraordinarily awful

→ More replies (3)

46

u/[deleted] Mar 27 '19

It's something to do with IE8's optimization of JS. I'm pretty sure replacing it with any conditional check would have worked. I've run into similar problems.

Any chance that the code surrounding that statement was idle for any amount of time?

17

u/Alokir Mar 27 '19

It's possible. This happened around 2013-2014 so I don't remember the exact context.

22

u/[deleted] Mar 27 '19

Yeah, I'm betting that's the case. It's similar to a "feature"(I call it a bug, but Oracle said its intended) in the JVM I found a couple years ago. If you have a condition that blocks in a while loop in a "Runnable", it will eventually start ignoring the loop and set it to such a low priority that it'll never be checked again.

I assume something like this happens in IE8, too, as the fix in Java was to implement a single operation within the loop to force the JVM into thinking the thread is active.

→ More replies (3)

66

u/WeAreABridge Mar 27 '19

Once I was playing Minecraft with my buddies, and I needed to allocate more ram. I typed in the necessary code in the launcher field, but my game kept crashing on startup.

I asked my friend for help and he added #yoloswag to the end of the line.

It worked.

28

u/git-fucked Mar 27 '19

Pure random guess but perhaps there was an off by one (or more) when parsing the parameter string, which resulted in:

command = "minecraft.exe --ram=8096" 
args = { "ram": "809" }

command = "minecraft.exe --ram=8096 #yoloswag"
args = { "ram": "8096", "#yoloswa": null }
→ More replies (4)

0

u/[deleted] Mar 27 '19

[deleted]

37

u/SGVsbG86KQ Mar 27 '19

Javascript has no threading tho...

→ More replies (13)
→ More replies (1)

10

u/[deleted] Mar 27 '19

or how they figured this out.

"This is beyond science."

7

u/FlyByPC Mar 27 '19

wtf was going on

IE8

→ More replies (11)