Skip to main content

Command Palette

Search for a command to run...

The RUST Language

Published
•2 min read•View as Markdown
The RUST Language
S
Frontend engineer writing about software beyond UI. I explore frontend, engineering lessons, delivery, performance, distributed teams, and the systems that turn code into shipped products.

Hello World!

RUST LANG

Rust is a system programming language with the goals of Safety, Speed and Concurrency. Rust is good at embedding with other languages. It has several compile-time safety checks that eliminate the data races.

How to install it?

For Linux and Mac, open the terminal and enter the following command.

$ curl https://sh.rustup.rs -sSf | sh

For Windows, download and install this file.

To verify whether Rust is installed, enter the command

$ rustc --version

Cargo

Cargo is Rust’s build system and package manager. It does three things

  • Building the code

  • Downloading the Dependencies and Libraries

  • Building the Libraries

We can check whether the cargo is installed by typing

$ cargo — version

Hello World — Rust Program

Now let us write a Rust program that prints the text “Hello World!”

  • First, move to the destination where to write the program. For example /home/User/Documents/RUST.

  • Now open the terminal and type

cargo new hello_world --bin

Creating new Cargo

When we list the files in hello_world it will have Cargo.toml and src directory.

In the src directory, we have the main.rs, in which we write the code. In Cargo.toml, we give the dependencies.

Cargo.toml

  • Let’s write the code for the “Hello World” program. For that, we need to open the main.rs file in an editor. I use nano editor, which is accessible in the Linux terminal. Write the code and save the file.

$ nano src/main.rs

Rust code for Hello World!

Here, fn keyword denoted the function declaration and main() is the main function.

The println!() method is used to print the values to the output console.

Now, let us build and run the code. The command used to build the code is

$ cargo build

The command to run the code is

$ cargo run

Output of Hello World program

Now, we have installed Rust in our system and executed a simple Hello World program in Rust. Since this is a very simple program and need no dependencies, we left the Cargo.toml unchanged.

Looking forward for your valuable feedbacks and suggestions.

Thank you!!

More from this blog

Building Beyond Components

29 posts

Building software rarely ends at components.

This blog is where I write about frontend, engineering lessons, delivery, and the systems that turn code into shipped products.

Some posts come from technical work. Others come from unexpected places: process, communication, platform exposure, production realities, and the things I learned outside UI.

I’m Sriram, a software engineer exploring software beyond components.