4 ms·
>GC is also a convenience “Convenience” makes it sound like syntax sugar, it’s not merely convenient. It eliminates certain types of bugs fundamentally, often
by WhitneyLand 4y ago
>GC is also a convenience
“Convenience” makes it sound like syntax sugar, it’s not merely convenient.
It eliminates certain types of bugs fundamentally, often it can simplify how the code is reasoned about.
- mpweiher 4y ago"Convenience" is exactly right and syntactic sugar is underrated. Just like static typing is a convenience. And dynamic typing is a (different) convenience. And unit tests are a convenience. The computer runs fine without any of these. And none of them are a magic wand that eliminates all bugs. Instead all of them make debugging easier by reducing the search space, usually eliminating fairly trivial bugs. Which is more useful than it sounds because a lot (the majority?) of bugs are pretty trivial and at the same time hard to find because they are often so trivial that they stare us in the face and we can't see them. But again, all these things are conveniences for the human programmer, they don't make one iota of a difference for the actual computer running the bits.
- pjmlp 4y agoI always discuss about SLAs when arguing about language X vs Y. Even if language X loses in microbencharks against language Y, if the application written in X is still within the project delivery SLA for acceptance testing, who cares about the microbencharks.
- dxdm 4y agoIf I understand you right, then following your logic, all programming languages are conveniences. The computer runs just fine if we give it a binary to execute. It's not clear to me where you'd draw the line.
- chucksmash 4y agoIs that wrong though? Compilers are "just" a kind of program that runs on our computers that afford us the convenience of writing programs in a more human friendly manner. The main argument in my mind against considering programming languages an awesomely powerful convenience would be that this is reductionist and that in the same manner, literally every invention ever was just a convenience as well. But maybe the view of modern society as a tower built on the back of a million million one time conveniences that have since become indispensible isn't that far from the truth either?
- nanolith 4y agoIt's not always a convenience. Perhaps when dealing with the potential elimination of certain classes of programmer error, but there are definitely use cases where specialized GC can solve runtime problems more efficiently than hand-written memory management. As a real world example, consider a firmware boot loader I wrote for a previous client. They needed to apply code polymorphism (think, extreme ASLR) when they applied an over-the-air update or a factory reset of firmware. This is part of their defense in depth strategy: if a gadget attack were discovered in their system, they wanted to mitigate its effectiveness across all deployments. The problem with this approach is that boot loaders are tightly space constrained. To implement a sound code polymorphism strategy, around a dozen different heuristics must be applied in several passes over the code. These heuristics had to be weighed against timing and cache coherency constraints in the code under mutation, but most critically, these heuristics had to fit in the very limited space set aside for the boot loader. The GC was an optimization. It significantly reduced the code size of the heuristics.
- naasking 4y ago> Instead all of them make debugging easier by reducing the search space, usually eliminating fairly trivial bugs The last 50 years of CVEs suggests they're not so trivial.
- mpweiher 4y agoYou're right, I should have specified that I meant trivial in terms of cause, not in terms of impact. That's why static typing and unit testing are both practically much better at reducing bugs than they have any right to be theoretically.
- canadianfella 4y ago
- Cloudef 4y agoI actually find it easier to leak with gc than without. Gc effectively hides the problem well, while non-gc is easy to debug with tools like valgrind.
- tsimionescu 4y agoGCs don't eliminate leaking, they eliminate use-after-free, and can also be used together with other language design choices to eliminate any kind of memory corruption (like in Java).