4 ms·
I wrote all my code in Pascal to have fast compilation With reference counted strings/arrays, it has solved almost all memory safety issues for me.
by benibela 5y ago
I wrote all my code in Pascal to have fast compilation
With reference counted strings/arrays, it has solved almost all memory safety issues for me.
- formerly_proven 5y agoMemory safety is easy if you use GC (so don't have to define lifetimes) and mandatory bounds checking (unless compiler/JIT can convince itself that it is not necessary). Arguably these tradeoffs are the correct choice for a large majority of all applications — developers agree, looking at the popularity of Python, Java, .NET, Go, PHP, Perl, ...
- BenFrantzDale 5y agoThe biggest leak I’ve seen was in the JavaScript (qml) side of a C++/qml app. You can still leak in GC languages by inadvertently holding on to things you are done with. The GC encourages you to not think about it, which is a problem.
- aww_dang 5y agoAgreed. At a certain point thinking about garbage collection becomes more burdensome than just handling allocation explicitly.
- benibela 5y agoThere reference counting has an advantage of being deterministic, so it is easier to reason about than full garbage collection
- valenterry 5y agoI disagree. Just because there is a GC, it doesn't mean one does not have to be aware of the existence of memory. OOM errors are thing even without leaks in GC languages. Besides, leaks are only a small part of memory safety anyways. And I'm not surprised that you find the biggest leak in Javascript, the language that probably the biggest percentage of amateur/inexperienced developers are working in. (which is not generally a bad thing, but increases the chance for these bugs)
- formerly_proven 5y agoI don't consider memory leaks a memory safety issue since all they do use use up memory and cause failing allocations, which has to be handled one way or another regardless whenever you use dynamic memory.