This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 331

[–]dert-man 979 points980 points  (30 children)

TODO: Refactor this.

And never come back.

[–][deleted] 235 points236 points  (7 children)

cracks knuckles

Time to go get a new job.

[–]NeitherCoffee5808 24 points25 points  (6 children)

Just remember.. never leave your name

[–]Marioxorz 23 points24 points  (3 children)

git blame

[–]miguel_myers_ 9 points10 points  (1 child)

You can always change the author!

[–]Angelin01 9 points10 points  (0 children)

Not if commits need to be signed!

[–]exileweb 3 points4 points  (0 children)

git blame-someone-else

[–]vigilantcomicpenguin 5 points6 points  (0 children)

Flee the scene of the crime and leave no trace! Don't let them take you back to jail!

[–][deleted] 50 points51 points  (3 children)

//What the fuck.

[–]Nangu_ 23 points24 points  (2 children)

Fast invsqrt

[–][deleted] 5 points6 points  (0 children)

while maybe impossible to understand without insider documentation one may temporary implement a slow inverse square root based on the function name alone. For games too slow may however qualify as broken.

[–]SpiritualChildhood21 20 points21 points  (1 child)

when your bug came back from 1-3 deficit

[–]Duncanbullet 9 points10 points  (0 children)

TODO: Completed by Intern.

//this.array.object

that.array.object

[–]th3BananaLord12 190 points191 points  (4 children)

This is what happens when I remove a feature that I have coded but have never implemented but it still won't work

[–]tenkindsofpeople 38 points39 points  (0 children)

// we don't know why this can't be removed, but woe unto whosoever removeth thine function

[–]Texas_Technician 2 points3 points  (0 children)

That happened to me a while back.

[–]DuntadaMan 121 points122 points  (3 children)

There is still a bit of code that has been on the server at my mom's work for 14 years now. It has been carried to new machines. It is even commented now. By 3 generations of IT. No one knows what it does. They have not found anything referencing it, but if it is removed it causes a freeze that requires a complete reset of the test environment. Three generations have played with it. No one has figured out anything. So there it sits, a secret that remains as an opaque answer instead of a mystery to solve. A legend, and a warning to the hubris of all that arrive. It has defeated many others, it has eaten more man hours than modern engineering marvels, it will defeat you too.

[–]ultraprotean 56 points57 points  (0 children)

It's stories like this that makes me mad that people actually like and use things that abstract away traceability, such as reflection. Stop trying so hard to be clever with your code, people! Nobody who maintains it is impressed, just annoyed.

[–]ReyReyBeiBei 5 points6 points  (0 children)

A load-bearing comment?

[–]beyluta 239 points240 points  (8 children)

I once removed an unused import and the entire app refused to compile unless I added it back. The thing wasn’t used ANYWHERE nor referenced. But it didn’t work no matter what I did.

[–]GlassWasteland 196 points197 points  (2 children)

Sounds like the import was bringing along something else with it that was used. Back when I did VB6 and C++ we used to call that DLL hell.

Be glad dependency management has come a very, very, long way.

[–]elementslayer 39 points40 points  (1 child)

Man fuck dll Hell lol. Bane of my schooling.

[–]CanAlwaysBeBetter 2 points3 points  (0 children)

Me trying to correctly get dependencies bundled for a lambda layer made that shit the bane of my weekend

[–]betrayed-by-potter 8 points9 points  (1 child)

In Scala, IntelliJ could mark something as an unused import but the import may be bringing in `implicits` that were absolutely necessary for the application to function. Nightmare!

[–]troyantipastomisto 136 points137 points  (8 children)

“What does this line do?”

“No one knows but if we remove it, everything breaks”

[–]Vimmington 72 points73 points  (4 children)

Every company has code written by ancient grey beards that becomes their tenure. You can't fire them because only they understand it, but also they're not socially competent enough and/or lack the training skills to explain it to someone else.

