is Rust safer than C/C++?

“show me the src”

DebConf 2019: Why would a python programmer learn rust when there are no jobs in it

“This means no matter what language you use, the only safe way is to keep in mind: stop doing stupid things.” (src)

Update 2020-08: “Through the past five years of experimentation, I’ve gone from intrigued, to optimistic, to convinced that Rust is an ideal language to build industrial grade, bulletproof bare metal software.

Beyond that, I’ve come to realize that even the highest level constructs that the base language offers are applicable to firmware development, very much unlike other languages that span a wide range of paradigms (I’m looking at you, C++). There are a few reasons I felt this way:

  • Rust’s safety guarantees and general strictness bring the debug time down significantly, so there’s less need to spend time developing mental maps of how high level constructs correspond to hardware primitives.
  • The type system is great at enforcing local reasoning and preventing leaky abstractions. Building decoupled systems with no runtime cost is easy.
  • The compiler error messages are worthy of an AI assistant with concerning mind-reading abilities.” (src)

Rust is a multi-paradigm system programming language[14] focused on safety and performance, especially safe concurrency.[15][16]

It is Open Source Apache License Version 2.0, January 2004

Rust is syntactically similar to C++,[17] but is designed to provide better memory safety while maintaining high performance.

Rust was originally designed by Graydon Hoare at Mozilla Research, with contributions from Dave Herman, Brendan Eich, and others.[18][19] The designers refined the language while writing the Servo layout or browser engine[20] and the Rust compiler. The compiler is free and open-source software dual-licensed under the MIT License and Apache License 2.0.

Rust was the “most loved programming language” in the Stack Overflow Developer Survey for 2016, 2017, 2018, and 2019.[21][22][23][24]

Introduction to Rust at 2017

presented by E. Dunham …with harme and wit 🙂

  • speed
  • safety
  • don’t be a jerk

PyCon 2019 AU:


The language grew out of a personal project begun in 2006 by Mozilla employee Graydon Hoare,[16] who stated that the project was possibly named after the rust family of fungi.[38]

Mozilla began sponsoring the project in 2009[16] and announced it in 2010.[39][40]

Named rustc, it successfully compiled itself in 2011.[42]

stable point releases are delivered every six weeks

while features are developed in nightly Rust and then tested with alpha and beta releases that last six weeks.[46]

Along with conventional static typing, before version 0.4, Rust also supported typestates.

The typestate system modeled assertions before and after program statements, through use of a special



Discrepancies could be discovered at compile time, rather than when a program was running, as might be the case with assertions in C or C++ code.

In January 2014, the editor-in-chief of Dr Dobb’s, Andrew Binstock, commented on Rust’s chances to become a competitor to C++, and to the other upcoming languages D, Go and Nim (then Nimrod).

According to Binstock, while Rust was “widely viewed as a remarkably elegant language”, adoption slowed because it changed repeatedly between versions.[49]

Rust was the third-most-loved programming language in the 2015 Stack Overflow annual survey,[50] and took first place in 2016, 2017, 2018, and 2019.[51][52][53][54]

The language is referenced in The Book of Mozilla as “oxidised metal”.[55]

getting started: Examples

one can run the examples in the online editor:


setup rust compiler:

highly recommend setting this up in a virtual machine, that once it is set up, can be moved to various machines where one intends to work. (laptop, desktop, ultratop, megatop, hypertop, gigatop)

as non-root user, download and run the setup script, warning! this will download ~100 MBytes of Data! (one might want to do this with connections of fast and inexpensive bandwidth)

install procedures for rust (usually a one-liner) change from time to time please checkout the website for up-to-date-howto-install:

hostnamectl; # tested on
  Operating System: Debian GNU/Linux 10 (buster)
            Kernel: Linux 4.19.0-17-amd64
      Architecture: x86-64

# as non-root user
# go into one's home directory
# download rust setup script
curl -o
chmod +x
# start it
sh ./

