Go versus Rust : Which is the better
language to learn between Go and Rust? Which offers the best performance? Which offers the best opportunities?
Which should you learn? We’ll dive into all that and more. First, let me explain how
we’ll be approaching this. First, we’ll look at the
differences in **philosophy and mindset** between each language.
Second, we’ll explore the **features** of both languages and their
relative strengths and weaknesses Third, we’ll examine what the
**statistics** say about the difference between the two languages in terms of
developer experience, attractiveness and salary. And then I’ll tell you what I recommend.
But whatever language you choose, I’ve provided links in the description
to helpful resources for learning them. Let’s dive in What are the differences in
philosophy between the two languages? We have our contenders. In the blue corner, Go’s
friendly gopher. In the.. well, brownish-red corner, Rust’s unofficial mascot, Ferris the crab.
And there you have it already. These logos, names, mascots and even colours tell us a lot about
the differences between the two languages. Let’s start with Go. Go’s name and
logo express speed and efficiency. The three lines make the text look
like two wheels in rapid motion. Go’s mission, as expressed by their brand book, is to:
* Bring order to the complexity * of creating
* and running software at scale. Let’s unpack that. _Creating_ and
_running_ at scale. What does that mean? Go’s goal is to be :
* 1/ simple enough to be used for prototyping and * 2/ efficient enough to be
“The Language of the Cloud”. Go’s [brand book] also says it
wants to be Thoughtful, Simple, Efficient, Reliable, Productive, and Friendly. These values are expressed in the
friendly, cuddly mascot, the Gopher. Rust’s mascot, Ferris,
certainly has a friendly smile. It’s prickly, though.
As is Rust’s logo. Rust’s goal is _not_ to be friendly or simple.
After all… Crabs walk sideways. The best way to explain Rust’s values
is to tell its [origin story] . Graydon Hoare was a programmer at Mozilla.
Coming home one night, he found an out-of-service elevator.
The software had crashed due to a memory error. This goaded Hoare into creating a language
that prevents memory management crashes. Rust is designed to be **solid**, like a crab.
And the name “Rust” also conveys this. It doesn’t refer to the oxidation of iron
but to an exceedingly resilient [fungi]. ## A closer look at the features
What are the differences and common strengths between Go and Rust’s features? Go and Rust Both focus on:
* memory management, * concurrency and
* performance. However, their approach is _very_ different. This, too, reflects their philosophy.
Allow me to demonstrate. First, let’s talk about memory management.
Go has a helpful **garbage collector** that tries to clean up unused memory references for you.
Rust, on the other hand, enforces the concept of ownership and borrowing to
prevent you from coding memory bugs. Go helps you. Rust forces
you to do the right thing. Second, concurrency and multithreading. In a similar fashion, Go
provides easy-to-use Goroutines. These are lightweight threads that
allow you to write concurrent code without worrying about thread management.
Rust, on the other hand, uses system threads. Here, Rust’s ownership concept helps prevent
thread-locking errors and data races. Again, Go makes your life easier.
Rust teaches you to do the right thing. Third, performance.
Go has a small memory footprint and is optimised for modern multi-core processors.
Its syntax is simple and concise. This makes it easy to learn
and start working with. Go does the right thing for you by default. Rust provides something
called Zero-Cost Abstractions. There is no “magic”. The code you write faithfully reflects
the code that the compiler produces. This means less runtime overhead, which helps
you build high-performance applications. In short, Go hides the complexity for you.
Rust helps you understand it by exposing it. Now… what do developers think
of the languages? Let’s look at the statistics provided by the
Stack Overflow Developer survey. Go and Rust have similar popularity levels,
at about 13% overall among all developers. Developer _opinions_ of the
languages, however, show a difference. 84% of the developers who used Rust last
year want to use it again this year. For Go, that number is lower at 60%.
The survey also shows 30% of those who did not work with Rust last year want to work with it.
That number is 20% for Go. In short, Rust is more desirable
among developers than Go. But what about on the job market? Finally, if we look at the reported salaries,
developers working in both languages report a mean yearly salary of 90 thousand dollars.
Go developers are slightly above, and Rust developers are slightly below. A word of caution here: these
values are reported globally. The situation in your local job market will vary. After having explored the philosophies, features and statistics of Go and
Rust, what are my recommendations? Let’s recap. Go is designed to be simple and friendly. Rust
is designed to be as hard as possible to break. They’re two teachers.
One is encouraging and warm, a kindergarten teacher. The other is
demanding and harsh, a drill sergeant. One makes life easier for you. The other
makes you work harder for your own good. Go and Rust also have different primary
use cases. Go is meant for the cloud, for server applications. Rust is meant
for low-level or embedded applications. Which is the best for you?
Well, that will depend on two things: who you are and what you are trying to build.
Go is easier to pick up. Rust requires more effort but provides greater rewards in the long run.
What kind of teacher do you need? Do you need encouragement? Or are you building
for the cloud? I recommend Go. Do you need a demanding teacher who will
push you forward? Do you want to build performance-intensive or low-level
embedded software? I recommend Rust. Whatever language you choose, if you’re looking
to pick up the basics, I recommend you go to [Exercism] which gives you simple challenges
to help you learn. And if you’re looking for projects to help you dive deep while learning
how reference technologies like Git, Docker or HTTP servers work, I recommend [CodeCrafters].
I’ve provided links for both in the description. And whatever path you choose,
I’ll see you in the next video.