3 ms·
> Rust has `unsafe` all over the place; it's no more safe if you use that keyword to do the same things that are done in C++. Yes, it is, because the language
by pcwalton 8y ago
> Rust has `unsafe` all over the place; it's no more safe if you use that keyword to do the same things that are done in C++.
Yes, it is, because the language has the concept of safe code to begin with. The problem with C++ is that all C++ code could potentially be unsafe.
> Get more compiler people on Go and it will be even faster than it is now (really fast), and Go is written in Go so there's no reliance on C++, unlike Rust.
This is a very confused comment. Rust is also written in Rust. If you're thinking of LLVM, sure, the Rust compiler uses that, but LLVM is nowhere to be found in products written in Rust that are shipped to users. What matters is how safe the runtime is, and there's no real difference between Go and Rust in this regard. Go might theoretically have some kind of edge over Rust in safety in that it calls syscalls directly instead of going through libc, but I highly doubt it matters in practice, because (a) the libc wrappers are a drop in the bucket compared to the complexity of the kernel; (b) Go only does that on Linux these days anyhow.
- naikrovek 8y agoI thought Rust was written in C++, apologies.
- piano 8y agoYup, and besides, Go has the unsafe (https://golang.org/pkg/unsafe/ https://golang.org/pkg/unsafe/) package, which allows for basically the same sort of unsafety as Rust's unsafe. In fact, I would say Rust is typically more safe than Go, because in Rust you can mark any code as unsafe, it doesn't necessarily have to involve unsafe pointers. For example in Rust FFI functions are typically marked unsafe even if they don't involve pointers. There's no way to do that in Go. Another example is strings: Rust ensures that strings are always valid UTF-8 by marking any function that could break that as unsafe. OTOH in Go you strings can contain invalid UTF-8 if I recall correctly.