2.0k
u/Daposto Jul 20 '18 edited Jul 20 '18
Let's remove some enters and spaces in the code to make it cleaner and run it again, did it often haha.
949
u/Docaroo Jul 20 '18
It's like the compiler doesn't approve of your shitty-ass looking code formatting and doesn't take you seriously.
Clean it up and make it pretty and it believes your code is more credible now!
509
11
u/Glass_Veins Jul 20 '18
I just encountered a bug that caused a test to fail if I normalised the line endings in the test suite. This was VB. Somehow it caused a multi-line SQL string to be misinterpreted even though it looked identical (just CRLF to LF). I no longer trust these whitespace languages, lol
17
Jul 20 '18
or, be lazy and (automatically)
go fmtyour code. especially if you're a spaces bastard.→ More replies (4)→ More replies (3)6
u/JamminJames921 Jul 20 '18
Lol, like my LaTeX-made essays. Shitty content but beautiful formatting, 20/20
85
u/crono1224 Jul 20 '18
Or the reverse of it not running after you remove some white space. Turns out that was load bearing white space.
14
8
17
6
Jul 20 '18
Sometimes you find your problem doing this. Not the worst way to debug
→ More replies (1)→ More replies (9)3
u/Fluffcake Jul 20 '18
You never know. At least in js there are a few cases where ASI will fuck you if your code is formatted silly.
830
Jul 20 '18
It works... better send this shit in before i test it and it doesn't work again
148
26
u/Siarl_ Jul 20 '18
I did this and the rc got trough testing. After release there were quite a few customers with issues. Never again
13
u/Holden_Makock Jul 20 '18
As a developer, ones it passes through testing it is no longer your problem. Let the tester sweat over it with clients.
You have the typical "Closing.can't reproduce" or "Can't reproduce,closing"
→ More replies (1)11
456
u/Rocketghostrider Jul 20 '18
No idea why it works...
No idea why it doesn't work..
117
u/ahhhhhhhhyeah Jul 20 '18
No idea what you're doing...
65
u/TheHellStorm Jul 20 '18
No idea what I am doing either...
→ More replies (1)45
u/ginyuforce Jul 20 '18
The dreaded feeling of existential crisis during debugging
→ More replies (3)38
u/BagelJaengi Jul 20 '18
When you stare into the error log, the error log stares into you.
→ More replies (2)9
26
u/mpa92643 Jul 20 '18
The dreaded semicolon after an if statement has probably cost me days of productivity.
18
u/has_all_the_fun Jul 20 '18
For me it's a trailing comma in Python.
For example you have:
{ 'foo': 'bar', }And then you think "maybe I don't need a dict here let me just inline it as a variable:
foo = 'bar',Then the whole world stops making sense.
515
u/taeratrin Jul 20 '18
Sometimes you need to see the error occur in real-time again. That's my defense.
249
Jul 20 '18
Too often
Encounters error
Stops debugging, returns to code
After a moment of thinking, realizes the lack of collected data, and starts debugging again to check out the same error
17
17
Jul 20 '18
The error isn't there anymore.
The error continues to appear once in a blue moon for years and nobody knows why
24
Jul 20 '18
My defense is I make sure I actually built/ran it properly. You don't want to go start changing things until you are 100% sure the error is real and not left over because you forgot to save a file or an ide (NetBeans...) didn't want to clean out the old built folder.
10
21
20
4
u/Octopuns Jul 20 '18
That's a pretty good defense. That's exactly what I do.
Code doesn't work.
Run it again multiple times to investigate possible causes. (If relevant, try it with different input to see if it occurs 100% of the time).
Once you have an idea of what it could be, return to the code.
I feel like jumping back into the code the instant you see something not work is the worst thing to do.
213
u/rogeris Jul 20 '18
"Maybe my recent changes didn't save"
We all know they did.
37
u/enoua5 Jul 20 '18
There's been times where I've been ferociously attacking a block of code, trying to get it to work... And then realizing that I was running an old version of the executable.
9
u/Tech_Itch Jul 20 '18
Especially as we saved multiple times just to "make sure it stuck".
I got my first computer in the mid-80s. Worked two decades in everything IT related from tech support and sysadmining to database programming, web development and even industrial automation.
Still can't stop doing that shit, even though it makes zero sense.
5
u/Steampunkery Jul 20 '18
Whenever I copy paste something, I always smash the keys a few times just to be sure
→ More replies (1)6
4
Jul 20 '18
That said, I do frequently run my tests from the wrong workspace and get stuck wondering why none of my code changes are doing anything.
2
2
2
0
Jul 20 '18
[deleted]
19
u/Jazzinarium Jul 20 '18
This is why I love Android Studio, there is no "just run it", it builds every time.
5
462
136
u/TheSinnohScrolls Jul 20 '18
We all know that we actually delete/add a few line breaks, remove a comment or add spaces between expressions “just in case”
3
u/instilledbee Jul 21 '18
No joke, this was how we resolved build problems in my previous job. The compiler didn't want to create a new executable unless we added line breaks or comments to trigger a change.
2
0
Jul 20 '18
[deleted]
→ More replies (2)35
u/EatsonlyPasta Jul 20 '18
I had the same thing happen last week and I no joke thought I was losing my fucking mind.
14
u/voicesinmyhand Jul 20 '18
Oh good it isn't just me.
24
u/EatsonlyPasta Jul 20 '18
I didn't figure out what it was until this thread. It just magically worked when I redid some lines and didn't know why.
I test it now and I'm like... son. of. a. bitch.
→ More replies (1)
47
210
u/DoctorAcula_42 Jul 20 '18
It's honestly more frustrating when it starts working. Like the god of programming has been toying with you this whole time, and now he's decided to make it spontaneously work to really twist the knife and cut your thin tether to sanity.
108
Jul 20 '18
When its not working I can change something and test to see if the change fixed it. If it starts working spontaneously I'll never be 100% convinced the problem is fixed.
47
u/RandyHoward Jul 20 '18
100% of the time I'm gonna blame it on the cache if anybody asks.
→ More replies (1)32
u/voicesinmyhand Jul 20 '18
It works! Submit it for advanced testing!
<test results come back, all is good>
Update the known good baseline!
<two days later...>
Shit! Nothing works now, and I'm pretty sure all I changed was a comment that had "teh" instead of "the". How the hell did this happen!?!
<reverts to known good baseline>
Shit! It still doesn't work!
<70 hours of testing/debugging later>
What the hell!?! Both versions work now?!???
2
u/the_one_true_bool Jul 20 '18
We had a really annoying bug at a previous company I worked at. The software was a huge cluster-fuck in general, but on top of that it was a multi-threading nightmare. We had an issue where about once a day the users would experience a spectacular unhandled exception crash where they could potentially lose a lot of changes. It would pop up at seemingly completely random intervals not driven by any particular action by the users, but usually about once/twice a day. Of course this company had terrible logging so going through log files basically told us nothing.
What was super annoying is that it never crashed when we had the program running in a debugger, so it was difficult to tell exactly what was causing the crash. At least in a debugger it will break somewhere and give you some context, but not in this case. We had people running the program in a debugger for days and it never once crashed.
→ More replies (1)
44
u/mrtibbles32 Jul 20 '18
runs code again
different runtime error
runs code again
doesn't even compile
runs code again
works with no errors
Ah, ok, cool.
runs code again
doesn't even compile
13
39
Jul 20 '18
Yo be fair, rerunning it is a perfectly acceptable thing to do. Sometimes your compiler will bug out. It was written by programmers too, so there are bound to be problems.
38
u/ASovietSpy Jul 20 '18 edited Jul 20 '18
The fact that their could be bugs in a compiler is something I never really thought of before and it is a terrifying thought.
3
u/PeachyKeenest Jul 20 '18
Fuck. :( Can confirm. I deal with a lot of frameworks that are still buggy. Some issues I thought were mine were actually the framework. Thought I was truly just that crappy.
The complier potentially having the issue would piss me off incredibly bad. lol
0
105
u/williamMchugh Jul 20 '18
The real reason it didn’t work for em is because he is using a light theme.
24
8
2
28
u/bap710 Jul 20 '18
I once had to debug some code (back in ancient times, AKA 1990 or thereabouts) that worked fine 99% of the time but would crash randomly.
I eventually discovered a pattern. It would only crash between 10:00 and 1:00. On Wednesday’s. In September.
Hint: the code was written in C.
7
u/Finianb1 Jul 20 '18
What? Why?
26
u/Din182 Jul 20 '18
It looks like a buffer overflow. C is notorious for them. September is the month with the longest name, Wednesday is the day with the longest name, and 10-1 are the times of the day with the most digits. Presumably, when converting the current time into a human-readable format, the array he was storing it in was one character too short to fit all that information in. Thus, the buffer overflowed an overwrote something important, causing it to crash.
→ More replies (1)8
2
u/PeachyKeenest Jul 20 '18
I always looks for patterns when it seems random as shit. I usually find something, but that one is fantastically terrible.
I'm so sorry. :(
4
u/bap710 Jul 20 '18
The longest weekday name fully spelled out. The longest month name fully spelled out. And a 4-digit time.
The person who originally wrote this code included a buffer to populate with the current date & time. (It printed out reports). But the size of the buffer he allocated was one character too small, so when the date & time reached the maximum possible string length it overflowed the buffer by one character.
22
21
Jul 20 '18
Or when I download an example file and it runs, but I write my own file copying the example line for line and it won't compile.
58
u/Miklelottesen Jul 20 '18
Actually, I'd say it's better to make sure that the error is consistent, before attempting a bug fix that might make the problem even worse if that happens to be the case.
2
16
u/blackmist Jul 20 '18
Run, fail, run, fail, same place every time, reproducible, good, step through code, no error, run again in real time, no error.
Sadly mark bug as fixed and move on.
16
u/sloth_sloth666 Jul 20 '18
Relating so bad to this right now. Code that takes a string argument says "TypeError expected byte-like object, not str"
So covert it to bytes "expected str, not bytes"
Just sitting here clicking run hoping it works
2
u/PeachyKeenest Jul 20 '18
Error is bsing you. It's a different issue altogether probably. I hate it when error logs are giving me things that don't even make sense.
This falls into that category.
13
u/IskaneOnReddit Jul 20 '18
Well with LaTex you have to compile it twice.
13
3
u/DrSandbags Jul 20 '18
My first thought was to Ctrl-F for a comment about LaTeX. Sometimes just have to delete those aux files and retry.
34
u/Steve1717 Jul 20 '18
Did you try turning it off and back on?
6
29
9
8
u/Atriux Jul 20 '18
The sequel: My code finally runs, let’s run it 20 more times just to prove it runs.
0
7
7
u/littlepanda888 Jul 20 '18
Alternatively,
My code works
Let's change nothing and run it again
everything breaks
6
u/serial_crusher Jul 20 '18
Just ask your coworker to watch you reproduce the bug.
→ More replies (1)
5
4
u/topredditbot Jul 20 '18
Hey /u/kajri,
This is now the top post on reddit. It will be recorded at /r/topofreddit with all the other top posts.
4
u/thedracle Jul 20 '18
This is sort of the equivalent to "Did you try shutting it down and turning it back on again " regarding the OS itself.
3
3
3
3
u/The_Alex_ Jul 20 '18
Surely it is the compiler that is mistaken! I shall give it a chance to correct itself. .
3
u/GirishPai Jul 20 '18
I work in VoIP and this shit is common. Sometimes we do have to make more than one attempt to get accurate results :p
3
3
u/Dsquadcreeper Jul 20 '18
I am a very amateur (I mean very, python in the terminal level amateur) programmer, yet I can relate. The funny thing is that this worked.
3
3
Jul 20 '18
Valid method. Race conditions exist. The output of the program should not vary between runs, so let's try it again…and again…and again…
3
u/boredtodeath Jul 20 '18
There was an engineer, manager and programmer driving down a steep mountain road. The brakes failed and the car careened down the road out of control. Half way down the driver managed to stop the car by running it against the embankment narrowing avoiding going over a cliff. They all got out, shaken by their narrow escape from death, but otherwise unharmed. The manager said "To fix this problem we need to organize a committee, have meetings, and through a process of continuous improvement, develop a solution." The engineer said "No that would take too long, and besides that method never worked before. I have my trusty pen knife here and will take apart the brake system, isolate the problem and correct it." The programmer said "I think you're both wrong! I think we should all push the car back up the hill and see if it happens again."
2
2
2
u/GeryGreyhound Jul 20 '18
So true in Python when I change nothing in code but 4 spaces and one tab to 8 spaces or 2 tabs
2
2
u/oppopswoft Jul 20 '18
Is this weird? I’ll walk through the code a few more times to attempt to recreate the problem and see if I can figure out exactly where it fails before walking through it step by step
2
u/Pretendosaurus Jul 20 '18
This logic stems from years of seeing OS issues being fixed by simply restarting the computer.
2
2
u/EnchanterIOSvk Jul 20 '18
And if it doesn't, then u need to run it few more times, just in case. Around 10 is a healthy number before looking for a normal solution...
2
3
2
2
1
1
u/sblinn Jul 20 '18
Latest error: "TypeError: can't compare offset-naive and offset-aware datetimes".
I'll run it just one more time just to be sure...
1
u/MChainsaw Jul 20 '18
I'm sometimes a bit paranoid in the opposite direction. I will write functioning code, then add some comments, then think "but what if my comments somehow messed up the code!?" so I have to run it again every time I add a comment to make sure it still works. Although I suppose that's not entirely nonsensical since there's always the chance you accidentally comment something out or make some other accidental change while writing the comments, so it might not be a bad practice.
2
1
1
u/krngd2 Jul 20 '18
It working for Ionic shit
2
u/Pepa489 Jul 20 '18
I love those random ionic shitty errors. I must restart the dev webserver every time when this happens
1
1
u/UserAlreadyNotTaken Jul 20 '18
The funniest thing is that not only the thing in the image, but also most of the ones in the comments, I actually do, typically thinking that I'm being dumb while doing them. I'm happy to see I'm not the only one.
1
1
u/verascity Jul 20 '18
Sometimes I get a flash of anger/indignation on the rare occasion I'm REALLY VERY SURE I did the thing correctly. "Wait, what? No. Surely that can't be right. RUN IT AGAIN."
1
1
1
1
1
1
1
u/pewpewlightningbolts Jul 20 '18
Did this just a few minutes ago when showing something to my boss. He looked at me like I was stupid but hey it worked.
1
1
6.9k
u/that_one_mister_user Jul 20 '18
The sad thing is that this works some of the time.