Hacker News new | ask | show | jobs
by c_crank 1095 days ago
Rust doesn't guarantee memory safety.

I think anything that can generate a trivial hello world program that doesn't leak memory is better than V.

2 comments

Besides the attempted slap on V coming from "out of left field", in regards to what the above commenter was talking about, V doesn't leak memory like that. V, since becoming beta (last year), uses an optional GC and does flexible memory management[1]. Giving users choices, somewhat like D and Nim do.

It provides 4 choices: default optional GC (that can be turned off), autofree (either alone or with GC), arena allocation (-prealloc), or manual memory management (-gc none). This flexibility has already been proven, like with their Vinix OS project[2].

Lastly, for developing languages going through alpha and beta phases, think that people should acknowledge how the process works and update their information. Rust or Nim, for example, aren't the same language they were 5 years ago or when still in beta.

[1]: https://github.com/vlang/v/blob/master/doc/docs.md#memory-ma... (4 ways to manage memory in V)

[2]: https://github.com/vlang/vinix

If you don't use `unsafe` then it guarantees it barring compiler mistakes. The compiler has had issues with memory safety before, they were found, and they were fixed. There might be some left lurking, but they are extremely unlikely since people are using it in production and haven't seen anything weird.

If you use `unsafe` you have to make sure of it yourself, but you can easily grep for this keyword and see where the monsters lurk.

The issue is that any Rust code is going to be targeted at performance processing (since otherwise you would write it in a higher level language). And for performance processing, you need to use unsafe (because at some point, the most efficient thing is getting or setting data at a certain memory address without anything extra). Look at any big Rust project, like Amazon Firecracker, and its littered with unsafes.
You really don't, I worked on a Rust project:

https://github.com/ujh/iomrascalai

it doesn't need unsafe code despite being performance-optimized

If you use any language with garbage collection then you won't have memory safety problems (barring unusual corner cases). That is an actual guarantee of memory safety.