setup rustc

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

hostnamectl; # also tested on
Operating System: Debian GNU/Linux 12 (bookworm)  
          Kernel: Linux 6.1.0-13-amd64
    Architecture: x86-64

# also tested with Operating System: Debian GNU/Linux 11 (bullseye)
su - root;
apt update;
apt install build-essential;
# otherwise error "linker cc not found"

# logout root Ctrl+D
# to become default user again
# root not needed to install rustc
# rusct will install per-user, not system-wide
# install rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# if that "hangs" try this
wget https://sh.rustup.rs
move index.html rust-setup.sh
chmod +x rust-setup.sh
./rust-setup.sh
# will download ~200MBytes

# should show:
Rust is installed now. Great!
# restart current terminal/shell (not optional)
# to reload env variables and find the correct path to rust binary
# source "$HOME/.cargo/env"
Ctrl+D # quit
# start new terminal MATE Desktop: Alt+F2 -> term
cd; # change to one's home dir

rustc --version; # debian12: test it works
rustc 1.74.0 (79e9716c9 2023-11-13)

getting started:

rustup update; # trigger manual rustc update

# point browser to offline docs
rustup docs --book

offline documentation can be found here:

file:///home/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html/book/ch00-00-introduction.html

now what to do with it?

GNU Linux (Debian) – how to – find the largest 30 duplicate files wasting disk space – multi line sorting madness (mlsm) – how to output x blocks of text separated by delimiter – build (Bill Poser’s and BSDs) msort from src

getting started links:

https://tourofrust.com/index.html

https://github.com/rust-lang/rustlings

https://github.com/rust-unofficial/patterns

https://ferrous-systems.github.io/teaching-material/overview.html

hello world:

let’s create one’s first program:

# create a folder to hold all projects (workspace)
mkdir /projects;

cd /projects;

# create new folder for project "hello world"
mkdir hello_world;
cd hello_world;

# optional, but recommended because it makes
# colorful source code is much more pleasant to look at :)

apt install git; # install git
# enable rust compatible syntax highlighting in vim
git clone https://github.com/rust-lang/rust.vim ~/.vim/pack/plugins/start/rust.vim
# create first source file
vim hello_world.rs

# fill with
fn main()
	{
		println!("Hello World!");
	}
:wq # write and quit
# compile it!
rustc hello_world.rs

# check results:
ll

# run it
./hello_world
Hello World!
# HURRAY! :)
# now why is it 2.4MBytes in size?
# because it has a lot of debug symbols in it
strip ./hello_world
# strip removes those and binary now 10% 215KBytes

would recommend the online documentary:
https://doc.rust-lang.org/stable/book/ch01-02-hello-world.html

is vim a bad ide?

it even can do auto complete, type part of a word, hit Ctrl+P

Rust-Links:

show me the src: https://github.com/rust-lang/rust

official website: https://www.rust-lang.org/

official forum: https://users.rust-lang.org/

how-to-conduct: https://www.rust-lang.org/policies/code-of-conduct

news/stay updated: https://blog.rust-lang.org/

via rss:

https://blog.rust-lang.org/inside-rust/feed.xml

https://blog.rust-lang.org/feed.xml

https://this-week-in-rust.org/rss.xml

samples/examples/to the book: https://github.com/ProgrammingRust

reference: https://doc.rust-lang.org/cargo/reference/manifest.html

RFCs: https://github.com/rust-lang/rfcs

rust-foundation: https://foundation.rust-lang.org/

her blog: https://github.com/edunham

book: https://github.com/rustwasm/book

Austria rust community: https://rust-linz.at/

wiki: https://en.wikipedia.org/wiki/Rust_(programming_language)

https://www.infoworld.com/article/3247799/what-is-llvm-the-power-behind-swift-rust-clang-and-more.html

https://flames-of-code.netlify.com/blog/rust-and-cmake/

Why RUST?

DebConf 2019: Yes even a Python programmer should learn rust! https://ytpak.net/watch?v=IYLf8lUqR40

is Rust safer than C/C++?

“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)

if one is viewing this site using Firefox or Gecko-Engine… one is running RUST already.

At the beginning – one was big fan of Java – Java was/still is all the rage – theoretically write once – run anywhere linux, osx and (thanks to Google) on mobile and even on the closed source OS who’s name shall not be mentioned, nobody knows what the Java Virtual Machine does besides running bytecode, Java on slow ARM CPUs is kind of a burden.

Here comes RUST.

About RUST: it’s a lengthy talk so take some time… or go into parts.

how to keep a good culture at Open Source:

pros:

+ rust promises the same and even more cross os compatibility than java (even ARM and RISCV! (OSX not officially supported but it seems someone cross compiled OSX binaries via Ubuntu))

+ faster than Java, almost as fast as C (binaries are larger than those of C or C++)

+ safer than C and C++

+ cargo and crates: comes with online colaboration and code sharing tool

cons:

– syntax looks as ugly as C++ to this user X-D

– rust programs can not use a GUI yet

– sorry to say – the least sexy name – someone EVER has given an programming language X-D (next time call it “dirt” or “crap” or “cancer” X-D)

  1. why would one name a language after corroded (oxidized) metal and give it a pet that can be pronounced “crap”?
  2. “crab” in German is “Krebs” and the general name for cancer (sorry Brian X-D really love your work and blog, advice: just marry someone and adopt another name)

Tweets:

straight from the creator:

probably the right dunham?

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!
admin