3 ms·
Ask HN: Rust or Go?
I want to learn another programming language. I have to decide between Rust or Go.
I'm proficient in Java/PHP/JS/Python/C. Between Rust or Go whats the easier language to learn?
- tptacek 5y agoGo is much, much easier to learn than Rust (Rust is pretty easy if you're already a C++ programmer, though). They're both fine languages.
- snider 5y agoRust is more tricky, since it places emphasis on correctness and memory management. Starting with go was far easier for me
- melling 5y agoPlacing emphasis on correctness sounds like a plus. How does Rust do this? Does it only apply to memory management? For added performance I could live without gc, but I still prefer it.
- dnh44 5y ago>How does Rust do this? Does it only apply to memory management? https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html https://doc.rust-lang.org/book/ch04-00-understanding-ownersh... This link explains it pretty clearly with example code (which is easy enough to understand even if you've never seen rust code before).
- melling 5y agoIf correctness only applies to memory management then choosing it’s not a benefit in deciding Go or Rust because Go has garbage collection.
- steveklabnik 5y agoIt applies to everything.
- bitwize 5y agoRust encodes object lifetime into its type system, and enforces constraints on how references are used through the borrow checker. With Rust, you don't need a GC. Object lifetimes (not just memory!) are automatically managed through static lifetime analysis. Time and CPU spent in a tracing GC is simply lost, it's emitted as waste heat. In Rust you can reclaim some of that back, and still use a programming style very similar to a GC'd language. Remember: static beats dynamic, every time. Time spent checking assertions at compile time pays for itself many times over in time spent debugging these same issues at run time. Just as static typing is a huge win over dynamic typing, static lifetime analysis (Rust memory semantics) is a huge win over dynamic lifetime analysis (GC).
- tptacek 5y agoI think it's probably rarely the case that static analysis beats GC, and this "static beats dynamic" rule probably doesn't generalize as well as you think it does.
- HamburgerEmoji 5y agoI really want to answer some other question than the one you asked. But the answer to your question is Go.
- spicyusername 5y agoDepends on where you want to take your career. Rust and Go are different tools that are good at solving different categories of problems. Additionally they are both languages that will provide different lessons about modern programming ergonomics. If you expect your programming career to be solving more high level "enterprise-y" problems like writing APIs, web services, and middleware, learning Go is probably going to be more useful to you. If you think your programming career is going to be more low-level like programming operating systems, libraries, or drivers, learning Rust is probably going to be more valuable to you.
- tptacek 5y agoThere's huge amounts of low-level systems code written in Go; for example, gVisor reimplements most of the Linux kernel in userland. Go is also the dominant language of the container ecosystem. You're unlikely to see Go kernel modules any time soon, so if kernel hacking is where you want to to, Rust is definitely the right way to get there.
- tomohawk 5y agoYou can learn go in a week, and be proficient quickly. You will find you can read pretty much any go code written by anyone. The source to everything is available. Rust is more like c++. It contains not-so-easy concepts dealing with memory that require different approaches. It will take 6 months or more to get there.
- gomes33 5y agoThank you all for your time with this question.