Rust does all that, and more, in its standard library. But C and C++ users expect to have a decent standard library-they want to be able to use containers, collections, and iterators, perform string manipulations, manage processes and threading, perform network and file I/O, and so on. One part of Rust’s larger mission is to encourage C and C++ developers to use Rust instead of those languages whenever possible. Some features found in other languages, like inline asembler, are also available, albeit under Rust's “unsafe” label. Rust’s native language features compare favorably to what languages like C++ have: Macros, generics, pattern matching, and composition (via “ traits”) are all first-class citizens in Rust. Rust has powerful language featuresįew developers want to start work in a new language if they find it has fewer, or weaker, features than the ones they’re used to. Also, although Rust works on the majority of current platforms, it’s not its creators’ goal to have Rust compile absolutely everywhere-just on whatever platforms are popular, and wherever they don’t have to make unnecessary compromises to the language to do so. If you want to cross-compile, or produce binaries for a different architecture or platform than the one you’re currently running, little additional work is involved, but one of Rust’s general missions is to minimize the amount of heavy lifting needed for such work. Rust works on all three major platforms: Linux, Windows, and MacOS. Microsoft Windows users are not second-class citizens, either the Rust tool chain is as capable there as it is on Linux and MacOS. External compilers, like GCC, are needed only if you are compiling other components outside the Rust ecosystem (such as a C library that you’re compiling from source). That’s why Rust’s developers and community have tried to make the language as useful and welcoming as possible to newcomers.Įverything needed to produce Rust binaries comes in the same package. None of Rust’s safety and integrity features add up to much if they aren’t used. Even then, you almost never have to take off the seatbelts for common use cases, so the end result is software that’s safer by default. The key word is partly, because Rust’s memory safety operations can never be completely disabled. Rust’s safeties can be partly suspended where you need to manipulate memory directly, such as dereferencing a raw pointer à la C/C++. Rust lets you live dangerously if you need to, to a point. (That also gives Rust another performance boost.) Rust is flexible The ownership approach also means that Rust does not require garbage-collected memory management, as in languages like Go or C#. The way ownership is transferred between objects is strictly governed by the compiler, so there are no surprises at runtime in the form of memory-allocation errors. Every bit of memory in a Rust program is tracked and released automatically through the ownership metaphor. Any given value in the language can be “owned,” or held and manipulated, only by a single variable at a time. Rust’s memory-management system is expressed in the language’s syntax through a metaphor called ownership. Rust controls memory management via strict rules. The compiler flags those issues and forces them to be fixed before the program ever runs. Rust’s syntax and language metaphors ensure that common memory-related problems in other languages-null or dangling pointers, data races, and so on-never make it into production. Most memory errors are discovered when a program is running. Rust won’t compile programs that attempt unsafe memory usage. Binaries are self-contained, with no external runtime apart from what the OS might provide, and the generated code is meant to perform as well as comparable code written in C or C++. Rust code compiles to native machine code across multiple platforms. Rust accomplishes its safety, speed, and ease of use through the following characteristics. A few key reasons drove that decision: Firefox deserved to make better use of modern, multicore processors and the sheer ubiquity of web browsers means they need to be safe to use.īut those benefits are needed by all software, not just browsers, which is why Rust evolved into a full-blown language project from a browser component project. Rust started as a Mozilla research project partly meant to reimplement key components of the Firefox browser.
0 Comments
Leave a Reply. |