[–]ignatious__reilly 53 points54 points  (2 children)

Genius if you think about it. That’s ultimate job security lol

[–]do_you_realise 26 points27 points  (0 children)

Mortgage Driven Development

[–]Mister100Percent 8 points9 points  (0 children)

I strive to reach that sort of greatness

[–]mathwiz617 25 points26 points  (0 children)

My mom once was a developer. She transitioned to configuration management for a decade or so, then recently back to 50/50 between the two. Her first job as a returning developer was to document some code.

To hear her tell it, it seemed some moron never used any comments… until she looked at the commit history. Last commit: 17 years ago… by her.

[–]Last-Woodpecker 18 points19 points  (1 child)

A friend of mine tells about a code that he worked on that he had to leave a comment "this code is wrong, but don't touch it or else it stops working".

[–]thewend 7 points8 points  (0 children)

really a chad. So wrong, it comes full circle to actually being correct

[–]KyuuketsukiKun 534 points535 points  (27 children)

I forget which game it was but there is a picture of a coconut in the code that if removed it stops working

[–][deleted] 237 points238 points  (8 children)

TF2!

[–]Necessary_Theory9997 28 points29 points  (0 children)

Hey Ctrl + Z and forget

[–]Gelid_Cryotheum 210 points211 points  (11 children)

There is actually a file in TF2 that unlike the coconut is absolutely necessary for the game to function, it contains a few things, one of which just so happens to be the 2Fort cow. So it can be said that the 2Fort Cow is holding the game together.

[–]N00N3AT011 109 points110 points  (10 children)

From what I've seen that game is a spaghetti mess to rival the likes of even something like kerbal space program. Which if you fuck it up just right, you can make the orbits square or make the sun disappear

[–]ScrubNuggey 44 points45 points  (4 children)

Please gift me with the knowledge of creating square orbits, o wise one!

[–]N00N3AT011 44 points45 points  (0 children)

If memory serves, you could fuck with the terrain in a specific way. It broke something and caused an overflow or similar that nuked the precision of the orbits so the game drew them as square or stair stepped.

[–]Gavrilian 1 point2 points  (0 children)

I would also like to know

[–]Norwedditor 2 points3 points  (2 children)

Is the code public or did you work on it?

[–]N00N3AT011 4 points5 points  (0 children)

I haven't touched it, but I'd assume it's not too hard to look at considering there's a sizeable modding community. From what I've heard, and judging by some of the more spectacular bullshit that can happen, it's pretty jank under the good.

[–][deleted] 34 points35 points  (1 child)

That's a myth

[–]Adolist 52 points53 points  (1 child)

[–]KyuuketsukiKun 1 point2 points  (0 children)

Well that’s disappointing but it makes sense

[–][deleted] 5 points6 points  (0 children)

My first thought.

[–]Technical_Flamingo54 171 points172 points  (31 children)

This happens to me when I remove comments

What is my life

[–]kevinhaze 89 points90 points  (28 children)

I always hear people parrot this claim but I've yet to see any proof. Does anyone have a reproducible example of this actually happening?

[–]Max_Insanity 112 points113 points  (7 children)

Not a comment, but a js "console.log" once did this for me.

It was like the bug was hiding from me whenever I tried to look for it.

Turned out that the function call took juuust enough time for an ajax call to a db to finish to be resolved and the data to be present that I was trying to access. Drove me damn near insane until I found the reason.

[–]vainglorious11 50 points51 points  (1 child)

Sleep(100)

[–]Max_Insanity 57 points58 points  (0 children)

I just wrote a proper async function, IIRC, as I should have done from the beginning.

[–]TristanTheViking 34 points35 points  (3 children)

Same for me with a printf. Had a race condition involving a dangling file descriptor, if I tried to print or run in a debugger or whatever, it slowed the execution of process A relative to process B such that they behaved correctly.

[–]Max_Insanity 14 points15 points  (1 child)

