📜 ⬆️ ⬇️

Rust: abstraction and security, completely free (video from the Saratov Open-IT session)

Hey.

Last Saturday, I gave a talk at the next Saratov Open-IT meeting where I talked about Rust, a promising system programming language developed by Mozilla Research and the community, and what problems it solves and what features it has and infrastructure. I hope that my presentation will be interesting to the community, so I post it here.

(video is not inserted into the post through the <video> tag because it does not work with a specific timestamp; the duration is about an hour and a half)
http://www.youtube.com/watch?v=lmauAUF823k#t=2583
')


I have been studying Rust and have been participating in its community for about a year and a half. In general, the main platform, the programming for which I do, is the JVM, but I always wanted to write natively working programs — some utilities for Linux, easy cross-platform programs, and so on. However, I didn’t want to write in C ++ or C. C ++ is a huge and very complex language, with a lot of opportunities (the number of which is growing with each new standard), which is difficult to use correctly, without having strong self-discipline and long experience with it. C, on the other hand, is very simple, but also very inexpressive - after languages ​​like Scala it is difficult to write on it, because it lacks many already familiar features (like anonymous functions), there is no good standard library, and yet C is very strong tied to the platform - many things are done on it through conditional compilation and reference to the lowest-level OS tools.

Rust tends to close this niche between low and high level languages. On the one hand, it is as “close to hardware” as C / C ++, and on the other hand, it provides security and abstractions that are much closer to higher level languages. All this is ensured by powerful static analysis, thanks to which programs written in Rust are guaranteed to work correctly with memory. The feeling was like the first time after learning Haskell - you are amazed at the fact that the program that has been compiled always works correctly :)

Another advantage of Rust compared with C / C ++ is its infrastructure, in particular, its package manager Cargo. Thanks to Cargo, cross-platform programs on Rust are as easy to write as programs are written in languages ​​like Java and Python. The Cargo project contains a manifest, which describes all its Rust-dependencies and (where appropriate) the rules for building C-dependencies. In order to get the collected binary, just dial the cargo build in the terminal - all dependencies will automatically download, assemble and connect to your project. Compared to the need to use tools like autoconf or cmake, which delegate responsibility for third-party libraries to a system user, Cargo makes building programs on Rust much closer to interpreted / dynamic languages, in which you also get a working program using one command.

In addition, the central repository of Cargo packages has recently opened, which will become the core of the future stable ecosystem around Rust - crates.io . Already there are more than 400 packages. Naturally, Cargo will still be able to use the master branches from the repositories, but crates.io will become a concentration of stable versions of packages. It is assumed that due to the universal use of the semantic versioning, it will be painless and easy to update the dependencies of your projects. By the way, you can read about the language stabilization plan in my translation of blog posts from Rust developers, here and here .

In general, in the light of the upcoming stabilization of the language, it seems to me that now is the time to start promoting Rust in a wider community of developers. Now in Rust there is a very active preparation for the release of the first stable version, many of the most awaited features of the language and libraries take the final shape. A little more, and the language will be fully prepared for industrial use.

A rough outline of my story (in video):
  1. place Rust among other languages, what problems he solves
  2. brief syntax overview and Rust type system
  3. polymorphism in Rust, generics, traits and trait objects
  4. Data Ownership and Borrowing Concepts - The Basics of Rust Security
  5. multithreading and lack of data races in programs for Rust
  6. when unsafe operations are needed
  7. Rust infrastructure
  8. existing projects on Rust
  9. useful links

I apologize, sometimes I forgot to speak questions from the audience into the microphone, and because of this it is not always clear what I answer :(

Presentation to the report is available at this link .

Source: https://habr.com/ru/post/244537/


All Articles