4 ms·
unless it's reassigned Well, sure. And that's true of C as well. The question is what happens when that memory gets reused.
by cperciva 15y ago
unless it's reassigned
Well, sure. And that's true of C as well. The question is what happens when that memory gets reused.
- barrkel 15y agoI don't know if you're being deliberately obtuse. At the semantic level of a memory safe language, there never is any memory reuse, because memory isn't a resource like that. It is impossible to observe memory being reused from within the language. In fact, you could use that as a kind of definition of memory safety. It cuts off a whole kind of memory corruption bug, makes it impossible (aside from bugs in the language and / or runtime, of course). I'm just going to have to throw up my hands here. The masses on HN are apparently proudly ignorant, and unwilling to learn even the slightest thing before wading in.
- cperciva 15y agoWhat you're talking about is the benefits of garbage collection -- the fact that you can't free memory until nobody has a reference to it any more. That's completely different from type safety.
- barrkel 15y agoColin, it's embarrassing at this point, it really is. I'd have hoped, with your background, that you'd know better. Memory safety is not dependent on having a GC - if you have an appropriate runtime, a smart enough type system, or a simple enough language semantics.
- cperciva 15y agoOk, enlighten me: Assuming you don't have an infinite amount of RAM how do you avoid running out of memory without doing at least one of garbage collection or explicit memory deallocation?
- kenjackson 15y agoThat's completely different from type safety. It's not completely different from type safety. You're right, they're not the same thing, but GCs prevent a common form of type safety violation. With that said there are other techniques that exist that are orthogonal to GC. At the same time there are problems, like lack of bounds checking, which can result in type safety issues. My point isn't that you need a GC per se, but you do need memory safety. GCs happen to be one of the most prevalent ways to achieve it. Someone else in this thread noted that they build a complete runtime that guaratees memory safety and requires their devs to code against that runtime. That's fine too (although I think a lot less common than that poster might lead one to believe). It's almost like the memory safe subset of other popular existing runtimes.