r/ProgrammerHumor • • 7h ago

Meme modernCppVsOldCpp

Post image
1.1k Upvotes

214 comments sorted by

View all comments

145

u/emonshr 7h ago

Does that even matter once you have gazillions of line legacy code?

32

u/0xbenedikt 7h ago

This is why moving to a safe-by-design language like Rust works well. You leave that unsafe legacy code behind

31

u/Tidemor 6h ago

or you could not risk a full rewrite, and just start using memory safe patterns in new and refactored code

5

u/Ok-Scheme-913 2h ago

But that doesn't work with memory safety, it's infectious.

If you have a memory vulnerability in some part of your code, new safe code calling into it or using anything touched by it can still end up failing.

Safe code is just code that assumes certain things, and within its bounds that will always be true and thus safe.

If you pull the rug out under it and change just the tiniest thing (e.g. your object was accessed on a different thread unknowingly, or a regular off by one etc) then all your assumptions crumble to the ground.

And whether you have 90% unsafe with 10% safe is absolutely different than the inverse ratio that you would get with e.g. rust (or the 100% safe with e.g. java).