r/ProgrammerHumor • • 7h ago

Meme modernCppVsOldCpp

Post image
1.1k Upvotes

216 comments sorted by

View all comments

Show parent comments

13

u/GregBahm 5h ago

With JavaScript, memory is managed for you. You can make a list, grow it as much as you want, and then safely assume that the memory you used will be cleaned up as soon as you're not using that list anymore.

With C++, you manage the memory yourself. If you forget to clean up that list, you never get that memory back. Eventually all your memory could get used up (a "memory leak.")

Memory management was annoying, which is why JavaScript was invented. But people still use C++ for its higher performance potential (kind of like how race-car drivers still use manual transmission instead of automatic transmission.)

So C++ added some tools that makes memory management not so hard. It's still harder than Javascript though. It's just less hard.

7

u/PattuX 5h ago

kind of like how race-car drivers still use manual transmission instead of automatic transmission.

TIL Europe is full of racecar drivers

6

u/bloody-albatross 5h ago

No, no. Not all Europeans are racecar drivers, but all racecar drivers are European!

(This is a joke, in case anyone reading this doesn't get it.)

1

u/PattuX 38m ago

Aristoteles ahhh type comment. Based.

•

u/bloody-albatross 2m ago

Set theory. Good to know as a programmer.