The company teased that it will have more news about the console release of Rust sometime in 2021, so fans will need to wait for that upcoming announcement to learn anything concrete. Don’t forget to read the second post, where I’ll focus on the full-stack aspect of Rust.
Rust positions itself as an effective programming language targeting all performance, reliability and productivity. Performance means that Rust programs should be able to run without overhead, both in terms of pure speed or memory usage.
While B-tree maps are quite efficient, it’s much harder to write a generic B-tree library in C than in Rust due to the type system, so C programs often end up with less optimized structures like red-black trees. Another example is the Yashmak structure of Rust, which now implements a port of Google’s Swiss Tables, and is therefore more efficient than std::unordered_map in C++.
The first aspect that makes Rust a programming language of choice for a wide range of use cases is that it works on many platforms. The three most common systems for desktops (including laptops and servers) are in the tier 1 of supported platforms.
If you have a Windows, Linux or OSX system released in the last 10 years, Rust is “guaranteed to work” on it, thanks to exhaustive automated testing. The integration model is essentially to build a native library written in Rust (rather than in C/C++), and invoke it from the main Android/iOS application.
I haven’t looked at it in detail yet, but there is an online book to get started with Web Assembly in Rust. They constitute the lowest level of software that interacts with hardware components, which includes things like firmware, operating system kernels or bootloaders.
With no_std, you can simply do some “basic” operations such as manipulating memory, performing arithmetic, and of course having control flow. Compare this to languages like Java or Python, for which you need to ship a virtual machine and/or a runtime on a platform before you can run programs on it.
For example, concepts like java.Io. File simply don’t exist without a supporting OS to provide a file system. Some target systems I mentioned so far are made possible by the ability of Rust to interface with other programming languages.
This is done via simple annotations such as ex tern “C” or #, as well as support libraries such as the std::FFI module and the LBC crate. It’s useful for applications such as monitoring performance, implementing load balancing, mitigating DDoS, etc.
As an example, the AFCEL crate provides a GP GPU computing platform based on Cuba. First, Rust hides a lot of platform -specific elements behind meaningful abstractions in the standard library.
For example, the u32::trailing_zeros function, which counts the number of zero bits at the end of a 32-bit integer, looks quite specific. In C/C++, you would have to support that yourself, and either have plenty of custom #if def in your code to check for various compilers and target systems, or just give up and implement the slow naive loop.
All “This Week in Glean” blog posts are listed in the Twig index. One thing I wanted to achieve with that talk is putting that knowledge out there.
We can generate the full API documentation thanks to rustdoc, and we rely on Clippy to tell us when our code is suboptimal. While glean-core is pure Rust, it doesn’t actually provide the nice API we intend for users of Glean.
It’s a translation between the proper Rust API of glean-core and C-compatible functions exposed into the dynamic library. Ffi-support knows how to translate between Rust and C types, offers a nice (and safer) abstraction for C strings.
Instead, we use opaque handles that index into a map held inside the FFI crate. The nice API calls into the Glean SDK using the exposed FFI functions of glean-ffi.
Unfortunately at the moment different language implementations carry different amounts of actual logic in them. Uniffi is a current experiment for a multi-language bindings generator for Rust we might end up using.
The Glean SDK is our approach to build a modern Telemetry library, used in Mozilla's mobile products and soon in Firefox on Desktop as well. We can generate the full API documentation thanks to rustdoc, and we rely on Clippy to tell us when our code is suboptimal.
While glean-core is pure Rust, it doesn't actually provide the nice API we intend for users of Glean. It's a translation between the proper Rust API of glean-core and C-compatible functions exposed into the dynamic library.
Ffi-support knows how to translate between Rust and C types, offers a nice (and safer) abstraction for C strings. Instead, we use opaque handles that index into a map held inside the FFI crate.
The nice API calls into the Glean SDK using the exposed FFI functions of glean-ffi. Unfortunately at the moment different language implementations carry different amounts of actual logic in them.