What is Rust? How to install it? Introduction to Rust.

Talking with a friend and became a topic of “Rust”. I heard that it seems to be an interesting language, and I love C/C++, which is likely to be my favorite language.

This article says that:

  • What is Rust?
  • How to Install it.
  • How to compile and run.
スポンサーリンク

What is Rust?

The Rust is a programming language. It is a system language and have been developed by Mozilla Foundation. It is usually supposed to be used for developing software that requires high performance such as written in C/C++, and the goad is to replace C/C++.

The Rust has a compiler and export the native executable binary, so the Rust is not needed when the developed software runs.

The official web site is here:

Rust Programming Language

The latest version is 1.36.0. (at this article was written)

Installing Rust

It is easy to install tools to develop with Rust, and a guide in the official is also simple.

Do following in terminal on Unix Compatible OS such as macOS and Linux.

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

On Windows, download the installer from next page.

Install Rust – Rust Programming Language

First Step To Rust

First, add the path to tools, do following:

$ source ~/.cargo/env

Let’s make the “Hello World” program.

Make the project.

$ cargo new hello-world

The “cargo” is a package manager of the Rust. It can create the project, and build the program. The “hello-world” folder is created by above command. Move into it by “cd”.

$ cd hello-world

Edit the “main.rs” in “src” folder. The path extension of the Rust source file is “rs”. The code is following:

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

Yes, it is completed code. Even those who are new to Rust will understand it somehow. I am also new to Rust, I can understand it somehow.

I think that it is derived from C/C++ by “;” at the end of the line.

Let’s build and run this code. Use “cargo” to do that.

$ cargo run

On my machine, exported following:

Compiling hello-world v0.1.0 (/Users/akira/hello-world)  Finished dev [unoptimized + debuginfo] target(s) in 0.64s
   Running target/debug/hello-world
 Hello, world!

The first 3 lines are exported by cargo. The built program exported “Hello, World!” at line 4. It seems that the binary is exported into “target/debug” folder. Open it, the many files are exported. I think they are intermediate objects. The “hello-world” is also there. Is it really executable? Let’s check it.

$ file target/debug/hello-world

The result is next.

target/debug/hello-world: Mach-O 64-bit executable x86_64

It is executable.

Does IDE support Rust

It is important that the IDE supports Rust. You can even develop without IDE and with only the CLI, a text editor and a CLI debugger. But it is not efficient and no merits.

The official site says that following IDE supports Rust:

  • Visual Studio Code (VS Code)
  • IntelliJ IDEA
  • Eclipse

Also following text editors are support Rust:

  • Sublime Text 3
  • ATOM
  • vim
  • emacs

I think it is enough to develop.

Conclusion

This article says that introduction to Rust, how to install it. I am new to Rust, I think it is easy to start and try.

スポンサーリンク
最新情報をチェックしよう!

rustの最新記事8件

>現役のプログラマーが書くプログラミング情報

現役のプログラマーが書くプログラミング情報

日々の開発の中での学びや分かったこと、調べたことなどを書いていくブログです。

CTR IMG