What is Rust, and how do you get started programming with it?

So, you’re getting into software development, and one elemental name keeps coming up: Rust. After experiencing that myself, I looked into the increasingly popular programming language. Here’s what I learned about it, plus the steps it took to start writing Rust programs myself.
Rust is a fast, safe programming language
First created in 2006 by a Mozilla employee, Rust is a programming language that emphasizes speed and safety. I didn’t know what that meant at first, so I’ll explain.
By safety, I’m referring to its handling of memory and its code enforcement. Like Java, Rust is considered memory-safe, using a memory management method where all values must have an “owner” and only one “owner.” Values can be “borrowed” but the owner is always known and in-memory. These rules prevent memory problems like dangling pointers, which can result in bugs and vulnerabilities in other languages.
Why you should learn Rust, especially if you’re new to programming
Rust is one of the newest programming languages, and it can change how you see code.
Rust is also type safe, meaning it’s extremely strict about how code is typed. If anything is at all amiss about your syntax, Rust will not simply not compile it and complain about the issue (or issues) until they’re addressed.
It’s compiled, and that’s important
If you’re like me and most of your programming experience comes from scripting in Python, there’s an important aspect of Rust that I just mentioned and that you need to keep in mind: compiling.
While you might be used to writing a Python script, running it, rewriting the script, running it, and so on, you’re going to have to get used to a different workflow in Rust. It’s not a language for scripting; it’s compiled.
A compiled language is one that doesn’t use an interpreter to “interpret” and run programs on the fly. Instead, when you want to run a program you wrote with Rust, or a similar language, you need to use a “compiler” to translate your code into a language your machine can understand.
Why I’m Excited That Rust Is Coming to the Linux Kernel
Liberating the kernel.
Believe it or not, your computer is not built to understand either Python or Rust code without help. That’s the benefit of using a compiler, though: with the language fully translated from the get-go, your software executes faster than via an interpreter.
Why Rust is such a big deal right now
If you follow software news, you’ve probably seen Rust mentioned in headlines a lot. That’s especially true if you follow the Linux world. It’s featured as the basis for System76’s new COSMIC desktop. The ubiquitous coreutils programs are being rewritten in Rust, and despite regular dunking on social media, that implementation keeps getting better. Even beyond Linux, there’s an experimental browser engine written in Rust that just might become a real competitor with the likes of Chromium and Gecko.
Clearly, Rust is experiencing a surge in popularity. Other programming languages aren’t going away; Python is still dominating in data analysis, for example. Still, it’s certainly going to be easier to get involved in cutting-edge open source projects if you’re familiar with Rust. That’s why I’m learning it.
How to write your first Rust program
If you want to start coding in Rust right now, it takes just a few steps. I’ll show you how I ran my first Rust program on my Linux desktop, but you can generally follow along on any operating system.
If you don’t want to fully install a Rust development environment right now, you can use the web-based “Rust Playground” demo in your browser and instantly start coding.
Setting up a Rust environment
To start using Rust on your computer, you first need to install Rustup. The software suite gets you the Rust language along with version management software. On Windows, refer to the Rust Forge “Other Installation Methods” guidance. On Mac or Linux, you can install it by running this command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the prompts as the installation proceeds.
Once you have Rustup installed, you need a Rust-friendly IDE. Many people prefer to use VS Code, which will be, generally, plug-and-play experience. Personally, I’m using Kate, an open source text editor that can be configured for Rust programming. I’m just a Linux and FOSS die-hard, but you can use whatever coding tool seems best to you.
To make Rust programming in Kate easier, I simply made sure the rust-analyzer tool was installed. I ran this command in your terminal, before making sure the LSP plugin was enabled in Kate’s settings.
rustup component add rust-analyzer
Writing and compiling your first program
Once you have your IDE of choice set up for Rust, you need to run this command in your terminal while in whatever directory you want your first program to be stored:
cargo new hello
The cargo new command creates the necessary project files, and hello defines the project name. You can name it anything you want, but I called it “hello” because I’m going to write a “Hello World” program.
To do that, open the project file called main.rs in your IDE and can type this code:
fn main() {
println!("Hello, world!");
}
With the fn line, I created a function called “main,” and what’s contained inside the curly braces defines what the function does. Note that every statement must end in a semicolon (;).
To run your first program, just go back to the terminal in your project folder and run this simple command:
cargo run
You’ll see your program being compiled, like I talked about earlier. If all went well, and the compiler didn’t find any issues, you will see Hello, world! printed in your terminal.
Congratulations! You’re now a Rust programmer.
You can start putting your new development environment to use by building a recipe program in Rust, through which you’ll learn about dependencies, variables, and more. If you find Rust to not be your cup of tea, you can look into other niche programming languages that might pique your interest.




