
Mozilla has reached the finish line in the preparation of the programming language Rust 1.0. The developers
say that this solemn event will take place around the end of the year. After beta testing, the final release will be released. From this point on, a promising programming language can be used in combat conditions: the code is guaranteed to be compiled in future versions.
It's not just about compiling. Mozilla believes that the design of Rust is finally acquiring the desired minimalist form. For example, there used to be several types of pointers, now only
&T
and
&mut T
remain. Simplification touched upon other aspects, including closures, which caused a lot of controversy.
Rust combines the effectiveness of C and C ++ with Java security.
')
The entire design is built on the concept of "ownership and borrowing" (ownership and borrowing). It was originally intended to use the ownership mechanism to quickly and securely transfer data between processes. But then the understanding came that the same mechanism can be used to transfer a significant part of the functions to libraries. As a result, Rust turned out to be even lower-level than the developers expected, and without compromising security. On the minimal configuration of Rust, you can even write the kernel of the operating system (examples:
1 ,
2 ,
3 )!
The developers have also published a list of features that must be implemented before the official release. This is what we are working on right now:
- Types with dynamic size (dynamically sized types). The extension of the typing system allows the use of data types whose size is unknown at the time of compilation, for example, arrays. Instead, a smart pointer is placed, containing arrays or objects.
- Unboxed closures. In the new design of the closures, they are combined with the types of objects.
- Associated types in the feature system make it much easier to write annotations for libraries, the first implementation is ready.
- Where clauses. It is planned to introduce a flexible new form of elementary disjunction. Work on this function has already been completed, it will soon be added to the main branch of the code.
- Multidispatch traits. The functions of the types are expanded, so that they can specify more than one type at the same time , this opens up possibilities for more ergonomic APIs and for using the associative types mentioned above.
- Destructors The semantics of destructors are improved, so that it now does not need to reset the memory, which should increase the speed of compiling and executing programs. Now the analysis of the conditions for zeroing memory ends, after which this part will also be added to the main branch.
- Green threads (green threading) are removed from the main library to additional ones in order to optimize their effectiveness on a specific operating system. This will also lead to faster execution of programs.
In parallel, the package
Cargo manager is created and a central software repository will be organized.
From the
lecture by Stepan Koltsov , which was recently published in Habré:
“Rust solves Java and C ++ problems: programs written in Rust are both fast and secure. Rust is the same low-level (in the sense of close-to-metal) programming language like C ++, however, there are built-in constructions in the language that allow, at the compilation stage, to prove that there are no memory errors in the program, such as the post-use handling, double deletion, use of uninitialized memory, etc.
In addition, Rust fixes many of the mistakes made when designing C ++ and Java. For example, templates in Rust, unlike C ++, are statically typed, and instead of generics, Java uses a mechanism similar to Haskell timeclasses.
Rust code examples can be found on the
official website .
UPD.
Full translation of the article “Towards Rust 1.0” by
Googolplex