TNS
VOXPOP
Will JavaScript type annotations kill TypeScript?
The creators of Svelte and Turbo 8 both dropped TS recently saying that "it's not worth it".
Yes: If JavaScript gets type annotations then there's no reason for TypeScript to exist.
0%
No: TypeScript remains the best language for structuring large enterprise applications.
0%
TBD: The existing user base and its corpensource owner means that TypeScript isn’t likely to reach EOL without a putting up a fight.
0%
I hope they both die. I mean, if you really need strong types in the browser then you could leverage WASM and use a real programming language.
0%
I don’t know and I don’t care.
0%
Open Source / Rust / Software Development

Rust and the OS, the Web, Database and Other Languages

Interest in the 2022 Rust conference highlights that various types of projects are embracing the popular programming language.
Nov 21st, 2022 10:49am by
Featued image for: Rust and the OS, the Web, Database and Other Languages
Image via Pixabay.

This is the second of a two-part series. Read Part 1.

Increased interest in the 2022 Rust conference highlights that various types of projects are embracing the popular programming language. It is natural to be curious about the depth of this language and the body of technologies it currently encompasses. This article will point out a few of the highlights.

Could an Operating System Be Written in Rust?

Simply put: Yes, a wide variety of operating systems and OS-like systems are available in Rust. This includes unikernels, hypervisors, other virtual machine technologies and firmware projects.

KataOS from Google is a secure operating system that uses seL4 as the microkernel for security purposes. Performant seL4 is mathematically proven correct against its specification and is notably secure. The pleasant notion of guaranteed integrity, availability and confidentiality is refreshing. Internally, KataOS is also able to dynamically load and run third-party applications built outside of seL4’s CAmkES (component architecture for microkernel-based embedded systems) framework.

The current GitHub release includes most of the KataOS core components:

  • Frameworks used for Rust, such as the sel4-sys crate for seL4 system call APIs.
  • An alternate root server written in Rust.
  • A kernel patch to seL4 to also allow reclaiming memory used by the root server.

The Google reference implementation, called Sparrow, for KataOS allows users to evaluate KataOS on secure hardware platforms. In addition, Sparrow includes a logically secure root of trust built with OpenTitan on a RISC-V architecture.

A further goal of KataOS is its use as the underlying OS in the Android system. The Rust end user and developer base would explode if that comes to fruition.

Redox is one of the older projects of the more traditional OS systems ilk. It offers what appears to be a reasonable jumping-off point for someone interested in a “Linux-like” development platform. A few Redox observations:

  • The current version is 0.7 (we ran 0.6), so not the latest.
  • It’s likely the longest-running Rust OS project.
  • Boots are extremely fast. It took less than 15 seconds in QEMU emulating x86_64 on an M1 ARM.
  • It’s Unix/Linux-like but with a microkernel design, POSIX maybe.
  • It has basic tools internet browser, file editor, file browser, calendar, image viewer.
  • Version 0.6 runs in ~350MB.

Primary source of Table: https://github.com/flosse/rust-os-comparison

Partial Rust OS List
KataOS https://github.com/heron-sense/KataOS
Redox https://github.com/redox-os/redox
Theseus OS https://github.com/theseus-os/Theseus
Tock https://github.com/helena-project/tock
IntermezzOS https://github.com/intermezzos/kernel
Reenix https://github.com/scialex/reenix
Rustboot https://github.com/charliesome/rustboot
RustOS https://github.com/ryanra/RustOS
QuiltOS https://github.com/QuiltOS/QuiltOS
Tifflin / rust_os https://github.com/thepowersgang/rust_os
bkernel https://github.com/rasendubi/bkernel
Quasar https://github.com/LeoTestard/Quasar
SOS https://github.com/hawkw/sos-kernel
Core-os-riscv https://github.com/skyzh/core-os-riscv

Rust and the Web

Anyone with a little exposure to Rust understands that there is much technology available for WebAssembly (Wasm). Many consider this technology a (r)evolutionary web user interface. Rust technologies provide mechanisms to reduce much of the CSS, HTML and JavaScript from web page infrastructure. Since the interweb will continue to be a vital part of many people’s lives, Rust can potentially also offer more security checking and memory safety as it evolves in cyberspace.

Wasm is included as a compile target in many Rust library stack environments. This means that without code changes, your program can run on the web. Bevy, a game development toolkit, is one such environment.

WebGPU is an up-and-coming API that provides easier interfaces for accessing multiple GPUs in your environment. It’s not just for gaming. Many aspects of scientific visualization and integration with augmented reality/virtual reality (AR/VR) technologies will enable much in the way of intelligent visual interactions and design. This will assist those with abundant data in many professions.

