7 ms·
I think many people look at GC in the wrong way, as if absolute maximum speed is always the goal. It depends on what the goal is, and GC performance can be as f
by Tozen 4y ago
I think many people look at GC in the wrong way, as if absolute maximum speed is always the goal. It depends on what the goal is, and GC performance can be as fast as needed or enough. GC is also a convenience, that many may find worthwhile, to not worry about memory management.
Optional GC, also means you are free to go for it manually, if there is really and truly some bit of extra performance needed. In regards to language wars, it's arguably better to make the case of how to make manual memory management more convenient to use, when the optional GC is turned off.
- 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).
- pjmlp 4y agoIndeed, many think of GC languages as if GC was the only way to allocate memory. Java is one of the languages to blame for such misunderstanding, many other languages, even Lisp variants like Interlisp and Common Lisp, provide all the tooling to manage resources like one would do in C and co languages. Having a GC doesn't preclude those other features. On D's case, we have the problem that language designers are against moving the GC forward, as they refuse to introduce managed pointers alongside untraced pointers. So even optimizations that Mesa/Cedar, Modula-3 and Active Oberon were capable of before D came to be, aren't possible in D with its current language design.
- WalterBright 4y ago> we have the problem that language designers are against moving the GC forward This is incorrect. There even was a concurrent collector written for D, but it failed for technical reasons, not anyone blocking it. The idea that I would block any improved GC implementation for D is just silly. D is free and open source and Boost licensed. I couldn't possibly stop anyone from doing a better one. You're free to prove me wrong about what can be done, I would welcome your implementation!
- pjmlp 4y agoPlenty of languages have already proven D wrong, as mentioned on my language list, my contribution isn't required. C# already offers what I care about in managed languages with C and C++ like capabilities. And honestly why would anyone go through the trouble to prove you wrong, if in the end it eventually has the same fate as the concurrent one, that only works in Linux anyway.
- WalterBright 4y agoWe didn't adopt the concurrent one because nobody could figure out how to make it work on platforms other than Linux. Everybody wanted it. I'm curious why you don't use Managed C++ (the one with separate GC pointers)?
- tjoff 4y agoThe GC made sense in comparison to C style memory management. But with with Swift, Rust and modern C++ the argument can be made that GC doesn't bring anything to the table. In the beginning the biggest drawback seemed to be performance, so people have been hell-bent on fixing that for decades now. Completely ignoring that the "don't need to care about memory" mindset is flawed. You always need to think about memory, and if you do you might as well do it yourself. It doesn't take more time to do in the long run and you are forced to design a better system because of it. For scripts it is a really nice have. But for a proper language writing large-scale applications? No thanks.
- zozbot234 4y ago> But with with Swift, Rust and modern C++ the argument can be made that GC doesn't bring anything to the table. GC will always be needed to solve problems dealing with general graphs containing possible cycles. Not coincidentally, this describes many of the GOFAI problems for which GC (in the context of LISP) was first developed.
- ninkendo 4y agoI mean, what you’re saying is probably technically true for very specific problems that are contrived specifically to show shortcomings in refcounting, but in practice I’ve never seen it matter. Weak and unowned pointers are pretty simple to deal with, and I’ve never seen a situation where it’s really confusing whether a pointer should be strong or weak in swift. Everything mostly just works, and if you need to point back to the object that owns you, it’s usually pretty clear by the abstraction you’re building that you need a weak/unowned reference to do it.
- deleted 4y ago[deleted]
- zozbot234 4y ago> and if you need to point back to the object that owns you That's not the interesting case; that is indeed easily addressed by "weak" pointers. What's interesting is the case of a spaghetti reference graph where none of the objects definitely "owns" any other, and even the choice of GC roots might be dynamic.