Hi friends, my name is Tress and this is no boilerplate focusing on fast technical videos.
This is my guide on how to learn Rust and is the way I teach it to my Patreons in our mentoring sessions.
I have a lot of tips on how to get up to speed fast and will start with the primary sources.
Everything you see in this video from the script to the images are part of a
markdown document available on GitHub under a public domain license.
Rust isn't difficult, it's unfamiliar.
This is the first lesson.
You may have noticed that my videos are mostly hyped by design.
Most comments on my videos are by total rust to newbies.
Some are even new to programming and yet are so excited by what they see.
If you don't yet understand Rust and someone explains it clearly as I try to, it seems like magic.
Rust is the 19th most popular language according to GitHub projects and Stack Overflow tags but the scale is not linear.
There is a lot of work to do if it is not to suffer the same fate as Haskell and Common Lisp.
I want Rust to achieve escape velocity.
Back in 2020, I crashed out of learning Rust twice.
First time due to multiple string types, Haskell's biggest mistake made again, I thought to myself, and the second due to lifetimes.
At the time, I had a great mentor, shout out to Alex, who picked me up and helped me back on the path.
Most people don't have this luxury.
They need the excitement that I try to help with in my hype videos to break through.
I will eventually run out of hype topics and move on to the first,
there's a few million developers I want to send to rustup.rs.
If you're on Mac or Linux or WSL, run this command in the terminal.
If you're on Windows and can't run WSL, then download and run the installer, probably the 64-bit version.
Linux is the native operating system of the Internet, and I would recommend that Windows users install Microsoft's Windows Subsystem for Linux.
Linux, WSL, to get access to this incredible world.
Next, you need the core triumvirate that is required learning for my students.
The three pillars of my recommended syllabus are one, the Rust programming language book, which from now on we will just call the book.
Two, Rust by example, excellent supplementary reading, and three, rustlings and interactive code cat assist on one of the best I've ever used.
Though there are many other great ways to learn Rust,
I recommend starting with these three because they are so tightly bound together, in a way you might have missed.
Starting with Rustlings, it's written in almost the same order as the book.
They are made to be consumed together.
Rust by example is less linearly linked to the book.
Though it's partially in the same order, I read it as a supplement to the book.
It includes high-level tips on idiomatic error handling, how to organise your code into modules and testing strategies.
These are all covered in the book, but Rust by example is more opinionated on how to use them.
Keep all three of these tools together.
We'll get back to the main quest in a moment, but first, a quiz from today's sponsor, Razor Secure.
What data center travels at 100 miles an hour,
reconfigures every IP when it attaches or detaches to other data centers,
all without a reliable power source or internet connection and must never fail, the answer, a travel.
RAISER secure is a 50-person startup bringing cutting-edge security tech to the rapidly advancing world of rail.
They do this through a rust intrusion detection and monitoring agent running on board,
a cloud environment running Kubernetes, Python microservices and event-based data processing, and a Yocto hardware platform running custom embedded Linux.
Their team and customers span Europe and North America,
so if you've taken a train journey here, then RAISER secure security systems may have already kept you safe.
If you're excited by this challenge and tech, then they are very interested in speaking to us, they are hiring now.
The company is fully remote,
so wherever you are based,
they offer challenging work in an interesting field with some awesome technology and a highly collaborative team with flexible working practices.
Find out more about jobs at RAISER secure at razorskill.com forward slash careers.
My thanks to RAISER secure for their support of this channel.
This is ultra learning by Scott H.
A very good book on the meta process of learning to learn.
You should read it or listen to it on audiobook as I did in chapter eight.
where it seemed that students who took the exam and failed before studying did far better
than those who only studied and then took the exam.
He calls this procedure test to learn and it makes a lot of sense.
It's like placing a number of boxes in your mind labelled with the information that you would like to be there.
Facts, figures, tell like time annotations work, etc.
Then, when you're studying later on, you more readily absorb the information because you are already looking for it.
Keep this in mind when I tell you my next tip.
I recommend reading the Rust book from cover to cover as fast as possible and without stopping to do the exercises.
If you come across something you don't understand, mentally note it and move on to the next chapter.
The installer a great sanity check to avoid pain later.
Rustlings is a code-catter-style system that you can think of as a suite of failing unit tests that you slowly work through,
fixing in a test-driven development way.
Here is the first example, fixing a hello world.
Rustlings starts out extremely simply and ramps up slowly.
Even non-programmers could start this way, and veterans will speed through them.
the early questions quickly.
Though starting simple, they follow the book all the way through lifetimes, smart pointers, and threads.
Note that the Rustling's Watcher, the output of which we are seeing here, has some extra functionality, not just auto-refreshing output from the compiler.
Each exercise has a hint, accessed by simply typing hint into the Watcher, as I did here.
Rustlings exercises are catas.
Catas, a term borrowed from Japanese martial arts, are something you practice over and over again to build muscle memory.
Musicians do the same thing.
At time of writing, there are 95 rustlings catas.
When you've done them all, it is time to choose your favourites to redo regularly.
Keep your muscle memory fresh.
Rust is a hybrid imperative and functional language.
The compiler was originally written in Okamel.
This means, in addition to the punched card analogue of statements, we can also use many features of functional languages.
The most obvious of these is the pervasive use of the iterator pattern.
possible to write Rust mostly in the way you've been writing Python or JavaScript or Java,
but you'll get most out of it if you adopt the functional principles of higher order functions and immutability.
Rust is flexible and doesn't force you to write in a functional style.
Haskell, however, is inflexible in the extreme, and you have no choice but to learn it and learn it fast.
Have a at either learn your Haskell or real world Haskell, or both.
Again, you can mostly read through these quickly.
Your package manager will have the Haskell REPL, which called GHCI, and any version it installs will be fine for experimentation.
Learning Haskell will teach you about mapping, filtering, folding, carrying, matching, and many other words to describe your algorithms in Rust.
which are abandoned in other languages that just use for loops and if statements.
You might even learn what a Monad is.
A huge turn off for me, coming from Python, was Rust's syntax.
There's so much more than I was used to.
In other languages, the compiler can't help you very much.
So moving fast and breaking things is the best way to develop.
any syntax gets in the way.
In Rust, the compiler is your best friend, but you must be nice to it for it to be nice to you.
Here's how I think the difficulty in learning say JavaScript and Rust compares to each other.
I've picked JavaScript because I want to make as many friends on the Internet as possible,
but the general relationship is the same for Python and Java.
Rust up fronts all the work that you would need to do in other languages later on to get scalability and performance and safety.
And in making you deal with them at the start, the language debt doesn't spiral as you increase complexity.
In other languages, simple things are easy and complex things are possible.
trust, simple things are possible, and complex things are easy.
And this is how it should be.
I don't care how easy it is to do simple things, that doesn't impress me anymore.
I want a language that can stay by my side as I make extremely complex distributed systems
that run at sea speed and don't wake me up at night.
Keep in mind through all your early learning.
you only have to learn Rust once.
JavaScript developers have to keep learning JavaScript every single day,
edge after edge case after edge case, framework after framework to try and manage these edge cases.
Rust offers another way, but you have to work for it.
Some annotations how long a reference should live.
It's a minimum value that variables must live for before the borrower checker knows it's safe to clean up.
This example is from chapter 10 of the book which states, the returned reference will be valid as long as both the parameters are valid.
We'll name the lifetime A and then add it to each reference.
It's very unfamiliar stuff, right?
There's two ways to think about lifetimes as a liability or an asset.
I started off thinking about them as a liability, something annoying I had to do to satisfy the compiler.
This is a totally fine way to start off with, and I have some suggestions on how to learn lifetimes gradually.
one, don't use references, use ownership and share nothing, pass in ver- intervals into functions, and if you need them later, return them back out, giving away
Copy and clone everything.
Rust is 80 times faster than Python, you're probably not going to notice the performance hit.
Only use references when the compiler tells you to.
This will eventually teach you how to use them properly.
When you've done three a few times, you're ready.
The intermediate way to think about lifetimes are not as an annoying piece of syntax, but something to enrich the model of your data.
Other languages allow you to model what your data is.
Rust, through lifetimes, allows you to model when.
Rust is shaping up to be the only language we may need for systems development,
front-end and back-end web development and bare-metal too.
Please ask any questions in the comments and I'll try to help and do join my Discord.
Have fun, talk to you next next time.