Rust is not that rusty

Rust is not that rusty

ยท

4 min read

Hey everyone, if you follow me on my socials you already know that I started learning Rust a while back. And today after completing the basic fundamentals, I would like to share my learning about the same with you'll. This blog not might be the most accurate piece of information you might find on the internet about rust but I am writing this from my understanding of what is rust. So if you would like to correct or suggest something, please feel free to do that in the comments below. So with that let's get started ๐Ÿš€

What is Rust

Rust is a programming language with a lot of potentials. Rust became popular because of its similarities with C++ language with some extra flexible and highly efficient features. Rust quickly became one of the popular languages as it's trusted for great performance (Super fast and memory efficient), reliability, and productivity (Good error messages, documentation support, integrated package manager, etc) while building software.

Apart from all its great features, Rust became popular to it's highly flexible and fitting nature across different domains. Some of them are:

  1. Command Line: Building and distributing of command line tool is extremely easier due to Rust's robust ecosystem and also helps in maintenance for the same.

  2. WebAssembly: This concept of taking web apps to the next step is truly revolutionary and Rust helps us work with Web Assembly to efficiently work with Web Applications.

  3. Networking: Rust becomes a popular choice for building network services as it provides reliability and resource footprints needed for predictable performance

  4. Embedded: Many of the embedded software developers prefer low-level languages like C etc but Rust helps these developers to use it as low-level language without giving out the high-level language features

Installation

Installation is pretty simple for Rust, if you are using Linux or mac you can simply learn the following curl command

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

you will get a prompt something like the below press one and hit enter and that's it, your rust is installed.

If you want to check if it's installed correctly you can run the following commands:

rustc --version
cargo --version

What is cargo?

Cargo is a package manager for Rust, if you have used and worked with JavaScript and Python then it's similar to the native npm and pip we use. You can use some of the cargo commands to run, and build your code

//This command initializes the rust project
cargo init
//This command is used to run your rust program
cargo run
//This command is used to build your rust program (Creates /target folder)
cargo build
//This command is used to build release ready command executable
cargo build --release

Creating a rust project

Now that we are done with introductions and basics, let's try to create the first hello world program with Rust.

Step 1: Go to the preferred destination on your file structure and create a folder with your project name here we will take it as hello, and initialize your terminal

Step 2: Run cargo init this will create some folders and files needed.

Step 3: Navigate inside src/ folder and you should see main.rs file. This is the file we will do the changes

Step 4: Add the following code to the main.rs file

fn main() {
    println!("Hello World");
}

Step 5: Into the terminal navigate to the location of main.rs file

Step 6: Run cargo run and you should be able to see the output as Hello World.

And that's it, you have successfully created your first Rust program. In the upcoming blogs, I will try to go deeper into the basic programming with Rust where we will see about variables, conditionals, loops, and other language-specific things one needs to remember.

Resources:

Thank you so much for reading ๐Ÿ’–

Like | Follow | Subscribe to the newsletter.

Catch me on my socials here: https://link.kaiwalyakoparkar.com

Did you find this article valuable?

Support Kaiwalya's Musings ๐Ÿ’ซ by becoming a sponsor. Any amount is appreciated!

ย