The Rust programming language is one of the fastest adopted systems programming languages by developers and tech companies. It is also voted as one of the most loved programming languages by developers who use it on a daily basis. Rust has been getting this love for seven consecutive years now!
It is so popular that there are now two big efforts being carried out in the Linux ecosystem:
- Inclusion of Rust as a secondary programming language in the Linux kernel
- System76 is writing their own desktop environment from scratch using Rust
And that is just in the Linux ecosystem. Android's Bluetooth implementation Gabeldorsche is now written in Rust.
Do you see the rising popularity of Rust? You would probably like to learn coding in Rust.
Why use Rust?
Rust is a programming language that has an extremely strict type system. As a result, you are "forced" to not write unsafe in the first place. (Unsafe code doesn't mean that it won't leak the memory, though.).
The Rust programming language has the following "goals":
- Speed: Rust's binaries are as fast as C binaries, sometimes outpacing C++ binaries!
- Memory safety: Rust has a huge emphasis on memory safety.
- Concurrency: Focusing on memory safety eliminates a lot of race condition-like scenarios and helps you introduce concurrency in your program.
Following are a few
errors mistakes one might make in languages like C/C++ (but not with Rust):
- Use after free
- Double free
- Accessing out-of-bound values
- Inappropriate pointer arithmetic and/or access
- Use of uninitialized variable(s)
- Thread-unsafe multi-threading
Now that you know why one might want to choose the Rust programming language over any other one, let's start with the Rust language tutorial series!
For the love of Rust, Pratham created this series of Rust tutorials to help you get acquainted with the concept of Rust programming.
This tutorial series is intended for folks already familiar with programming languages like C and C++. We assume you know basic terms like variables, functions, loops, etc.
The only prerequisites is your time and some effort.
1. Create and run your first Rust program
The first chapter of the Rust Basics series discuss the installation of Rust followed by your first ever Rust program. You'll learn to compile and run the Hello World program in this chapter.
2. Use variables and constants
Next, you'll learn about using variables in Rust. Rust's variables are different from other programming languages as they are immutable by default. Learn about them in this chapter.
3. Learn scalar data types
Rust has two categories of data types: scalar and compound.
In the third chapter, you'll learn about scalar data types such as integers, floats, characters and booleans.
4. Learn compound data types
The compound data types can store multiple values in a single variable. Rust has two compound data types; arrays and tuples. Know more about them in this chapter.
5. Use functions
Like any modern programming language, Rust, too, has functions. In fact, the
main function is required to run any Rust program.
6. Know about using conditional statements
Add some logic to your Rust program by using conditional statements like if-else.
7. Have fun with loops
Learn about the regular for and while loops along with the special
8. Test your Rust knowledge with a complex program
You have learned the absolute basics of Rust programming. Now it is time to use them all in this slightly complicated programming exercise.
Where to go from here?
It's FOSS will have another Rust series to take you to the intermediate level. But don't wait till then. Explore some Rust projects on GitLab and GitHub. You can always refer to the official Rust documentation and learn more.
It's FOSS doesn't cover coding as much as Linux. This is an attempt to cover a programming language that is gaining popularity among application developers. Perhaps you'll use the knowledge to develop Rust applications for Linux one day.
Enjoy learning Rust with It's FOSS 🦀🦀