DEV Community

Cover image for In Case You Don't Know, Rust is The New "C"
Yaser Al-Najjar
Yaser Al-Najjar

Posted on

In Case You Don't Know, Rust is The New "C"

Good read: “Rust is the future of systems programming, C is the new Assembly”: Intel principal engineer, Josh Triplett

I really couldn't see this before, but Rust is a replacement for C/C++, a clean replacement.

Here is Redox OS:

Redox is a Unix-like Operating System written in Rust, aiming to bring the innovations of Rust to a modern microkernel and full set of applications.

redox

And Wasmer is pretty promising for the web world:

GitHub logo wasmerio / wasmer

🚀 Fast, secure, lightweight containers based on WebAssembly


Wasmer is a blazing fast and secure WebAssembly runtime that enables incredibly lightweight containers to run anywhere: from Desktop to the Cloud, Edge and your browser.

  • Secure by default. No file, network, or environment access, unless explicitly enabled.
  • Pluggable. supports WASIX, WASI out of the box.
  • Incredibly Fast. Run WebAssembly at near-native speeds.
  • Embeddable anywhere via Wasmer SDKs

Install Wasmer

curl https://get.wasmer.io -sSfL | sh
Enter fullscreen mode Exit fullscreen mode
Other installation options (Powershell, Brew, Cargo, ...)

Wasmer can be installed from various package managers. Choose the one that fits best for your environment:

  • Powershell (Windows)
    iwr https://win.wasmer.io -useb | iex
    Enter fullscreen mode Exit fullscreen mode
  • Homebrew (macOS, Linux)

    brew install wasmer
    Enter fullscreen mode Exit fullscreen mode
  • Scoop (Windows)

    scoop install wasmer
    Enter fullscreen mode Exit fullscreen mode
  • Chocolatey (Windows)

    choco install wasmer
    Enter fullscreen mode Exit fullscreen mode
  • Cargo binstall

    cargo binstall wasmer-cli
    Enter fullscreen mode Exit fullscreen mode
  • Cargo

    Note: All the available features are described in the wasmer-cli crate docs

    cargo install wasmer-cli
    Enter fullscreen mode Exit fullscreen mode

Looking for more installation options? See the wasmer-install repository to…

Even it might takeover current big C/C++ implementations like this one:

GitHub logo RustPython / RustPython

A Python Interpreter written in Rust

A Python-3 (CPython >= 3.14.0) Interpreter written in Rust 🐍 😱 🤘.

Build Status codecov License: MIT Contributors Discord Shield docs.rs Crates.io dependency status Open in Gitpod

Usage

Check out our online demo running on WebAssembly.

RustPython requires Rust latest stable version (e.g 1.67.1 at February 7th 2023). If you don't currently have Rust installed on your system you can do so by following the instructions at rustup.rs.

To check the version of Rust you're currently running, use rustc --version. If you wish to update rustup update stable will update your Rust installation to the most recent stable release.

To build RustPython locally, first, clone the source code:

git clone https://github.com/RustPython/RustPython
Enter fullscreen mode Exit fullscreen mode

RustPython uses symlinks to manage python libraries in Lib/. If on windows, running the following helps:

git config core.symlinks true
Enter fullscreen mode Exit fullscreen mode

Then you can change into the RustPython directory and run the demo (Note: --release is needed to prevent stack overflow on Windows):

$ cd RustPython
$ cargo run --release demo_closures.py
Enter fullscreen mode Exit fullscreen mode

What other Rust potential use-cases do you see?

Top comments (8)

Collapse
 
skhmt profile image
Mike 🐈‍⬛

I'd like to see a Rust/Gecko/Quantum/SpiderMonkey implementation of Electron (replacing C++/Chromium).

Collapse
 
yaser profile image
Yaser Al-Najjar

I really hope so 🙏

Collapse
 
mcountryman profile image
Marvin Countryman

Checkout servo.org/

Collapse
 
lealhugui profile image
Guilherme Leal

I'm preatty new to Rust, so the obvious question (for me) is: "why Rust over Golang in these cases"?

Collapse
 
nielvandw profile image
Nielvdw • Edited

Golang won't work for these cases. A garbage collector is like a layer on which the rest of the program runs. It's very unstable to bootstrap the GC in an OS kernel BEFORE the kernel runs. Aka you need a kernel first to run a GC, and with Golang you will need the GC first to run the kernel. Similar thing applies to many other systems, the extra GC layer is a continual pain point.

Collapse
 
yaser profile image
Yaser Al-Najjar

Besides what @nielvandw and @buinauskas have already mentioned.

Before writing the post, I've done some research and found that Rust and Go are not competitors.

And I would also wanna add that Go is very very use-case-specific to Google-like products (scalable solutions made by tech gaints like Digital Ocean or Docker).

Collapse
 
buinauskas profile image
Evaldas Buinauskas

AFAIK Rust is faster and is designed to be a systems programming language.

Go, on the other hand, is designed for microservices, web based tasks for high concurrency, easy vertical and horizontal scaling.

Collapse
 
osde8info profile image
Clive Da

no way ! C++ was the new C ! :)