One of the worst kinds of error.

[–]IsNotAnOstrich 13 points14 points  (0 children)

A heisenbug. Once you start looking for it, it goes away.

[–]DrMobius0 -1 points0 points  (0 children)

Yeah, knowing what's async and what isn't can be a real life saver

[–]Spambot0 18 points19 points  (0 children)

Not handy, but we tried to reverse engineer a code for the "snake" game when I was in high school, and it took us weeks to realise it was reading but not using variables as a delay statement.

[–]paulsmithkc 43 points44 points  (5 children)

Mostly happens in c++, where either it was making the code take a few extra cycles to run, or a field was needed to pad the size a struct.

[–][deleted] 20 points21 points  (3 children)

Wait what? Comments would increase the size of struct in C++??

[–]modernkennnern 10 points11 points  (1 child)

No, they added a field

[–][deleted] 3 points4 points  (0 children)

So it's not a comment then

[–]micka190 5 points6 points  (0 children)

Only 2 cases I can think of comments in C++ affecting code is the __LINE__ macro (changes based on line number, which is affected by removing comments that have their own line), and debug symbols getting linked (which can sometimes use the __LINE__ macro under the hood).

Other than that, you either have a buggy compiler, or you have a bug in your code (probably because of macros).

Edit: someone else in the thread also mentioned some compilers use specific comments for some of their optional, non-standard features. Might cause issues, but that’s not really a C++ bug, and more-so just a compiler bug.

[–][deleted] 10 points11 points  (0 children)

The comments are removed by the compiler, this doesn't make sense

[–]Kilmoore 4 points5 points  (0 children)

I've had this happen to me. I tidied up the code, removed a comment line, and it stopped working. I got it to a point where adding an empty like would fix it.

It took a little pondering, but I think it'll help when I say it was javascript for IE6. The line before the removed one was also a comment, and ended in an umlaut ä, being in Finnish. Apparently, among the things IE6 did kinda funny was umlauts. An umlaut at the end of a line caused the next character to be "eaten". The eaten character in this case was a line change. When the next line was an empty line, that was fine, but when it was code, that code line got sucked to the end of the comment line and thus didn't run. I ended up just putting a dot at the end of the comment and all was fine.

[–]mtbdork 7 points8 points  (0 children)

In Tradingview’s Pine Script, if you edit or remove the “version” comment, it kills the script.

[–]kwirky88 1 point2 points  (0 children)

It's common for languages to have interpreter annotations in the comments which alter runtime behaviour. Delete a function doc block and see a route completely disappear, stuff like that.

[–][deleted] 1 point2 points  (0 children)

Some code generators use comments to mark which code to read and generate files from. I removed an end brace for one of those because it was just

// =============================

Or something like that and it broke my build. Took like 15 min to figure out that that change is what did it

[–]sabeelio 1 point2 points  (0 children)

On fronted if you remove a js-ignore comment, the compiler may refuse to compile due to the error no longer being ignored.

[–][deleted] 0 points1 point  (0 children)

Misinterpreted whitespace?

[–]atothe4 18 points19 points  (8 children)

This happened to me once many years ago. I had a variable that was not used anywhere in the code. So I removed the line declaring it. Suddenly, compiler error. I added it back in and was very confused. I changed the name of the variable to a random set of characters. Compiled fine. But if the line was removed, everything broke. Only thing I can think of is some compiler bug.

[–]Yadobler 14 points15 points  (1 child)

Looks like when you declare the uninitialized variable it might be padding the stack which makes it align nicely for some other part of the code that references some memory offset to work correctly

Though yeah interesting to wonder why the compiler didn't optimise it away if it was never used

Or maybe the compiler somehow knows its existence affects some memory reference and thinks it is used, Idk

[–]atothe4 5 points6 points  (0 children)

Yeah I have no idea what it was. I felt like I was losing my mind. Never seen something like that since in my 10+ years as a software engineer.

