Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> It's absolutely possible to bork ownership and have multiple thread trample a struct.

This is specifically the one place where go is not memory safe IMO.

> It's absolutely possible to compute wrong pointer offsets.

In Go? Without the `unsafe` package (at which point you are explicitly opting out)? How? There's no pointer offset in the first place.

> It's absolutely possible to dereference nil.

Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

It's (really the lack of non-nil types) is one of many reasons why go doesn't produce as reliable software as rust, but it's not a memory safety issue.

> It's absolutely possible to reinterpret memory the wrong way.

Again, without the unsafe package? How?



My Go is a bit rusty (pun intended), so I may have misremembered, especially with the pointer offsets. (just googled it, I did remember it, sorry for the confusion).

>> It's absolutely possible to reinterpret memory the wrong way. > Again, without the unsafe package? How?

Again my go is rusty, but I saw quite a bit of shenanigans in go with pointer casting from what's essentially a collection of void*. However perhaps those casts blow up at runtime? I'm too used to rust where it's explicit where it'll blow up.

>> It's absolutely possible to dereference nil. > Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

Agreed. I conflated "safety" and "robustness" here. The existence of nil is a thorn in the language.

Thanks for the corrections!



Right, that's the first category, "It's absolutely possible to bork ownership and have multiple thread trample a struct" resulting in undefined behavior.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: