8 ms·
> You may have read articles and blog posts aiming to convince you that Go is better than Rust, or vice versa. But that really makes no sense; every programming
by IshKebab 3y ago
> You may have read articles and blog posts aiming to convince you that Go is better than Rust, or vice versa. But that really makes no sense; every programming language represents a set of trade-offs. Each language is optimised for different things, so your choice of language should be determined by what suits you and the problems you want to solve with it.
That's sort of true, but I wish people would stop cowardly saying that you can't say that one language is better than another overall. That's clearly not true.
IMO this article is very very long and doesn't really highlight the differences well, which IMO are:
* Go has much faster compile times.
* Rust's tooling is very good but I would still say Go's is better. It has built in fuzzing support! Cross compilation is as simple as setting an environment variable.
* Rust is a little faster, and avoids GC.
* Go's standard library is much more comprehensive than Rust's.
* Go is much easier to learn and to read.
* Rust is a better language if you have learnt it. It has much more powerful features (especially the functional ones) and is more principled. Going back to Go from Rust is frustrating.
* Rust has a much stronger type system and the borrow checker. Both make bugs far less likely.
* Async Rust is probably the worst bit about Rust. Go's goroutines are much easier to use. Though I would say traditional multithreaded code in Rust is pretty easy - it's just that a lot of the ecosystem forces you into async.
- LambdaComplex 3y agoYeah, I really felt like this article had a lot of words and yet didn't actually convey much useful information—nor did it convey any information that hasn't been written about at length elsewhere. I also found this sentence to be confusing: > If you only have time to invest in learning one language well, don’t make your final decision until you’ve used both Go and Rust for a variety of different kinds of programs, large and small. So, if I only have the time to learn one language, I should...use two languages? For multiple projects? But somehow without learning them, because I don't have time?
- rapsey 3y agoIf you are interfacing with other languages or running on mobile (as a library not a full app) Rust is the obvious right choice imo. In other situations the choice is not as clear cut.
- k_bx 3y agoRust is your "last language". It's good for writing Python native modules, PostgreSQL native modules, compiling to WASM, all using the same libraries you love and know already. That is a big deal for me.
- sgt 3y agoCan do the same with C, and it is still being improved. Safety is IMHO a bit overrated.
- pjmlp 3y agoUntil we finally get liability across the industry, then devs will think twice about shipping CVEs into production.
- bombolo 3y agoYeah multiple attempts are done to put liability on open source library developers. Terrible idea.
- pjmlp 3y agoGreat idea, so far computing has been the exception, it is time to join the grow ups in responsibility how software affects the society. Everywhere else people ask for who's responsible when products don't match expectations, or are sold with faulty capabilities, unless the consumer protection laws of the country suck in protecting the citizens.
- threeseed 3y ago> Rust is a little faster, and avoids GC Depending on what you're doing. I am finding that Rust is easily beating all of the non-C languages in terms of full support for the latest performance technologies e.g. io_uring, SIMD (AVX2/AVX512/NEON), DirectStorage, CUDA etc as well as the highest quality wrappers for C/C++ libraries. So for many applications Rust will simply leave Go for dust. In fact for me the only benefits of Go are single binary and startup time. Otherwise I find Rust to be ideal for when I need low level performance. And Scala to be significantly better for backend apps since its faster, has access to more libraries, better concurrency and a stronger type system resulting in much more reliable code.
- ssokolow 3y ago> In fact for me the only benefits of Go are single binary and startup time. I hope you mean "compilation time" or "time to first prototype". My experience has been that, if a Rust binary doesn't start instantly, it's the fault of a specific library, not the language in general. Also, they ARE working on single-binary deployment for Rust... they just have a much more "Take your time and do it right. Don't hack around ecosystem flaws" approach than Go. If you're not cross-compiling/cross-deploying, Rust is already on par with non-cgo Go... you just need to use a musl-libc build target for Linux, specify RUSTFLAGS="-C target-feature=+crt-static" for Windows, etc. to get statically linked libc. (The musl-libc targets are a simple `rustup target add` away if your only C dependency is the libc itself.)
- diarrhea 3y ago> * Rust is a little faster, and avoids GC. I always wondered: how is it not much faster? Dealing with the borrow checker is immense overhead, yet performance gains are low compared to Go. Is Go's GC simply that good? Is Rust's compile-time GC about something other than performance somehow? I realize Go still needs to ship a minimal runtime in its binaries, but don't feel that's a meaningful burden compared to borrow checker fighting.
- amedvednikov 3y agoGC is often faster than ownership. All the extra clones are costly.
- _ahxg 3y agoThat's a fair point, although there is a simple solution in Rust (and other RAII languages) to use heap allocation if what you want is moving big chunks of data (so only the pointer is moved) or in case you really want copies, reference counting (Rc/Arc in Rust).
- thumbuddy 3y agoYou don't have to clone... Really you don't. If you want fast rust code, learning how to avoid that is probably step 1.
- lordnacho 3y agoIt's not just a question of on average how much faster it is, it's a question of whether the distribution of latencies matters.
- antonvs 3y ago> Is Rust's compile-time GC about something other than performance somehow? Predictability and determinism: In some environments, GC pauses are problematic. Modern GCs in Go and Java running on fast enough CPUs can generally keep pause times down below 1 ms, but on a multi-GHz CPU that's multiple million clock cycles - a virtual eternity in some contexts. Memory usage: GCs waste memory in exchange for performance. Go's GC doesn't compact (last I checked), so fragments the heap. Ability to have no runtime: in some environments, the need for a runtime is problematic. That's a big part of why the Linux kernel supports Rust but not Go. All of these issues tend to be more significant in e.g. hard real time contexts, in embedded environments with less powerful processors, etc. Also btw "borrow checker fighting" is not much of an issue for experienced Rust developers. You quickly get used to how to write code to avoid borrow checker issues. And in general, writing code that way tends to be a good thing anyway.
- atmosx 3y ago> Go's goroutines are much easier to use. True. Golang multithreading is easy to reason to about. I had to make some mental gymnastics to write multithreaded scripts in Ruby and Python. The Golang implementation was the easiest by far.
- brabel 3y ago> Rust has a much stronger type system and the borrow checker. Both make bugs far less likely. I really prefer strong type systems over weak ones, but despite that, I always like to point out that there's no evidence that strong type systems cause "bugs to be far less likely". No study I've seen (quite a few) has ever shown that. There's a few bugs that become impossible (in Rust, some kinds of data races for example) but the vast majority of bugs can still occur and in practice, do occur.
- orwin 3y agoThe main advantage to me is more that I don't have to write tests to test type integrity accross functions.
- lelanthran 3y agoI've never found myself doing that in Go.
- orwin 3y agoI was talking about strongly typed languages, which Go is. That's why I'd rather use go than python at my job (not an option though).
- IshKebab 3y agoRust is even more strongly typed than Go, so it reduces the chance of bugs even more. The borrow checker also reduces the chance of bugs. It was originally created just for memory safety, but it turns out that the ownership structures that it enforces are less bug prone. It's quite similar to how using immutable data structures leads to less bug prone code.
- IshKebab 3y ago> No study I've seen (quite a few) has ever shown that. There's a really great one that shows that Typescript or Flow prevents around 15% of Javascript bugs. It would be difficult for a study to show that Rust's strong typing or borrow checker prevents bugs, but anyone who has used Rust extensively knows it to be true. It's similar to Haskell's strong types and immutability preventing bugs. Google "if it compiles it works". I think you could do a study to prove this, but experiments aren't the only way to get knowledge. They are the best when possible but sometimes they are impractical. Programming language studies tend to focus on "get some students to spend a few hours writing code from scratch" tasks which can even lead to conclusions that are the opposite of reality for realistic programming. For example that static types hurt productivity. > the vast majority of bugs can still occur and in practice, do occur. Right, but they are much less likely to occur.
- luuio 3y agoAt least two reasons I'm not choosing Go: - Go (the language) is missing the ability to declare something immutable. I don't mean making fields in a struct private then exposing getters. I mean the equivalent of an immutable reference in Rust or `const ref` in C++. - Go mod and go workspace still can't get a cohesive story together [1]: - - If my module wants to depend on another module in a workspace, `go mod tidy` would freak out. - - If I use replace in my go mod file to point to the other modules in the same workspace, `go mod vendor` will copy these workspace modules to the vendor folder as well. [1] https://github.com/golang/go/issues/50750 https://github.com/golang/go/issues/50750