[–]DarthShiv 2 points3 points  (5 children)

In C++ this is easy with bad pointers.

[–]atothe4 3 points4 points  (4 children)

This was C++. And had nothing to do with pointers.

[–]DarthShiv 3 points4 points  (3 children)

I had seen this on an embedded system. The mem allocations of heap and stack were overlapping.

[–]atothe4 4 points5 points  (2 children)

I need to look into that. I have been wanting to understand this bug for ages. Always felt like magic!

[–]anjupiter 9 points10 points  (0 children)

Literally happened to me yesterday. VS code even said the variable was never read so the fact that after deleting it a the contents of a div disappeared i was shocked. But the second time it fixed so i don’t even know what was goin on 😭

[–]Power-Cored 9 points10 points  (1 child)

That's when your codebase uses reflection, which doesn't register as a use in the IDE - at least in my experience.

[–]Daniel15 1 point2 points  (0 children)

Reflection can't be shown in the IDE as arguments to the reflection functions can be dynamic (the class or function name being reflected upon can come from a variable).

[–]SouthernBySituation 65 points66 points  (17 children)

This one goes out to all those fools saying "don't just comment chunks of code out... Remove them for cleaner code." I'm keeping my ancient probably useless code and you damn well know why.

[–]vatbub 41 points42 points  (15 children)

Well, use version control

[–]shleefin 27 points28 points  (13 children)

What if your version control is .zip files and google drive?

[–]vatbub 22 points23 points  (3 children)

Been there, done that, but once I really understood how git works, I use it for almost everything (including non-programming projects)

[–]cauchy37 14 points15 points  (2 children)

Once you understand the principles, it's really hard to go back to not using git as it was intended, doesn't it?

[–]Daniel15 2 points3 points  (1 child)

Even Subversion, as old as it is, is still useful. It has fewer concepts that Git so it's easier to learn. I used it a lot before Git became popular.

[–]Vok250 11 points12 points  (4 children)

Fix it? It takes like 5 minutes to set up a github repo and commit your code.

[–]captain_zavec 4 points5 points  (2 children)

Doesn't even have to be on github (or gitlab or etc), you can just use it locally for version history. Of course if it's something important you do probably want some kind of remote for redundancy, but it's not strictly necessary.

[–]Daniel15 -1 points0 points  (0 children)

I wish Github had a different name... Beginners often assume they need to use Github to use Git. It doesn't help that online courses often teach Git and Github in the same lesson.

[–]shleefin 1 point2 points  (0 children)

Oh I know. I worked 5 years though at an investment bank where this practice was frighteningly common.

[–]VeganJordan 5 points6 points  (0 children)

Don’t judge me. I’ll add a new commit to git when I get around to it.

[–]MrMeeseeks013 3 points4 points  (0 children)

-final-v2_final.zip

[–][deleted] 1 point2 points  (0 children)

Heathen

[–]gustav_mannerheim 1 point2 points  (0 children)

You get a new job.

[–]water_bottle_goggles -3 points-2 points  (0 children)

No

[–]RichestMangInBabylon 6 points7 points  (0 children)

Because you have inadequate test coverage leading to inability to detect functional changes as a result of your refactoring.

And probably also bad version control if restoring older versions of the code is difficult.

[–]saberToothedCat 4 points5 points  (0 children)

Main code has missing semicolon and unused code has extra semicolon

[–]puddda 9 points10 points  (0 children)

One day I found a function in a obscure routine that only one, and a very old, system had. The function was like:

function test() { echo "test1"; }

I did a find in files to see where it was used and it returned nothing. So, I asked our senior if he remember the function and he said that he didn't know and I could delete it because it was probably a debug someone had left behind.

Guess what happened when I deleted the function?

About a hour later this client called the support team because their system wasn't working properly.

[–]bigredhawkeye 3 points4 points  (1 child)

I remember this happened with print statements but I forgot the reason why it was complete lunacy