Rust also has nice libraries for creating a web service infrastructure. So, whether you’re producing a platform, distributing an API or publishing a website, you have the tools. Actix, Hyper, Iron and Rustless are a few useful tools in this space.

Could a Database Be Written in Rust?

There are many experimental SQL and NoSQL stores implemented in Rust. Several database engines have surfaced giving options to those who would like to fully embrace the language’s power. It is not hard to imagine the fit given the speed and accountability inherent in the environment. SurrealDB (commercial), FeOphant (Postgres-like), Databend (Arrow2) and GlueSQL are a few examples. Many projects that support mobile and IoT environments are likewise coming online. If your dream is a Rust full stack to develop on, it’s on the way. Of course, APIs and drivers exist for most of the mainstream databases as well.

Does Rust Integrate Well with Other Programing Languages?

Rust has a few tailwinds working in its favor. Polyglot APIs have become the norm for development environments and hence backends are written with this in mind. Adding another language API is usually not very difficult in such environments. Because of this, Rust APIs to existing systems are extending the reach of Rust developers.

Well-Reported Language Pairings

Rust seems to be able to augment other languages well, creating efficient hybrid development environments.

C — Rust directly supports developing interfaces to C with its Foreign Function Interface (FFI). You will find it possible in many cases to write near-safe code here as well as implement things like callbacks from C into your Rust code. Additionally, FFI goes well beyond C.

Javascript — In addition to JS and Rust link with WebAssembly, with a bit of search engine magic, it becomes obvious that there are a host of projects and papers with techniques on harmonizing the two environments. There are even JavaScript interpreters/frontends written in Rust. Also apparent are tutorials on building personalized or custom interpreters. Rust can interact pleasantly with any number of languages such as Python, Lua, Erlang, Haskell and more.

Who Is Likely to Use Rust Soon?

Several sectors seem ripe for Rust, particularly where memory safety and performance are critical issues. It will likely be more difficult to justify not using Rust in these endeavors, especially if they are greenfield in nature. As previously mentioned, most industries that heavily use cloud services and software development technologies will probably inadvertently use it along with mobile and web apps.

Beyond the computing and IT sectors, government/defense, IoT/embedded, telecom, health care and education/research seem to stand out. Several trends that IT managers are focusing on may also be beneficial to Rust. For example, cybersecurity and cloud strategies are dominant themes in the long and short term. Rust has strong messages to send for both. New autonomous infrastructure of varied kinds must be met with increased security and stability attributes. This obviously facilitates the best outcomes in public safety and co-ownership of various scales of infrastructure management. This would include civil, smart home, driving, sensors and likely much more.

Manufacturers Ford, GM, BMW, Bosch, Volkswagen, Volvo, Toyota have all joined a new subgroup in Autosar’s Working Group for Functional Safety (WG-SAF), an automotive standards group, that examines Rust’s use in a reference platform.

SAE International set up a task force as well for Rust in the automotive industry for safety-related systems. This is certainly a case where a spot of Rust on your vehicle is welcome.

There are also developments with innovative rail systems. Parallel Systems is in this space allowing dynamic (un)coupling and self-propulsion of individual train cars.

In finance, a useful trading library, Quants/QuantLib, is experiencing oxidation. The term “quants” in the securities (stock) space refers to data experts who program high-speed trading algorithms that generally have priority with market makers over retail traders. While controversial, this shows that Wall Street is watching.

Tangentially, there are at least 25 active crypto-oriented crates in the Rust environment addressing various tokens. In any case, Rust is becoming armed to enter and perhaps bring solutions in this arena. NFTs and EFTs all around!

Entertainment and gaming might seem surprising areas for Rust adoption, but it’s likely in areas such as film processing and game development as well. And you’ll find it in apps for music streaming including a Spotify client, various games, console emulators, and of course, rich game development environments such as Bevy, Fyrox, Piston and Unrust. This seems to be a momentum area. Game on!

Conclusions

There are four key points in this two-part series:

  1. Rust will continue to make powerful inroads in foundational computing infrastructure.
  2. The memory management model is game changing, and you can expect it to be emulated in other languages.
  3. Technologies like Wasm will bring Rust more into the application space.
  4. This advent arrives with a trade-off to higher productivity, but this is probably for a limited time.

The Rust team is generally very supportive of newcomers, and it is rewarding to work with a nascent technology. Rust uses both Discord and Zulip for chat. Find out how to jump in here. Don’t be afraid to get your hands rusty.

My humble thanks to Zongfang Lin, Yan Zhang and Yan Chen of Futurewei for their contributions on KataOS details and language performance analysis.

Group Created with Sketch.
TNS owner Insight Partners is an investor in: Pragma, Simply.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.