Fast, secure, and easy to type – choose two. This has been the state of software development for a good long time now. Languages ​​that emphasize convenience and security tend to be slow (eg Python). Languages ​​that emphasize performance tend to be hard to work with and easy to blow your feet with (like C and C++).

Can all three of these traits be presented in one language? More importantly, can you make the world work with her? The Rust language, originally created by Graydon Hoare and currently sponsored by Google, Microsoft, Mozilla, Arm, and others, is an attempt to do just those things. (Google Go has similar ambitions, but Rust aims to make as few compromises as possible for performance.)

Rust is meant to be fast, secure, and reasonably easy to program. It’s also meant to be used widely, and it doesn’t end up being just a curiosity or a run in language sweepstakes. There are good reasons to create a language where security is on par with speed and power of development. After all, a huge amount of software—some of which drives critical infrastructure—is built in languages ​​where safety was not their primary concern.

Advantages of Rust programming language

Rust started as a research project from Mozilla aimed in part at re-implementing key components of the Firefox browser. There are a few main reasons for this decision: Firefox deserves to make better use of modern multi-core processors; And the sheer presence of web browsers means that they need to be safe to use.

But these benefits are required by all programs, not just browsers, which is why Rust has developed into a full-fledged language project from a browser component project. Rust achieves its safety, speed and ease of use through the following characteristics.

Rust fast

Rust code is compiled to native machine code across multiple platforms. Binaries are self-contained, with no external runtime apart from what the operating system may provide, and the generated code is meant to run as well as similar code written in C or C++.

rust safe memory

Rust will not compile programs that attempt to use unsafe memory. Most memory errors are caught when the program is running. Rust syntax and metaphors ensure that common memory problems in other languages ​​- null or hanging pointers, data races, etc. – never hit production. The compiler flags these problems and forces them to fix them before the program ever runs.

low rust

Rust controls memory management via strict rules. Rust’s memory management system is expressed in the language’s syntax through a metaphor called Property. Any value in the language can be “owned” or held and manipulated, only by one variable at a time. Every bit of memory in Rust is automatically tracked and released through the borrowing of ownership.

The way ownership is transferred between objects is strictly subject to the compiler, so there are no runtime surprises in the form of memory allocation errors. The proprietary approach also means that Rust does not require garbage collector memory management, as is the case in languages ​​such as Go or C#. (This also gives Rust another performance boost.)

rust flexible

Rust lets you live dangerously if you need to, up to a point. Rust integrity can be partially suspended where you need to manipulate memory directly, such as dereferencing a raw pointer à la C/C++. The key word is partially, because Rust memory security processes can never be completely disabled. Even then, you’ll never have to take off your seat belts in common use cases, so the end result is that the software is safer by default.

Rust is easy to spread

None of Rust’s safety and security features add much if they are not used. That’s why the developers and community of Rust have tried to make the language as useful and welcoming as possible for newcomers.

Everything needed to produce rust diode comes in the same package. External compilers, such as GCC, are only needed if you are compiling other components outside the Rust ecosystem (such as the C library that you compile from source). Microsoft Windows users aren’t second-class citizens either; The Rust Toolkit is as capable there as it is on Linux and macOS.

Rust is multiplatform

Rust works on all three platforms: Linux, Windows, and macOS. Others behind these three are supported. if you wanted to via translation, or producing binaries for a different architecture or platform than the one you are currently running, A little extra work included, but one of Rust’s general tasks is to reduce the amount of heavy lifting needed for such work. Also, even though Rust runs on the majority of current platforms, it’s not the intent of its creators to completely bundle Rust everywhere – just on any popular platforms, and anywhere they don’t have to make unnecessary compromises for the language to do so.

Rust has powerful language features

Few developers want to start working with a new language if they find it has fewer or weaker features than they are used to. Rust’s native language features compare favorably with languages ​​such as C++: macros, generics, pattern matching, and composition (via “adjectives”) They are all first-class citizens of Rust. Some features are found in other languages, such as Embedded assembler, also available, albeit under Rust’s “unsafe” rating.

