Hey. My name is Stepan Koltsov. Recently, I spoke at the Java Party in the Kiev office of Yandex with a report on the Rust language, which carries a lot for the future of programming. Some colleagues say that I always talk about Rust, when I have this opportunity. Today I want to share this story with you and explain why this seems important to me.
First, a few words about what Rust is. For the last 15 years, there is a debate between Java and C ++ developers about which programming language is worse - Java or C ++. C ++ programs are buggy, crash, and memory leaks. Java programs slow down and require too much memory.
')
Rust - a new modern programming language developed by Mozilla - 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. Rust uses the borrowed pointers mechanism for this. Most of my story was devoted to the description of this mechanism.
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.
At the moment, the Rust programming language has not yet begun to be used in industrial programming, and most likely it will not be possible to find a job as a programmer at Rust tomorrow. However, it is worth exploring Rust - in order to better program in Java and C ++ and to understand the direction in which modern programming is developing.
I myself program at work mainly in Java and C ++. Using these languages, I suffer. It is assumed that Rust will relieve me and everyone else from suffering.
I closely follow what is happening in the world of Rust, and imagine what is happening there now. When I first became acquainted with this language, I had the feeling that I was blind, but suddenly I began to see. Previously, I was sure that a binary choice is presented to a programmer: either a program is written in C ++, it runs fast and crashes, or the program is written in Java, it runs safely, but slowly. It turned out that there are other approaches: the program can be both fast and secure. Almost all of my story is about how memory work is arranged in Rust, because memory work is the main problem with C ++.
Java is considered a safe environment, but Java programs have a large memory and CPU overhead. In addition, Java does not allow you to safely write multi-threaded programs. Java does not guarantee in any way that if an object is designed to work from one thread, then it will not be able to be used in different threads. There is no such problem in Rust. Java does not guarantee that you will not forget to install mutex.
Story story plan (on video):
- Code examples;
- Basic data types;
- About the fact that moving objects is better than in C ++ 11;
- Pointers;
- How programs in C ++ fall, and how the same programs in Rust do not fall;
- The lifetime of objects in the Rust language;
- Banning aliasing in Rust, and what problems this ban solves;
- As in Rust made mutex.