# all in one go
curl --proto '=https' --tlsv1.2 -sSf | sh

# this will download and install a lot of stuff under /home/user
# 85 Mbytes rustc
# 61 MBytes rust-std
# 4.6 MBytes cargo
# 11 MBytes rust-docs
# if one wants to reinstall
# (fix error: "no default toolchain configured")
# rustup install stable
# rustup default stable

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source $HOME/.cargo/env
# download more stuff
# fix error in eclipse during project creation:
# "Install missing rls component in Rustup"
rustup component add rls

# verify one can run the rust compiler by
rustc --version
rustc 1.53.0 (53cb7b09b 2021-06-17)

# rust gets installed on a per-user basis
# if for some reason the user's .profile get's ignored
# per-user (only current non-root user can use rust)
# manually modifying the PATH env variable
# (that should have a path pointing to where the rust compiler is located)
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile

# this is the same but global (for all users)
echo 'export PATH="/home/user/.cargo/bin:$PATH"' >> /etc/bash.bashrc
# 3x hurrays and atleast a 30sec dance :) when it works :)

get organized

one recommends to create a projects folder (eclipse calls it “workspace” where all projects reside in)

this should probably also be in one’s home folder, but out of shier crazyness will create this under /

# create workspace folder
mkdir -p /projects/devrust

# create folder for project
mkdir /projects/devrust/helloworld

# go into that folder
cd /projects/devrust/helloworld

Hello World

Here is a simple “Hello, World!” program written in Rust. The println! macro prints the message to standard output.

so simply do vim and insert this content:

fn main() {
    println!("Hello World");

when done, one can compile it to binary.

# will generate a 2.4MByte binary
# run it
Hello World

# dance! dance! dance! hurray we did it
# as user might have noticed
# the binary is rather large
du -hs ./helloworld
2.8M ./helloworld

# because it contains a lot of debugging symbols
# strip those symbols
strip ./helloworld
du -hs ./helloworld
236K ./helloworld

Factorial function


fn factorial(i: u64) -> u64 {
    match i {
        0 => 1,
        n => n * factorial(n-1)


fn factorial(i: u64) -> u64 {
    let mut acc = 1;
    for num in 2..=i {
        acc *= num;

Using iterators

fn factorial(i: u64) -> u64 {

What IDE would one use?

either emacs or vim of course X-D

step debugging rust in vim

How to step debug debugging rust in vim 8.1


what other ides can do rust?

eclipse is a great IDE contributed by “BigBlue” IBM

with massive amounts of features and probably the best file and version-compare “screen” ever seen… (which allows with hotkeys to move lines from left to right with Ctrl+Alt + CursorLeft (<-) and CursorRight(->))

but it also has disadvantages…

  • it has almost unlimited ways of “mutating” into supporting almost any language and a lot of tool, BUT (!) this integration/setup of languages and tools often do not “just work”
  • it is another very big and thus CPU and RAM hungry (aka slow) Java program

Build it in Rust

In 2018, the Rust community decided to improve programming experience for a few distinct domains (see the 2018 roadmap). For these, you can find many high-quality crates and some awesome guides on how to get started.

Command Line

Whip up a CLI tool quickly with Rust’s robust ecosystem. Rust helps you maintain your app with confidence and distribute it with ease.

Learn More


Use Rust to supercharge your JavaScript, one module at a time. Publish to npm, bundle with webpack, and you’re off to the races.

Learn More


Predictable performance. Tiny resource footprint. Rock-solid reliability. Rust is great for network services.

Learn More


Targeting low-resource devices? Need low-level control without giving up high-level conveniences? Rust has you covered.

Learn More

Read Rust

We love documentation! Take a look at the books available online, as well as key blog posts and user guides.

Read the book

Watch Rust

The Rust community has a dedicated YouTube channel collecting a huge range of presentations and tutorials.

Watch the Videos

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!