Rust has a useful standard library

One of the larger parts of Rust’s mission is to encourage C and C++ developers to use Rust instead of those languages ​​whenever possible. But C and C++ users expect to have a proper standard library – they want to be able to use containers, collections, and iterators, perform string manipulations, manage operations and threads, perform network and file I/O, etc. Rust does all of that and more in Standard Library. Since Rust is designed to be cross-platform, its standard library can only contain things that can be reliably ported across platforms. Platform-specific functions such as Linux’s epoll must be supported via functions in third-party libraries such as libcAnd Mine, or Such as.

Rust can also be used without it Standard Library. One common reason to do this is to build binaries that do not have platform dependencies – for example, an embedded system or an operating system kernel.

Rust has many third-party libraries, or “boxes”

One measure of a language’s usefulness is how much can be done with it thanks to third parties. ChargeRust Libraries’ Official Repository (called “Boxes”) lists over 60,000 chests. Integer ones are API links to public libraries or frameworks, so Rust can be used as a viable language option with those frameworks. However, the Rust community doesn’t yet provide a detailed organization or ranking of boxes based on their overall quality and usefulness, so you can’t tell what works well without trying things out for yourself or polling the community.

Rust has good IDE support

Again, few developers want to adopt a language with little or no support in the IDE of their choice. That’s why the Rust team created the Rust Language Server, which provides feedback directly from the Rust compiler to IDEs like Microsoft Visual Studio Code.

rust visual studio code IDG

Live feedback in Visual Studio Code from Rust Language Server. Rust Language Server provides more than basic syntax checking; It also defines things like variable usage.

Disadvantages of Rust programming language

Besides all its attractive, powerful and useful capabilities, Rust has its negative sides. Some of these obstructions cause new “crustaceans” (as rust lovers call each other) and old hands alike.

new rust

Rust is still a recent language, having only introduced its 1.0 version in 2015. So, while much of the language’s core syntax and functionality has been hammeredThere’s a lot of other stuff around it that’s still liquid.

asynchronous operationsFor example, work is still in progress at Rust. Some parts of asynchronous are more mature than others, and many parts are provided via Third Party Components.

Rust is hard to learn

If anything about Rust is most problematic, it’s hard to taste Rust’s metaphors. Ownership, borrowing, and other memory management to imagine a journey Each at the first time. Many beginner Rust programmers have a common rite of passage, “fighting the metaphor-checker”, in which they find out firsthand how careful the compiler is about keeping the changing and immutable things separate.

Rust is complicated

Some of the difficulty comes from how Rost’s metaphors make code more detailed, compared to other languages. For example, string concatenation in Rust is not always as direct as string1+string2. One of the objects may be mutable and the other immutable. Rust tends to insist that the programmer show how to handle such things, rather than letting the compiler guess.

Another example: how Rust and C/C++ work together. Often, Rust is used to connect to existing libraries written in C or C++; A few projects in C and C++ have been rewritten from scratch in Rust. (And when that’s done, you tend to rewrite it incrementally.)

Rust is a systems language

Like C and C++, Rust can be used to write a systems-wide program, as it allows direct memory manipulation. But for some jobs, this is an exaggeration. If you have a job primarily related to I/O, or don’t need machine-level speed, the Rust can be a tough choice for the job. A Python script that takes five minutes to write and one second to execute is a better option for a developer than Rust, which takes half an hour to write a hundredth of a second to run.

rost language roadmap

The Rust team is aware of many of these issues and is working to improve them. For example, to make Rust easier to work with C and C++, the Rust team is looking into whether to extend projects like Link, which automatically creates rust links for C code. The team also has plans to make borrowing and ageing more flexible and easier to understand.

However, Rust succeeds in its goal of providing a systems language that is safe, concurrent, and functional, in ways that other languages ​​don’t, and doing so in ways that complement how developers actually work.

Copyright © 2021 IDG Communications, Inc.

Source link

Leave a Reply

Your email address will not be published.