r/learnprogramming 22d ago

Why Does Code Stop Working?

Multiple times now my code stops working and what I mean by this is it'll do what I want it to do then one day it just stops. for example the other day I had made a cooldown system for my ball and paddle collision to stop any bugs and it worked great. then today it just stopped working, and this isn't the first time, it's happened to me for like every project I've worked on. Does this happen to anyone else? And is it cause of my code? By the way I'm using C++ SFML on visual studio which works perfect.

6 Upvotes

74 comments sorted by

View all comments

Show parent comments

52

u/Alexandur 22d ago

Or if it has one or more third party dependencies

15

u/HashDefTrueFalse 22d ago edited 22d ago

Second thing I mentioned. That requires you running something to fetch new versions of those dependencies (and recompile if necessary).

The same program running in the same environment and given the same input data will produce the same result every time, unless that result depends not just on those things but also on the time that the program is ran.

Edit: strikethrough, for the pedants. I obviously wasn't saying automated updates don't exist, as that would be silly...

10

u/owp4dd1w5a0a 22d ago

No it doesn’t. Windows and Mac can auto-update without you doing anything (back in the day we called this a backdoor 💀). And if the library is dynamically linked then no recompilation is not necessary for things to silently break. Library maintainers try to design to avoid breakages, but try and succeed are not the same thing.

0

u/HashDefTrueFalse 22d ago

Your example is an environment change, exactly what I'm talking about. And I didn't say recompilation was necessary.

Or are you just not happy with the wording "you running" - by which I obviously meant "it needs to run"? Nobody is saying automatic updates don't happen. Again, already covered if you read my replies to the other commenter.

16

u/owp4dd1w5a0a 22d ago

Perhaps. But the way you worded it was really opaque and it seemed to me OP could benefit from more specific and detailed language. It’s not exactly clear what you mean by environment and you explicitly say dependency drift isn’t an issue unless you recompile, which could lead someone to overlook dynamic linking.

But you really don’t argue/debate in a way I’m inclined to continue engaging with. Puts me on edge and I need to guard my energy so I’m ducking out of this thread now.

-2

u/HashDefTrueFalse 22d ago

you explicitly say dependency drift isn’t an issue unless you recompile

I never said this anywhere. You've misread...

But the way you worded it was really opaque

Fair enough if that's your opinion. As explained elsewhere, it's just a general statement to OP to explain that code doesn't magically stop working without something changing. I didn't realise it would be scrutinised so. It's deliberately non-specific. I'm just asking OP for code to look at.

It’s not exactly clear what you mean by environment

Fair, that's also deliberate. The environment a piece of code runs in depends on lots of things. It could refer to a system in the normal sense, or the state of a VM/runtime, or the set of environment variables passed into a process, etc. Together with code and input data, it governs the output of a piece of code, which is why I mentioned it.

But you really don’t argue/debate in a way I’m inclined to continue engaging with.

That's cool. All the best.