What is Rust? |Explains the features of the language, the benefits of learning, and how to install it!

Rust is known as a relatively new programming language.
It used to be famous as a programming language supported by MoFo (Mozilla Foundation), but now some articles mention Rust as a programming technology trend after 2020 (Predicting Programming Trends After 2020 ). This article explains the benefits of learning an introduction to Rust. If you are interested in Rust, please refer to it.

Table of contents

  1. What kind of language is Rust?
  2. Rust features (safety, speed, concurrency)
  3. Features of Rust (Other)
  4. Install and run Rust
  5. What can you do with Rust?
  6. lastly

What kind of language is Rust?

Rust is a programming language that is being developed with a focus on ‘safety, speed, and concurrency’. Initially developed in 2006 as a personal project by Graydon Hoare, since MoFo began working on it in 2009, it has become an official project of Mozilla Research. We repeated destructive specification changes until the 1.0 version was released in 2015, but since the 1.0 version, we have maintained backward compatibility and regularly released new versions every 6 weeks.

There are two types of programming languages: compiled languages ​​(static programming languages) that require compilation (translation into computer language) like C++, and script languages ​​(dynamic programming languages) that do not require compilation like Python. There are two types. Compiled languages ​​require human-understandable source code to be translated into machine-executable form, while scripting languages ​​do not require translation.

Rust is classified as a compiled language in the same way as C++, and on Windows you can create exe files. It is expected to have future potential because safe memory management can be easily realized while maintaining the high speed that is a feature of C++. The fact that it is the language used by Firefox, which holds the 2nd to 3rd place in the browser market share, will also support future development.

Rust features (safety, speed, concurrency)

Here are some of the features of Rust as a programming language:

safety

By giving variables a “lifetime”, Rust allows many memory and resource leak bugs to be caught at compile time. Furthermore, by giving “ownership” to variables, it prevents multiple places from rewriting memory at the same time. Both are checked by the compiler.
Also, Rust is officially described as a null-safe language, and it can be said that it is a language with the potential to increase safety and development productivity.

speed

Since it is a programming language that runs in a near-native environment, it is characterized by high-speed operation. It is as fast as C and C++ in many benchmarks. There are also blogs that verify the execution speed of Rust, so if you are interested, please search for it.

concurrency

With the “ownership” mechanism described in the safety section, it can be executed safely even with multiple threads. A major feature is that multithreading, which was difficult in C and C++, is easy to implement.

Features of Rust (Other)

Rust has many more features than the above. Let’s go through them one by one.

very easy to install

In the second half of this article, I will introduce “From installation to the output of “Hello, World!””, but it is very easy to start using. On Windows, just run the installer and you’re ready to go! Mac and Linux just enter the command in the terminal.

Memory management feature “ownership”

Rust is unique in its memory management. There are some restrictions on copying variables, one of which is “ownership”. In short, even if a variable is copied, it cannot be accessed from the copied variable, so the compiler supports the idea of ​​”not copying variables carelessly.”

In C++ you can access freed memory or access unallocated memory. Because memory management is completely up to the developer. A less secure memory can compromise the entire system. So Rust introduces a system of ownership to ensure memory safety.

Specifically, assigning a value to a variable is called “variable binding”, and by binding value X to variable A, that value X is owned by variable A. If you then bind the value X owned by variable A to another variable B, the ownership is automatically transferred and you can no longer refer to value X from variable A. This is standard Rust behavior called “move semantics”. This avoids memory conflicts and guarantees memory safety.

Furthermore, in order to achieve the goal of developing applications that operate at high speed, it is designed to perform strict checks during compilation, reduce the load at runtime, and operate at high speed.

Install and run Rust

Rust has the advantage of being very easy to install compared to other programming languages. I will show you how to install it here, so please give it a try. By the way, the environment is described assuming Windows 10.

install

First, install the compiler from the Rust official site. When you access the official website on Windows 10, a special page will be displayed, so click “Get Started” to download the compiler. Start the downloaded installer and follow the instructions on the screen to proceed with the installation. If you install with the default settings, you will have a complete set of tools such as rustc (compiler) and cargo (build tool).

Program creation and execution

Next, let’s create an actual program. Open Notepad app and create “hello_world.rs”. The Rust extension is conventionally “rs”. Create a folder called “hello_world” anywhere and save “hello_world.rs” there.

1 fn main() {
2 println!(“Hello, world!”);
3 }

Next, start the command prompt, move to the “hello_world” folder, compile “hello_world.rs”, and then enter “hello_world.exe” to execute it.

$ rustc hello_world.rs
$ hello_world.exe

If you confirm that “Hello, world!” is output on the screen here, it is a success!
(If you get an error when compiling, please refer to this article first. I stumbled on compiling Rust . )

What can you do with Rust?

Rust is a programming language with a particularly high level of safety, so it has the characteristic of being active in large-scale system development. Even when multiple developers build a system, development can proceed while maintaining safety, so it can be considered that a more secure system than the highly versatile Java and C languages ​​will be completed.

Of course, it can also be used for application development, and it can be used for a wide range of development because it excels in many use cases that other languages ​​are not good at, such as low-level code such as device drivers and operating systems.

lastly

Today, I explained the following about Rust.

  • What kind of language is Rust?
  • Rust features (safety, speed, concurrency)
  • Features of Rust (Other)
  • Install and run Rust
  • What can you do with Rust?

Why not take this opportunity to learn more about the Rust programming language, which is gaining more and more attention?

Leave a Comment