Rust Is On A Roll

Written by exactor | Published 2021/09/23
Tech Story Tags: rust | features | rust-programming-language | rust-features | rust-libraries | coding-skills | beginners-to-coding | rust-vs-python

TLDRRust is a general-purpose, multi-paradigm, compiled programming language that combines functional and procedural programming paradigms with a trait-based object system. Memory management is carried out through the mechanism of "ownership" using affine types, which allows you to do without garbage collection at runtime. Rust guarantees safe memory use with a borrow checker built into the compiler. The language is intended for system programming, which will allow you to write utilities for various purposes, secondly, the speed of work. I plan to use Rust as a replacement for Python for writing automation, especially any complex-calculable tasks, creating CLI tools and tools for development in other languages.via the TL;DR App

Rust is a general-purpose, multi-paradigm, compiled programming language that combines functional and procedural programming paradigms with a trait-based object system. Memory management is carried out through the mechanism of "ownership" using affine types, which allows you to do without garbage collection at runtime. Rust guarantees safe memory use with a borrow checker built into the compiler. There are tools that allow you to use object-oriented programming techniques.

Such a description can be found on Wikipedia, but for most people, it is no longer very clear. We start to deal with not very obvious things: affine types and ownership.

Affine types are a descendant of linear types. Linear types are typing systems in programming languages based on linear logic. This system introduces a new type of data - types that prohibit copying a reference to an object. Thus, after appearing on the right side of the assignment, the object leaves the program.

Affine types are a similar but less strict system in which it is possible to use an object once (whereas in a linear system, an object must be used only once).

Ownership is central to the Rust language. While this feature is easy to explain, it has had a profound effect on the rest of the language. All programs use computer memory at runtime and use different approaches to manage their memory.

Some programming languages ​​use a garbage collection (GC) system for this purpose that constantly monitors program memory that is no longer used by the program. In other languages, the programmer must explicitly request and free memory himself. Rust takes a third approach: memory is managed using an ownership system with a set of rules that the compiler only checks at compile time. None of the ownership rules slow down program execution.

From many different materials, 3 main key priorities can be deduced:

  • Security
  • Speed
  • Parallelism

Based on the priorities, we conclude that the best application for Rust is system programming. Therefore, one often hears: “Rust is the C \ C ++ killer.”

What Rust is good for:

  1. programming client applications and web servers;
  2. blockchain;
  3. OS creation;
  4. writing programs and applications for monitoring systems and servers;
  5. general-purpose software development;
  6. creation of infrastructure;
  7. writing engines for browsers and games.

Why is he interesting to me. In addition to the rating on StackOverflow, I liked the rather interesting syntax, a convenient builder and installer of dependencies, the ability to create an executable file and use only it with all dependencies, unlike Python, where you need to preinstall these dependencies on each computer. Concurrency without GIL, another benefit and support for asynchrony.

Interesting libraries:

  • Tokio is a library for building asynchronous applications.
  • delay-timer - Time-manager of delayed tasks. Like crontab, but asynchronous tasks are possible.
  • seed - A Rust framework for creating web apps
  • yew - Rust framework for making client web apps
  • rust-websocket - A framework for dealing with WebSocket connections (both clients and servers)

Subjective conclusion.

Firstly, this language is intended for system programming, which will allow you to write utilities for various purposes, secondly, the speed of work, I am more than sure that Rust will work faster than Python, especially CPU-bound tasks, and thirdly, on Rust, you can write backend, and I think it will be a very interesting experience, and you can also develop Frontend using WASM.

Another bonus was the support for microcontroller programming. Therefore, it will be possible to try to create a service completely written in Rust with the ability to deploy statics to a microcontroller, which seems like a too strange decision, but the fact is that we just can. What seems difficult now: unsafe code; I met with such an opinion that first, you learn Rust, and after Unsafe Rust - as almost a new language. Now it is difficult for me to imagine how often I will have to use unsafe, given that up to this point, it is to me not very useful.

Now I plan to use Rust as a replacement for Python for writing automation, especially any complex-calculable tasks, creating CLI tools and tools for development in other languages; it is possible to rewrite a couple of standard UNIX commands (programs) to improve their output to the console. I plan to use all this as a practice in the Rust language.

As you can see, Rust is not just another C-based systems programming language. A system language enriched with a number of high-level concepts can also be viewed from the other side: as an applied language equipped with low-level tools.

Are these low-level tools useful in application development? I think yes. They allow you to create new efficient high-level abstractions, expanding the developer's arsenal. Additionally, the availability of tools that allow you to isolate and link different layers together makes Rust a truly universal programming language.

Interesting projects using Rust:

  1. Rust - The Rust compiler is written in Rust.
  2. Cargo is a package manager for Rust.
  3. Servo is a multithreaded browser engine.
  4. Redox is an operating system written entirely in Rust.

Useful links

https://doc.rust-lang.ru/book/ https://github.com/rust-unofficial/awesome-rust


Written by exactor | Development Lead.
Published by HackerNoon on 2021/09/23