+5 votes
177 views
in Web development by (242k points)
reopened
Rust: the modern programming language

1 Answer

+3 votes
by (1.6m points)
edited
 
Best answer

What is Rust?
Rust Features
Rust syntax: example

image

Rust: the modern programming language

Although there are already many programming languages, such as C ++, Pascal or Java, new ones are constantly being developed that aspire to be simpler, more secure or faster . Rust is meeting all three of these goals at once, and is therefore very successful. According to a survey of users of the Stack Overflow developer platform, Rust was the most popular programming language of 2019..

Index
  1. What is Rust?
  2. Rust Features
  3. Rust syntax: example

What is Rust?

The Rust programming language was created in 2010 by Mozilla. At first, it was just a hobby a developer spent his spare time on. This language was later used to develop a new rendering engine for Firefox and is currently an open source project maintained by a very active community that still receives financial support from Mozilla.

This programming language falls between low-level C languages ​​and highly abstract languages, such as Java. In fact, Rust is a systems programming language , that is, a language used to implement applications or operating systems that are closely related to Windows, Linux, or macOS. At the same time, Rust is used to program web applications - that is, on a much smaller scale..

Rust Features

Rust's greatest advantage over other programming languages ​​is security, which is ensured, among other things, by a good error handling system . If an error occurs that cannot be corrected during compilation, the macro? Panic!? Starts, which performs a cleanup and issues an error message to prevent corruption.

The storage management of this language is also considered extremely secure. The advantage of Rust is that it ensures memory security without a garbage collector . For many years, memory was a common target of hackers in many programming languages. If a memory becomes full, a system error occurs and therefore a gap that can be exploited. A garbage collector ensures that unnecessary objects disappear from memory. However, this slows down code execution. The Rust compiler makes the garbage collector obsolete by checking for errors in memory at compile time..

If you wonder if these robust security measures cause a drop in performance, the answer is no: Rust is a systems programming language, just like C / C ++, so it offers the same execution speed. On the one hand, this is due to the absence of a garbage collector. On the other hand, so-called zero-cost abstractions ensure high speed during execution time . This concept, in reality, only indicates that the language allows programming in an abstract way without affecting performance.

Therefore, Rust is considered to be a combination of high-level and low-level programming languages . Like C / C ++, Rust is very close to hardware, which guarantees high speed, but can be programmed with relative ease, which is characteristic of other high-level languages.

Lastly, both less knowledgeable programmers and professionals can learn to use Rust quickly. In terms of use, the language hardly differs from the better known alternatives. A big plus is its elaborate error message system : where other programming languages ​​only generate cryptic warnings, Rust provides applicable tips for troubleshooting.

advice

Rust is one of the extremely compatible programming languages ​​for WebAssembly. Rust is also used to develop fast web applications.

Rust syntax: example

At first glance, Rust's syntax is very similar to that of C or C ++, other systems programming languages. As is common in these types of languages, Rust also includes functions, loops, queries, constants, and variables. The brackets are used differently in some cases, following the syntax of older languages, but the basis remains the same. Of course, Rust also has its peculiarities:

  • New functions are defined with the fn command .
  • The language works with macros , which are distinguished by the exclamation point at the end of the term.
  • The variables can be determined let ; For the information to be modified, it must be expressly permitted with mut .
  • Rust also follows a special model of ownership .

In Rust syntax, the concept of property refers to the relationship of a variable to its value. The peculiarity is that a value can only belong to one variable. If the value is passed to another variable, the previous one will no longer be valid:

  fn main() { let hello = String::from(?Hello, world!?); let hello1 = hello; println!(?{}?, hello); }  

The syntax of this code is not correct: the content of? Hello? went to? hello1? and therefore cannot be called back in the macro. Instead, the new variable must be written in the last command, which will generate the correct output.

  fn main() { let hello = String::from(?Hello, world!?); let hello1 = hello; println!(?{}?, hello1); }  
In summary

Rust is a simple language that provides more security and performance. This modern programming language does not introduce a totally new syntax, but rather it is based on the characteristics of C / C ++, although it also offers some very interesting new features. Starting to use it is not difficult, especially if you already know other languages.


...