Ask HN: Golang vs. Rust vs. Swift
I'm interested in the modern, more memory-safe languages that were built to replace the use of C++ in various places.
I wondered what people may know of each one? Below is my limited knowledge.
golang Invented for back-end web development, by Ken Thompson and two others, backed by largely open-source corporation. Has pointers, no classes/inheritance, has own compiler, as well as gcc support. Wide OS and architecture portability. Outline of original design explained: https://www.youtube.com/watch?v=sln-gJaURzk
rust Invented for cross-platform desktop app, backed by fully open source organisation. Strongly tied to x86, incompatible with other architectures.
swift Invented for native apps on client devices, backed by mostly closed source corporation (but Apple gifted clang to the BSD world). Has some level of Linux support...?
11 comments
[ 0.20 ms ] story [ 24.7 ms ] threadGo is what it bills itself as, but I find it an eyesore to read and parse.
Rust feels to me like the best middle ground between the two, with an amazing ability to _force_ you to account for errors in a way the other two don't quite achieve. You'll spend eons on compile times, though.
First of all, you have not explained what the problem or issue is that you want to solve. Will you be working with bare metal? With networking? With native apps on iOS? So you should determine what it is that you actually would like to do, and then find a good fit from there.
All I can say is I like working with Go and Rust for different reasons. Rust has a slightly different paradigm, but I think people exaggerate the learning curve simply because it's just not what they're used to.
If you can't decide, then write a toy application in all three languages! This will give you a better insight into working with that language and its ecosystem. I.e. I still dislike how Go handles packages, but it's tolerable.
There are a lot of things to like and dislike about each language. I use Go at my day job and Rust for most side projects, and I feel I need to be careful with both. Go makes concurrency easy, which also makes it easy to make mistakes. Rust makes concurrency safe, which also makes it hard to optimize. I'm faster with Go in prototyping, but more confident with Rust not breaking at launch.
Learn them all. If you're an experienced dev, it'll take you less than a week to be comfortable with Go if you've done any concurrency, two weeks for Swift, and about the same for Rust (maybe more if you have little to no FP experience).
This is incorrect.
Once you hit a wall with GC or want a good type system, then you can look at Rust. Note that rust is a big language with lots of concept from c++ and ml family languages. so you might need some time to get used to it.
I have no experience with swift, so I cannot say anything.
So basically use Rust, wherever you need C or C++ performances and you cannot afford to have a bug. So critical piece of the infrastructure, OS, critical embedded systems... It is probably easier to write correct concurrent Rust than C.
The fact that you can easily create static binaries that will run on Linux or Windows is nice, but I don't think this is the biggest differentiator.