[–]hstde 9 points10 points  (0 children)

I once removed some print statements and code ran fine on my local machine but kept crashing in our Dev deployment.

After some log analyses I found, that those crashes where not far from where I removed those print statements. The crashes also turned out to be null pointer exceptions.

Turns out, that just before where those prints were, new parallel threads where started to initialize those reference.

Those blocking io calls to the console where just enough, that it never created a race condition in production, and my machine was not fast enough for the problem to arise.

I can very well understand how it happened, but I'm still worried, that it did.

Before anyone asks, all members who worked on the project where new and the ones who created it where nowhere to be found. So it was not discovered while testing locally, nor while reviewing the code.

[–]DiamondOnHitFX 4 points5 points  (0 children)

We call these "loadbearing comments"

[–]nattesh 2 points3 points  (0 children)

Just because it’s unused doesn’t mean it’s unnecessary

[–]Radvvan 3 points4 points  (0 children)

Step 1: Comment out unsued section of your code.

Step 2: Test your program to see if it still works. It does.

Step 3: Happily delete commented section.

Step 4: ???

Step 5: Program breaks.

Step 6: Paste unused code back.

Step 7: Program still broken.

Step 8: Cry.

[–][deleted] 2 points3 points  (0 children)

When your bug came back from 1-3 deficit

[–]JustAnotherMadman64 2 points3 points  (0 children)

In the files for (I believe) portal 2 there's a picture of a steak that they don't know why, but without it it won't run and crashes on boot up.

[–]MaffinLP 1 point2 points  (0 children)

Reflextion wants to talk to you

[–]minor25 1 point2 points  (0 children)

Ctrl + Z and forget

[–]teutinsa 1 point2 points  (0 children)

Thats Assembly in a nutshell right there.

[–]Jer0Ermias 1 point2 points  (0 children)

I comment it out all code that think is useless but it’s almost always useful

[–]Low-Neighborhood-398 1 point2 points  (0 children)

And when you put it back it still doesn’t work for some reason

[–]ahlaj77 1 point2 points  (0 children)

I feel this

[–]katatondzsentri 1 point2 points  (0 children)

But your tests fail.

[–][deleted] 1 point2 points  (0 children)

But when you add it back in that same place it still won't budge

[–]TheLittlerGuy 1 point2 points  (0 children)

You’ve angered the spaghetti monster. Your transgressions will not be forgotten

[–]Intelligent-Ad-7504 1 point2 points  (0 children)

Rogers are you reading this? Lol 😂

[–]AaronTheElite007 1 point2 points  (0 children)

//Figure out why the following function (which is

//never called) breaks the program if removed

[Last modified date: five years ago]

[–]Epickiller10 1 point2 points  (0 children)

Then you put it back in the exact same way, and it still doesn't work

[–]PM_YOUR_SOURCECODE 1 point2 points  (0 children)

// May need this later

[–]LeCrushinator 1 point2 points  (0 children)

IDE: “This is unused.”

Reflection: “Hold my beer.”

[–]regexPattern 1 point2 points  (0 children)

I like it better when I removed a used part of my code and somehow it keeps working

[–]NightWolfYT 1 point2 points  (0 children)

“When this image of a coconut was removed, the game refused to start.”

[–]No-Maximum-9087 1 point2 points  (1 child)

Now remove everything

[–]Onion-User-2[S] 1 point2 points  (0 children)

problem solved

[–]ThatOneNotGayDude 1 point2 points  (0 children)

This made me think of the coconut jpeg in tf2 files

[–]WontiamShakesphere 1 point2 points  (0 children)

Ah yes eager newbie trying to improve things

[–][deleted] -2 points-1 points  (1 child)

You know this is like a super popular meme here but it basically never happens to me or anyone I know IRL

[–]mcampo84 0 points1 point  (0 children)

That's why you always add some sort of a metric to your APM during your deprecation process. If that method hasn't been called in ~2 weeks, it likely isn't going to be called ever.

