website icon indicating copy to clipboard operation
website copied to clipboard

Explain memory safety more

Open mverleg opened this issue 5 years ago • 1 comments

The main thing that confused me when reading through docs is the memory safety.

It mentions some cool things:

  • There's no garbage collection or reference counting
  • V cleans everything up during compilation
  • If your V program compiles, it's guaranteed that it's going to be leak free

I'm not an expert about this, so I got a bit confused. Rust had to make some substantial language changes compared to most languages to achieve this (and then still has Rc wrapper). And not a lot of other languages have managed.

So how exactly does it work in V? The docs don't mention much in the way of language changes to support this. What's the difference with Go that V can do this and Go can't?

I was going to experiment to figure it out, but ran into problems (can't mutate list arguments, another program failed to compile). So I'll post it here - I bet I'm not the only one interested in info.

mverleg avatar Feb 10 '20 21:02 mverleg

Exactly, seems to me V will have to handle special case after special case in the future, and there won't be an end, if the memory management model does not give a logical memory safety guarantee.

Congyuwang avatar Nov 06 '21 11:11 Congyuwang