Things that magically work but you don't know why are worse then the things that don't work

I can only think of one scenario, and it's a scary one.

C/C++ (not sure about C#) allow you to do a lot of things you shouldn't with memory. You can request memory from the Operating System, but then you have to give it back. However, you can do all sorts of things to cause corruption, such as giving it back multiple times, using it after giving it back, or even making up a random memory address and attempt to do things with it.

When things go wrong with memory, usually you end up with a crash with an access denied error. This is because you are only allowed to access memory within your process. If you access memory outside of your process, then the computer is smart enough to realize something is wrong and cause a crash, which is actually the good scenario.

The bad scenario is that you edit memory within your process and you don't cause a crash. You can actually end up changing variables that your code appears to never change. I've even tested this in C++. Create an array of length 5, then immediately after create a variable set to 1. Set the sixth element of the array (which doesn't exist) to 2. Print out your variable and it'll print 2. Good luck debugging that.

However, even that scenario still wouldn't result in the comments causing an issue by itself. First, you have to realize that your program is loaded into memory when it is run, so it can affect how the computer's memory is arranged. I believe that at this phase the comments have not been removed yet, so they could still affect the memory layout. So to hit this mythical type of error, you would have to have a bug that corrupts your memory like previously mentioned. Then, it would have to be that the program with comments causes the memory to arrange in such a way that your memory corruption corrupts a variable that doesn't matter, whereas the program without comments causes the memory to arrange in such a way that your memory corruption corrupts a variable that does matter.

/r/ProgrammerHumor Thread Parent Link - i.redd.it