📜 ⬆️ ⬇️

Why do we need Rust?

Rust is a system programming language that runs damn fast, prevents almost all crashes, and also eliminates the uncertainty of sharing data. It is developed by Mozilla as a tool for creating a new generation of browsers - Servo .

Items of contact

This definition of language seems like a fairy tale, because the tools available to us before have always balanced between speed and reliability. On the one hand, C ++, in which huge capabilities and speed are compensated by constant access errors outside the allocated memory, to remote memory, or unexpected results of reading data that another thread is writing at that time. On the other hand, there is Haskell, a sort of language-fortress (according to the principle “if it is compiled, it means it works”), although it cannot boast of speed. Somewhere in the middle balance Java, Python, C # and other popular (by virtue of its practicality) languages. Rust for me is a good cross between the best properties of C ++ and Haskell, while maintaining practicality at the level of competitors.

What unites Rust with C ++:

What do Haskell have in common:

')
Through hardship to the stars

All the magic of Rust becomes possible thanks to the compiler knowing about who owns a certain entity (owner), who only temporarily borrows it (mutable borrow), and who just came to watch (immutable borrow). When programming in C ++ or Java, you still keep this information in your head, albeit in a slightly different form. In Rust, this is expressed by language constructs, which allows the compiler to check the correctness of your model, as well as to guarantee its smooth execution. Such programming requires a slightly different approach than we are used to. I will try to go through the main points that may put you in a stupor during the initial study:

1. There is no inheritance, but there are structures and abilities ( traits ).
2. Pointers exist only in unprotected code ( unsafe {} ). Instead, there are links in the safe code that are guaranteed to point to existing objects.
3. If you have an immutable borrow = & Object , then no one can change the value while the link is alive.
4. If you have a mutable link (mutable borrow = & mut Object ), then no one else can read the contents of the object while the link is alive.
5. Language developers prefer Mac and * nix, so for work under Windows you need GNU environment .

Rust has a very fun and active community, you will always be welcome on the IRC channel and on Reddit . Already written a decent amount of any good , many of the projects are actively developing on GitHub . The language is especially popular with game and graphics developers. There are the beginnings of operating systems . In the future, the possibility of execution on web servers and clients also looms. Rust suitable for any task!

The only serious problem of the language today is its rapid development. The syntax may change from version to version, sometimes you have to rethink the logic, adjusting to the new features of the language. This situation will last for some time this year, until Rust-1.0 appears. Meanwhile, the magazine Rust 'n Stuffs in the weekly section This Week in Rust informs us about all past and upcoming changes, new articles and promising projects.

Something about me

Soon it will be 2 years ago, as I switched to Rust, leaving behind Boo, Dart, Haskell and, of course, C ++. The first project was a game that I decided to postpone until the release of a stable version of the language. Now I am actively working on rust-compress and my data compressor . I believe in the bright future of Rust and invite everyone to take part!

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


All Articles