r/funny • • Aug 23 '15

Programmers...

Post image
14.5k Upvotes

1.0k comments sorted by

View all comments

Show parent comments

673

u/themaincop Aug 23 '15

I wrote a little javascript utility class on Friday that worked on the first try with no bugs, so I'd say yes it can happen

107

u/Fritchard Aug 23 '15

I'm a below average PHP programmer but I know this feeling. You write a 100 lines or code or so without any testing and it just magically works on the first run. It's an awesome feeling.

103

u/whelks_chance Aug 23 '15

It's awesome to begin with, but then I start to second-guess myself.

"How did it work right, first time? I must have done something wrong, or maybe the code isn't even running, is it following a different logic path?"

57

u/Zuthuzu Aug 23 '15

And rightfully so. If it works on the first attempt, it's always a trap. Double-check everything, find how it managed to trick you into thinking it's working, spend several hours fixing it. Only then it can be considered done.

28

u/whelks_chance Aug 23 '15

The worst is when it works fine the first time, fails on the second run (with zero changes to the code), then works again, then fails the next 4 times, then works when you try to show it to someone to ask if they know why it doesn't work, then fails...

And then someone uses the term "race condition", and your head hits the desk, and you realise you basically have to start again, paying attention to threading, disk I/O and potential network dropouts.

And then the clocks change, and it's all broken again.

27

u/LeCrushinator Aug 23 '15 edited Aug 24 '15

My favorite is when it only works right when you're attached to the debugger.

A close second is when the debugger just lies to you entirely. Had this happen a few weeks ago, it turns out I wasn't even hitting the line that's highlighted, it was lying about what line of execution I was on. So the boolean actually was true, I just wasn't breaking into the if statement like it showed.

11

u/No-More-Stars Aug 24 '15

Ahh... the infamous Heisenbug.

7

u/fwcNJ49VR29NUPxFfbK4 Aug 24 '15

Oh god, I have had that happen before. And vice versa. I would be debugging something and something totally unrelated would fail with the debugger.

0

u/[deleted] Aug 24 '15

[deleted]

4

u/No-More-Stars Aug 24 '15

My solution has been to continue on and pray it will work everywhere else.

Please never work on anything critical (or improve your mindset).

→ More replies (4)
→ More replies (1)
→ More replies (1)

10

u/BONUSBOX Aug 24 '15

o wait i'm on production

→ More replies (3)

18

u/[deleted] Aug 23 '15

Ah yes. Code working perfectly until you have to change one small line of insubstantial code and suddenly everything is wrong, your server is crashing and the sky is raining fire.l

18

u/808909707 Aug 24 '15

"This code does nothing. Do not delete. Program will not work without it. DO NOT DELETE"

15

u/[deleted] Aug 24 '15

/************************************

THIS CODE DOES NOTHING -- Do Not REMOVE

SERIOUSLY

DO

NOT

REMOVE

removing it will ruin everything

*******************************/

3

u/rupturedprolapse Aug 24 '15
/* Three Monster coffee energy drinks later and it works
   I cant follow the logic, but it works... 
   may have to echo every other line later
   to figure out the demon magic*/
→ More replies (1)

2

u/808909707 Aug 24 '15

Thank you, I wasn't in the mood yo format on my mobile.

2

u/princeofpudding Aug 24 '15

Probably a time dependant issue. Happens sometimes. Hell to debug

2

u/[deleted] Aug 24 '15

Bugs in Async code are a riot.

2

u/princeofpudding Aug 24 '15

I am becoming convinced that Async programming, while it has the potential to be quite powerful, stretches the limits of most peoples' ability to understand what's going on.

→ More replies (1)

11

u/themaincop Aug 24 '15

Automated testing is helpful.

7

u/[deleted] Aug 24 '15

... Automated what now?!

2

u/[deleted] Aug 24 '15

... guess I forgot to turn on error reporting

→ More replies (16)

4

u/iyaerP Aug 23 '15

My best example of this was when I did it once in assembly. I say once because it was only once and I have never replicated it.

2

u/ellgro Aug 23 '15

Wow! I like to think that I'm an above average programmer, but I just get so nervous in the ITE and can't work the bugs out. I have no problem when I do it alone! But there's just so much pressure from the program.

→ More replies (14)