7 ms·
> All this complexity is there for a reason — we don’t know how to create a simpler memory safe low-level language. But not every task requires a low-level lang
by amelius 6y ago
> All this complexity is there for a reason — we don’t know how to create a simpler memory safe low-level language. But not every task requires a low-level language to solve it.
And what most people forget is that complexity works against safety: the less the programmer is distracted by other issues (e.g. memory management), the more they can focus on security.
- elteto 6y agoI think you need to develop this point a bit more: at face value it looks (to me) like you are saying: "The borrow checker is more complex than simple malloc/free calls therefore it is less safe." Which is clearly wrong.
- amelius 6y agoBut you can also compare it to a GC'd language, which from this viewpoint is safer. A GC'd language, however, is usually not preferred for systems work. However, most applications don't fall in that category.
- muldvarp 6y agoI don't think GC'ed languages are actually safer from a memory safety viewpoint, they're just easier to use.
- dnautics 6y agoit depends on the GC'd language. You absolutely cannot do use-after-free, double-free, or stack overflow in erlang (unless you FFI into C). You can OOM erlang (but you can OOM Rust, too).
- pjmlp 6y agoMostly due to cargo cult and politics than anything else.
- gameswithgo 6y agoCan you elaborate more on what you mean, and how you know it to be true? Taking the argument in reverse we might expect programming with just nand gates to be the most safe approach. Do you mean, all else equal, that it works against safety?
- amelius 6y agoWhat I mean is that the less the programmer is distracted by other issues (e.g. memory management), the more they can focus on security. (I added it to my comment).
- MaxBarraclough 6y ago> complexity works against safety. Not always. Java programs have fewer memory-management issues than C programs, and they tend to be less severe.
- ncmncm 6y agoThe evidence does not support this assertion. Certainly C programs have a poor record of memory usage errors, but the habit of Java programs routinely needing orders of magnitude more memory to do similar work is well known. Memory leaks are as easy under GC as in C.
- whateveracct 6y ago> Memory leaks are as easy under GC as in C. This is just untrue. And no, allocating a bunch of short-lived objects isn't leaked memory. Neither is the overhead of the GC.
- ncmncm 6y agoIt is very easy to leak Java objects, simply by failing to remove them from containers when their usefulness has ended. And all the memory not yet collected has effectively leaked until the next reclaim cycle, which might never happen. So, memory leaks are as easy under GC as in C.
- whateveracct 6y agoNeither of those is really a memory leak imo. The first one is a "retainer" leak in a way, but in your average Java use-case (e.g. an HTTP request handler) you have to make a pretty uncommon mistake for any allocation to outlive its usefulness and grow unbounded without being collected. Whereas in C you literally have to call free manually. That is way more error-prone than the ways you leak memory in Java. Once again, using too much memory or the GC running "eventually" are not leaks they are just not optimized memory management (a heavily fetishized thing in our profession.)
- atoav 6y agoNot checking things will always be less complex than carrying out a metric ton of checks. But if checks means "pass or halt" then I don't see how it would impact safety negatively..? Wouldn't no checks equal less recognized bugs and therefore in turn lead to less secure code?