HACKER Q&A
📣 poletopole

Is Rust worth it compared to Golang?


I've been studying Rust rigorously for about two months now and I'm almost done with the community book on Rust. However, I still feel like I don't have a strong grasp on Rust. Rust seems to have many edge cases and I like that Rust is being transparent about them, but at the same time it's very demotivating and burdensome. I chose Rust over Golang for a variety of reasons, primarily it's support for WASM and lack of a GC, but with each passing day Golang is looking better and better, ha.

For those whom have experience in both Rust and Golang: how long did it take to become proficient in Rust compared to Golang and which did you learn to appreciate over time over the other, if at all?


  👤 gas9S9zw3P9c Accepted Answer ✓
I used to write everything in Golang, but recently ported many things to Rust, so I feel like I have a good idea here. I'd consider myself quite proficient in both. I see Go and Rust as almost opposites.

Go is "easy" and makes you immediately productive. Like, productive on the first day. It's a great language for that reason. Compilers don't complain, no complicated generics, easy concurrency, loose interfaces, GC, etc. But this comes at a cost - it's easy to write sloppy code. Because of its flexibility, my code often suffered from concurrency bugs (don't get me started on deadlock debugging), bad abstractions, or performance issues. I felt like I was productive, but I often had to re-factor my codebases multiple times because of these issues.

Rust is the opposite. I didn't feel immediate productive, and the fight with the compiler was tough at times. But most of the time, the compiler was right and I was wrong. This typically resulted in "good" code once it compiled and I rarely had to go back and refactor my code. And of course there were no pesky concurrency bugs due to the compiler checks.

These days, I would choose Rust over go for my own projects. If I consider the time spent on debugging bugs in Go, I consider myself more productive in Rust, even if the initial code takes longer to write. However, if I was leading an engineering team, I would consider Go instead. It's much easier to pick up, and it's easier to read someone else's Go code. Reading someone else's Rust code can be hard.


👤 gorgeous_france
I have little experience in Golang apart from reading the Tour of Go and writing toy programs, but I have more experience in Rust. In my opinion, Rust is definitely worth it, even if at the end of the day I work with other languages professionaly, its principles (ownership, borrowing, safe concurrency) really helped me to improve myself. I started to be productive with it by actually writing code, I have read the book during 3 weeks but I learned much more quickly by confronting myself directly to the compiler after. I also became productive with the right tools (vscode + rust analyzer, rust cookbook, rust by examples), the right crates (regex, lazy_static, anyhow, actix, reqwest ...) and pragmatic principles (sometimes boxing, cloning or using refcell when necessary, in non critical code). As always, use the right tool for the right job, there is a learning curve and more cognitive overhead but I really appreciate working in Rust.

👤 satvikpendem
The inclusion of algebraic data types, coming from someone who uses TypeScript on the frontend and functional languages on the backend, already makes Rust the best choice for me, and conversely makes Go a non-starter. Rust definitely takes longer but I've been learning it through the Book and also by doing the exercises on Exercism [0]. The exercises really help in understanding, as for example, I didn't understand borrowing too well until doing the prime number generator problem, using a sieve of Eratosthenes which can use a mutable vector of previous primes.

[0] https://exercism.io/tracks/rust


👤 skymuse
1) How long did it take to become proficient in Rust compared to Golang?

A long time, probably a couple months to get productive, and a couple more to learn the foundation pretty well. And this is with a steady supply of side projects to help me solidify my learnings.

2) Which did you learn to appreciate over time over the other, if at all?

I chose Rust over Go because for my side projects (at the time) Rust was faster and had a better package manager. Since most of my side projects are command line tools, Rust fit in quite well in this domain.

A side note. I think it's more helpful to choose a language based on how well it solves your problems rather than its amount of shortcomings. If Go has the right packages and tools, go with that. If Rust does, choose that one instead. For me, the ability to quickly pick up the best language for the job is IMO more valuable than picking a language with less 'edge cases'.


👤 Dowwie
If I were to read a book about rebuilding a car engine, I wouldn't feel comfortable with actually doing so. Experience remains necessary to reach that comfort level.

Define concrete goals with learning any language and that will help you measure progress. Rust is a massive language with many features that aren't required learning in order to accomplish many types of development. Over time, you'll probably learn them out of curiosity and continued personal development. You'll also return to code that you seek to optimize.


👤 jameshiew
I am probably at a similar stage to you, investing seriously in learning Rust in the past month or so. Coming from having used Go as my “main” language for almost a couple of years, already I can tell it is going to be a longer journey to become as proficient with Rust.

The biggest thing I am missing right now from Go is the fast compile times, something I rarely had to think about before. In some of the small Rust projects I’ve tried out, compilation takes minutes on a clean run or after having updated dependencies. When you’re checking out a lot of different Github projects, or experimenting with different crates, it really adds up.

I’ve tried out Rust’s equivalent of channels (the `std::sync::mpsc` module - https://doc.rust-lang.org/std/sync/mpsc/) and it feels clunky by comparison to Go. Spawning threads in Rust via a `thread::spawn()` call feels archaic compared to `go func` (putting aside that threads aren’t exactly equivalent to goroutines, you might generally use them in the same way). I’d actually hope Rust could introduce first class language constructs for concurrency like Go has, at some point.

There are some other Go things like implicit interfaces I am learning to get used to without, but I am really liking Rust’s concept of ownership and having proper enum types/pattern matching is a breath of fresh air. I probably appreciate Go more now for what it is - a straightforward, performant language with very good devex.


👤 vibesngrooves
Disclaimer: I am neither proficient in Rust nor Golang - rather a hobbyist using them in non-professional contexts. I have a bit more programming experience with Golang than Rust (just finished the Rust book).

I think you should identify which ecosystem and toolset you like working with. I'm leaning towards Golang for web development and web/system protocols. I chose to explore Rust as an intro to embedded development and audio/dsp programming - an alternative to learning C++. Rust seems great as a well-absracted, yet powerful and performant low-level programming language. I feel much more comfortable writing code with the Golang toolchain, but I feel much more confident with my end-result thanks to the strictness of the Rust compiler. I appreciate the specifics Golang conventions and opinions as well as the openness/comprehensiveness of the Rust language and community - not saying there aren't conventions and idioms, rather there are so many options and approaches to implementation within the language. YMMV, figure out what feels more natural to your process, style, and application context.


👤 bennyz
I am actually doing the opposite transition now, I have been learning Go and using it a bit at work and on hobby projects for a while. I recently started working through the Rust book and I find it much more appealing at this point, and I am seriously considering converting my personal project to Rust to get some hands-on experience.