DEV Community

Discussion on: Golang or Rust, that is the question.

Collapse
 
asaaki profile image
Christoph Grabo • Edited

I looked at Go and to be honest, I never really liked it.

Coming from Ruby (and other dynamic languages), experimenting with Elixir, and then discovering Rust I don't think Go has anything to offer to me.
I know that Go wants to be a pretty boring language, but that also means to not have things which makes me considering to jump from dynamic to static typing.

No generics? Why?

Interfaces? What is that even for a concept in Go? Rust's trait/impl patterns make it more obvious to me, that something relates to each other, in Go I have to connect the dots myself (or let the compiler yell at me).

GC? I have that in Ruby and JavaScript already, no need to switch then. (And if you care and need raw speed with predictable throughput, you maybe do not want GC anyway.)

And some of these syntactical patterns. if err != nil or maps (m = make(map[string]int)). Someone said they get headaches when looking at Rust code, I have the same but for Go. 🤷🏻‍♂️

Also (compiler) error messages. Not great when it comes to Go. While Rust being harder to learn, the messages are extremely helpful there, and the developers try to improve them constantly.

Go also repeated still some mistakes of the past; for example the unicode string story in Rust is so complex for a reason, not because of the language, but because strings are complicated. And this is true for other areas where you think Rust makes it too hard on you. Go (and most languages to be fair here) do not really care about that.

Though Go has goroutines and channels, you still have to be careful when programming concurrent stuff. Have read some stories about how easily you can shoot your feet when not paying attention.

The dreaded null pointers are still there, because Go has nil, and it is equally "broken" as I know already from the dynamic languages. (Rust avoids this problem with specific types like Option and Result, so you also have to handle the fallible cases, but more explicitly, on the type level, no random "nil" or "null" pops up where you wouldn't expect it.)

I could dig up more weirdness about Go. And it is just my opinion. But even though Go and Rust are both pretty young languages (initially created around the same time), Go overall feels like an old language, as if it was created in the 90s.

Don't get me wrong, Rust is not a perfect language. And it has its own quirks and weirdnesses. While some of them will never change, others are constantly fixed and changed, and comparatively fast. (A release cycle of 6 weeks might help here to quickly move forward.)

Because Golang […] seems not [to be] the language that is needed in most business projects in the future.

This is an interesting statement. What do you mean? In my bubble I still see a lot of Go. For example if you work in DevOps and/or use containerization (Docker) + orchestration (Kubernetes, terraform), you cannot really work around Go that much, as most of the foundation was built with it.

Also I've seen people in companies redoing some JavaScript stuff in Go. Probably hoping to get more out of it, though the wins might not be as much as anticipated.

As far as I can see, Go is competing mostly in the web/networking domain. And there you find mostly JavaScript, Ruby, Python, or other usually dynamically typed languages, which slowly over time get some kind of stronger type system (gradual, optional, or like via TypeScript), as well as JIT and other performance improvements. And plain (request) performance/speed is not always the primary goal. In businesses you make trade-offs on so many levels, even if Go would be appealing, there might be still reasons not to use or switch to it.

The last reason also applies to Rust, too, of course. But I currently see some niches, where it shines, my current focus area being embedded/IoT. And for unknown reaons the blockchain folks seem to love Rust as well. 🤷🏻‍♂️

Will Rust overtake Golang?

I don't think so, they operate in different areas most of the time. People want to see them as direct competitors, but they're really not. (Usually Rust is seen more in competition with C/C++.)

And no matter what my personal preferences are, language plurality is better than this One True Language. Which will never be a thing.

So, sorry for my ranty response. Definitely make your own picture of the story.

In the end: learn both if you want. Use both where you feel they are best suited. And don't listen to surveys or us! 😅

Collapse
 
rubberduck profile image
Christopher McClellan

The blockchain folks use Rust because they can’t afford security issues resulting from memory mgmt bugs, alá buffer overruns.

Collapse
 
devimposter1 profile image
devimposter

"And some of these syntactical patterns. if err != nil or maps (m = make(map[string]int)). Someone said they get headaches when looking at Rust code, I have the same but for Go. "
Total agreement here...