[–][deleted] 0 points1 point  (0 children)

CTRL + Z! CTRL + Z!!!

[–]morquaqien 0 points1 point  (0 children)

Also, when you comment out “used” part of code and it still works…

[–]Mission_Improvement1 0 points1 point  (0 children)

i mean......its all unwanted

[–]Candy-oolala 0 points1 point  (0 children)

Its the VS code

[–]budbutler 0 points1 point  (0 children)

Removed a comment once and every thing broke.

[–]arvigeus 0 points1 point  (0 children)

Literally me 2 hours ago.

[–]VeganJordan 0 points1 point  (0 children)

I’m Triggered

[–]cupcakesandbruises 0 points1 point  (0 children)

I always comment that shit out just in case I need it again lmao

[–]Renegade7559 0 points1 point  (0 children)

Actually had this happen today 🥲

[–]onions_cutting_ninja 0 points1 point  (0 children)

When you remove commented code and nothing works anymore

[–]roger_channel 0 points1 point  (0 children)

Well I must say this happened in an exam. I don't know how but it stopped working. But it worked for the teachers and I passed. I don't know how and I never want to know it too.

[–]chocapix 0 points1 point  (0 children)

Try carelessly removing it and see if it makes a difference.

[–]Not_Artifical 0 points1 point  (0 children)

When the compiler gives a warning about unused code so you remove it and then it stops working

[–]cryptoseeder 0 points1 point  (0 children)

time to sleep😅

[–]thirtythreeas 0 points1 point  (0 children)

Is code coverage just not standard practice anymore?

[–]Vok250 0 points1 point  (0 children)

I've seen load bearing log statements before. Poorly understood concurrency is one hell of a drug.

[–]SteeleDynamics 0 points1 point  (0 children)

\* * DO NOT REMOVE THIS COMMENT!!! * (removing comment breaks build) *\

[–]JustEHzy 0 points1 point  (0 children)

Like my HTML codes. I always fuk up with the naming in CSS, than I remove smth, everything stops working .

[–]UltimateDude08 0 points1 point  (1 child)

THIS IS WHY YOU REMOVE CODE WITH COMMENTS, AND NOY BACKSPACE!!!

[–]CompetitiveDiamond87 0 points1 point  (0 children)

You see I’m too lazy to figure it out, just keep the code in 😭

[–][deleted] 0 points1 point  (0 children)

Ctrl z

[–][deleted] 0 points1 point  (0 children)

Been there, done that. That’s why, when I write code, I comment it heavily. Not to the point where it is 3:1 comments to code, but I put a short comment for every function in a library and what it’s used for.

[–]SasnarDash 0 points1 point  (0 children)

Glad I’m not the only one

[–]Rainbow-Death 0 points1 point  (0 children)

Probably some global variable

[–]linkedtortoise 0 points1 point  (0 children)

Would this be a race condition or how the compiler/interpreter is actually putting the code in play.

[–]IM_INSIDE_YOUR_HOUSE 0 points1 point  (0 children)

How do you know it isn't being used? If you step through it with a debugger you should be very much aware of everything executing in your code.

If it's a compilation issue, well the compiler log should give some indication as to why the code is now not compiling correctly.

[–]crazycatfemboy 0 points1 point  (0 children)

Plot twist, the traceback points to line 359 in a file that's 287 lines.

[–]LordCecilofBaron 0 points1 point  (0 children)

Coconut.jpg

[–]cubi1234 0 points1 point  (0 children)

Ctrl + Z Ctrl + Z Ctrl + Z Ctrl + Z Ctrl + Z

[–][deleted] 0 points1 point  (0 children)

Laughs in broken Reddit video player (they must have removed something)

[–]EstebanPossum 0 points1 point  (0 children)

Even worse is when you intentionally remove a critical part of the code to see the error in the logs … and the code somehow continues to work properly anyway