Ask HN: Rust vs. Golang

1 points by the_dripper ↗ HN
I am conflicted.

I want to learn an new Programming language, and eventually build a project with it. But Im not sure what language i should choose for that. I have already been programming a little bit of Golang, which I really like, but Rust also interests me.

So I have to ask, what pros and cons there are to both languages. I don't know if I should learn both of them, because I think it might be too difficult.

9 comments

[ 2.9 ms ] story [ 40.8 ms ] thread
learn both, it would make you a better programmer.
Rust:

- more versatile (both PRO and CON)

- better error handling (IMHO)

- more powerfull type system (i.e. more to learn but also more you can use to your advantage) (both PRO and CON)

- has good support for more different forms of concurrency&parallelism then go (your can use it better as a tool to play around with that forms) (both PRO and CON)

- LLVM backed (allowing cross language optimizations, I don't remember if they are currently on the way of being implemented in llvm or already implemented) (both PRO and CON)

Go:

- simple syntax

- mainly one form of concurrency&parallelism but backed into the language and all libs use that one (also very neat if you want to look into certain paradigm which are heavily based on this paradigm)

- as far as I know pretty solid "first party" library for common server middle ware task

- maybe some other things

Also in rust you have more control over memory, but for many use cases this doesn't matter that much until you scale up to a high degree, then there are some differences about package management but I can't judge those as I'm not experienced enough with using third party go libraries.

Another thing I haven't list is the rust borrow checker, it can be a bit of a handful to learn but it tends to force you to write better structured code so I think it's worthwhile even if you never again use rust later one.

Generally learning more programming languages (or more precise the concepts behind them and the concepts frequently used in libraries of them) can make you a much better programmer. And with learning I don't mean "going to be a experienced ... programmer" but just understanding the concepts good enough so that you can use them and recognize them when they appear in a different language with different syntax and naming.

If your final goal is building something today which can be used in production especially networking, server or web api go for golang as it’s mature, fast and performant with a very good and large eco-system of libraries. So if your systems programming involves network, servers or web API go with golang.

If you need to experiment with a new language and build something may be a new OS library encapsulating it’s C libraries around safety guarantees provided by borrow checker syntax try Rust. Also Rust with it’s rich type system and support of generics give you nice development experience similar to C++.

Rust still has a long way to go before it becomes 10% of what’s written in C++. But given it’s support from Microsoft and popularity among some programmer community, it might become popular in coming 10 years. So it will still be nice to learn for future. Just remember Rust has a large syntax area, expressive type system and steep learning curve especially with borrow checker syntax. So be prepared to spend 2x-3x developtment time compared to golang if doing systems programming where golang is strong like networking and servers, even though you will hear from Rust evangelist it won’t, but given current eco-system it will take time.

Golang has become old boring technology which just works and highly productive.

So given small syntax area and opinionated design like C, you will either like golang or hate it. People who tend towards Rust are in the opposing camp of golang.

Golang hit 1.0 in 2012. Rust hit 1.0 in 2015. Rust is only 3 years behind golang in maturity.
Golang is widely adopted as systems programming language for servers (e.g. Traefik, NATS, Caddy and many many more), database (e.g. yugabyte, cockroachdb etc.), web applications (e.g. gitea), docker, kubernetes (k8s), LXD, nomad, consul, etcd etc. and this is just tip on the iceberg. Golang has become very important language for internet related programming and managing container and serverless infrastructure.

Rust is used only in some part of it's core project Mozilla browser which still primarily a C++ application. Also Rust community is slowly building some software in it and may have some internal applications within some companies, but there is nothing substantial or crucial yet.

So Rust has a mountain of 10-15 years to climb before it comes close to golang eco-system for systems programming tasks especially servers and network related.

Rust might be closer to work as wrapper around C/C++ code in short term to give a start but given it's complex syntax, type system and borrow checker syntax it will still take sometime.

Again since golang is highly opinionated it might not suite everyone so it is still nice to see a parallel eco-system around other language like Rust. This will keep golang on it's toes to improve continuously.

You are missing a lot of places Rust is used in a “substantial or crucial” way. For example, the core of AWS Lambda and Fargate are both Rust these days.

It is true that there is more Go usage than Rust. But there’s a lot more serious Rust usage than you’re implying.

There are some uses of Rust in some companies but nothing really significant or ground breaking yet, and not to an extent as important as golang and Swift. Rust can not compare with C/C++ as most of the important crates in Rust still depend on underlying C/C++ library and will continue in foreseeable future, meaning those libraries still needs to be maintained in C/C++.

I do not have access to open source code of fargate or AWS Lambda written in Rust to see the extent of it’s use.

Having seen kubernetes (k8s) in golang and many of the CNCF softwares using golang, Rust is still a fringe language and will need another 10-15 years to reach parity.

Rust has yet to prove anything critical for internet or general computing infrastructure. Still waiting when Mozilla browsers C++ code will be replaced by Rust, given it’s the reason it was created.

> I want to learn an new Programming language, and eventually build a project with it.

Which part is more important to you?

  I want to learn an new Programming language => Rust
  build a project with it => Go.
As a language Go is not very large or interesting, introducing a couple unique ways of doing things. This let's you pick it up quickly and get going. Rust is far more interesting a language to learn but you will spend much more time investing in it.

> learn both of them, because I think it might be too difficult

If you're concerned about difficulty, consider learning Go first. Learning Rust is likely about as hard as learning both. Learning both takes longer but the Go part is not nearly as difficult (until you get deep into Go which isn't often needed).

Go and Rust have different use cases and have different learning curves. The first question you want to ask yourself is, "What do you I want to build?" Go is good for CLI-based programs and server work. Rust is more low-level and can be used to build, say, operating systems. It depends on your goals.

Now, if you don't have any in mind, then I suggest Go because it's easier to learn and you can still be pretty productive in it.