The article directories

  • Introduction of RUST
  • How to measure good language?
  • Static language
  • The compiler
  • Language localization
  • Representative project
  • Hello World
  • Prospect of RUST

Introduction of RUST

Rust is a programming language that combines memory security, high concurrency, and stable operation. It runs surprisingly fast (even faster than C/C++ in some areas), prevents runtime errors, and is thread-safe. The RUST language enables anyone to build reliable, efficient software.

How to measure good language?

In the programming world, languages are often judged in the following ways:

  • performance
  • productivity
  • reliability

Performance: RUST does all of these things well, even better than its peers. RUST has no Runtime or GC, that is, RUST has no Runtime and no garbage collection. This makes it very fast and saves a lot of memory.

Productivity: RUST is well documented, I have to say. Great documentation and a friendly compiler, top-notch package manager and build tools, and accurate error prompts are all RUST has in store for developers. We just need to focus on the logic.

Reliability: RUST’s compiler is so strict that it allows almost nothing out of control. It checks syntax, variables, ownership, and so on for you at compile time to prevent program failures.

RUST is really reliable, and it’s not blown. A strict compiler will nip problems in the bud, and once compiled, your program will be very stable (community talk of 90% stability after compiled).

Static language

RUST is a static language, which is one of the reasons it runs so fast. Before I met RUST, I was a PYTHON developer. The biggest complaint about PYTHON is its speed, whether it’s the WEB, networking, or execution. Dynamic languages have the advantage of being flexible, short, and fast enough to develop. The advantage of a static language is speed, and for that, we have to sacrifice speed (which isn’t that bad when you get used to it).

The compiler

Unlike a dynamic language like PYTHON, RUST programs must be compiled before they can be run. The compiler for RUST is LLVM (low-level Virtual Machine), which also uses LLVM as the compiler’s development language, as well as Swift.

Language localization

Each language should have its own niche, even if the end result is different from what the development team envisioned. PYTHON is now used in many areas of the WEB, such as crawlers, the WEB, deep learning, software development, etc. Although the WEB has strong competitors such as JAVA, PHP, and GO, there are still many developers using Django, Flask, and Tornado.

I’m a professional reptile engineer, so I know a lot about crawlers. PYTHON has very few rivals in the crawler space, and the number two in the crawler space is Probably JAVA, followed by GO. Crawlers are fickle, and crawler engineers change their code constantly, and few languages are as easy to develop in terms of efficiency and time as PYTHON. Crawler crawlers do not pursue super-high speed, too fast will cause the target site to refuse access (a lot of garbage is unethical behavior), if it affects the site’s operation, it will put itself on the legal edge. Also, there are so many PYTHON libraries that you don’t have to spend time building wheels. All things considered, the crawler world is really PYTHON.

PYTHON’s rich ecology and minimalist style make it a prime choice for deep learning. PYTHON dominates deep learning in a way that no other language can.

The software development world has been dominated by C# and C++ for years, the system level is C and C++, other languages have no ability to participate (GO PYTHON NODEJS JAVA languages are too weak compared to C++ and C).

What can RUST do? Good for what?

RUST is the counterpart of C and C++, but it also has the ability to compete with GO and has some opportunities in deep learning and crawlers. RUST is considered a [system-level] language that enables the development of extremely stable and fast projects. It can be a system-level programming language because it has no GC and Runtime, and its superior stability comes from ownership.

RUST is a proven development language for the next generation of operating systems. Firefox uses it to write a Unix-like operating system called Redox. The system interface is as follows:

C++ has always been the preferred choice for games and high performance software, but many developers have problems with memory (which C also has, like dangling Pointers). RUST’s strict compiler and good design allow it to circumvent these problems, and it does not suffer from memory security failures. And because RUST, like C++ and C, is a GC – and Runtime-free programming language, as well as a static language, it can play the role of C and C++, even with some advantages.

Did anyone use RUST instead of GO? Of course there is, or I wouldn’t be bringing this up. Here it is:

  • The TiDB team uses RUST to build the TiKV product, and the team developers at the RUST conference talked about RUST versus GO. In consideration of comprehensive factors, they finally chose RUST.

  • Some blockchain projects are/have been made from GO specifically for RUST, for nothing else, security.

Representative project

New languages can be hard to stand out without representative projects. Of course, if there is a big company like Google pushing things, things will be completely different (see GO and Flutter). But GO already has strong enough products to prove it, like Docker, Qiniu Cloud Storage, TiDB and Kubernetes.

RUST was born in Firefox and is maintained by Firefox developers and the RUST community. So far, RUST doesn’t have a popular project like Docker or Kubernetes, but RUST has made big strides in some areas, such as:

  • Redox – Unix-like operating system.
  • Servo – A new generation browser engine for Firefox.
  • TiKV – Distributed KV system.

Moreover, many large enterprises are trying to integrate RUST into production. I’m sure RUST will shine in the coming years.

Hello World

As mentioned earlier, RUST documentation is friendly, and we can see RUST through a case study.

To get started, we need to download and install the RUST language. As instructed by the RUST Chinese installation guide, run the following command on your terminal:

curl https://sh.rustup.rs -sSf | sh
Copy the code

Complete the download of RUST and install RUST. This installs the latest stable version of Rust. You may be prompted for your password. If the installation is successful, the following information will appear:

Rust is installed now. Great!
Copy the code

Then configure the environment variables and add the following to the ~/.bash_profile file:

$ export PATH="$HOME/.cargo/bin:$PATH"
Copy the code

After the configuration is saved, run the following command to make it take effect immediately:

$ source ~/.bashrc
Copy the code

With everything in place, we can start coding. Create a new file named hello.rs and write the following to hello.rs:

fn main() { println! ("Hello, world!");
}
Copy the code

After the code is written, it needs to be compiled before it can run. Run the following command on the terminal:

$ rustc hello.rs
$ ./hello
Copy the code

If you see Hello, world! It indicates that the program is running successfully.

You have officially written a Rust program. Become a Rust programmer. Welcome!

Prospect of RUST

We’ve seen fancy languages all too often. They’re unsafe and slow. For years, no language had been able to displace C/C++, and RUST brought new oxygen to the programming world. As a crawler developer (with lots of technology), I see programming languages [fast] as the trend and static languages as the future. I love PYTHON because of its concise syntax and high development efficiency. I have to admit that I wanted PYTHON to be faster from the bottom of my heart, but its roots as a dynamic language set the speed limit, so I switched to RUST. GO is a great language and a great ecology, but my reason for favoring RUST over GO is RUST NO GC NO RUNTIME,SAFTY.

This makes RUST bound to become the language that controls thunder and lightning in the future. Especially the emergence of Redox makes me more convinced of RUST’s future.