3 ms·
> It's garbage-collected and does subscript checking, so you're covered on memory safety. Go is only memory safe in sequential code, or concurrent code that ne
by zozbot234 6y ago
> It's garbage-collected and does subscript checking, so you're covered on memory safety.
Go is only memory safe in sequential code, or concurrent code that never accesses shared data from multiple threads. It does not protect against data races as Rust does.
- erik_seaberg 6y agoGo needs synchronized and immutable collections, or at least to start trusting users to roll their own. Concurrent slice appends will overwrite each other unpredictably, and concurrent map writes and reads can panic.
- throwaway894345 6y agoI’ve always found it better to avoid concurrent mutability as much as possible. That has worked very well for me, and I don’t generally have the negative experiences other Go programmers have complained about. Not as nice as static type system guarantees, but it’s available today.
- tapirl 6y agoIt is not always feasible. Even if sometimes it is possible, it isn't without any cost.
- throwaway894345 6y agoYeah, you’re absolutely right that there is always some situation where some amount of shared mutable state is necessary, but there’s still a lot of fat to trim in most cases.
- tapirl 6y agoWhat you say is prone to make people who are not familiar with Go think there will not a safe way to accesses shared data from multiple threads in Go. This is not the truth. In Go, multiple threads could access shared data safely. When the code is implemented correctly (which is easy), these threads will never access the shared data at the same time. Rust just makes this guarantee in the syntax level (at compiling time), which is different from most other languages, but with the cost of slow code complication, rigid, and not easy to learn. BTW, what you say shows you don't understand basic Go knowledge at all.
- pjmlp 6y agoRust only protects against thread based data races, it does nothing to prevent data races across OS IPC with mmap or shmem segments.