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

🚀 The leading WebAssembly Runtime supporting WASI and Emscripten


Wasmer is a fast and secure WebAssembly runtime that enables super lightweight containers to run anywhere: from Desktop to the Cloud, Edge and IoT devices.

This document is also available in 🇨🇳 中 文 -Chinese🇩🇪 Deutsch-German🇪🇸 Español-Spanish🇫🇷 Français-French🇯🇵 日本 語 -Japanese🇰🇷 한국어 -Korean.

Features

  • Secure by default. No file, network, or environment access, unless explicitly enabled.
  • Supports WASI and Emscripten out of the box.
  • Fast. Run WebAssembly at near-native speeds.
  • Embeddable in multiple programming languages
  • Compliant with latest WebAssembly Proposals (SIMD, Reference Types, Threads, ...)

Install

Wasmer CLI ships as a single executable with no dependencies.

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)

    Enter fullscreen mode Exit fullscreen mode

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

GitHub logo RustPython / RustPython

A Python Interpreter written in Rust

RustPython

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

Build Status codecov License: MIT Contributors Gitter docs.rs Crates.io dependency status WAPM package Open in Gitpod

Usage

Check out our online demo running on WebAssembly.

RustPython requires Rust latest stable version (e.g 1.43.0 at May 24th 2020) To check Rust version: rustc --version If you wish to update rustup update stable.

To build RustPython locally, do the following:

$ git clone https://github.com/RustPython/RustPython
$ cd RustPython
  # --release is needed (at least on windows) to prevent stack overflow
$ cargo run --release demo.py
Hello, RustPython

Or use the interactive shell:

$ cargo run --release
Welcome to rustpython
>>>>> 2+2
4

NOTE: For windows users, please set RUSTPYTHONPATH environment variable as Lib path in project directory. (e.g. When RustPython directory is C:\RustPython, set RUSTPYTHONPATH as C:\RustPython\Lib)

You can also install and run RustPython with the following:

$ cargo install --git https://github.com/RustPython/RustPython
$ rustpython
Welcome to the magnificent Rust Python interpreter
>>>>>

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 ! :)