3 ms·
In C you leak memory because of all the land mines in the language. In Java/.Net you leak memory because you have flaw in your logic.
by wiseowise 4y ago
In C you leak memory because of all the land mines in the language. In Java/.Net you leak memory because you have flaw in your logic.
- paulmd 4y agoCircular references and other things that tend to leak memory on GC languages aren't a logic flaw in the sense of your business logic being wrong or your algorithms being bad, though. They're things the language allows you to do, that can be completely correct at a business level and visually correct at a code level, but result in fundamental breakage of the VM's operation. I say this as someone who does high-level languages as a day job, and doesn't find them to be a problem personally, but, yeah, Java as a concept still allows some unintuitive footguns like that. Difference in magnitude of impact, difference in the response of the standards organizations in handling it, but yeah it's certainly same kind of footgun as C lets you do. The difference being that Java has devoted an enormous amount of resources to squashing these errors and they largely aren't a problem anymore, where C is afraid to touch the "undefined behavior" and "implementation dependent" sacred cows. Is there an unspoken social contract between language committee and language users that aliasing a variable or causing a circular reference should not shoot your dog and burn down the house? That's the fundamental disagreement between Java and C's standards bodies.
- scawf 4y agoCircular reference does not leak memory if your using a proper GC
- donkeybeer 4y agoMemory errors are always logic errors in C. Freeing something that was already freed or accessing a buffer out of bounds and so on are pure logic errors.
- pjmlp 4y agoPlenty of logic errors in the last 50 years, CVE appeciates it.
- donkeybeer 4y agoBut that person was trying to say memory errors are some kind of special "magical" error, which is simply wrong. Memory errors are merely logical errors. There is nothing "special" or "mysterious" about them.
- pjmlp 4y agoGiven the common meme as nasal dragons for UB, there is certainly some magic creatures associated with them.