Rust lang series episode #1 — basics (#rust-series)

in #rust-series8 years ago (edited)

Greetings! Rust programming language is gaining traction and so I’ve decided to write series about it. This is a first episode. I’ll not waste time writing here what’s great about Rust we will see it as we go except just one sentence: Rust is robust strongly typed (not-only) system language with many modern aspects and with above-average memory control. In general, explanation here will be brief but don't worry when you don't need to understand everything at first sight, many aspect will be clearer later on. Enjoy!

Warning

Don't be frustrated with Rust constantly complaining about almost anything but rather appreciate that, it will make you a better programmer and your code will be safer ☺ . I also expect readers to have some analytical thinking, that's basically all you need.

Installation

Check https://www.rust-lang.org/en-US/downloads.html and use proper installation for you, I'm using this one which is suitable for GNU/Linux and OSX.

curl -sSf https://static.rust-lang.org/rustup.sh | sh

Uninstall

If needed, to uninstall Rust you can use this

curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --uninstall

Compiler

I'm using rust 1.11.0 but examples should work with any newer 1.x version

rustc --version
# output
rustc 1.11.0 (9b21dcd6a 2016-08-15)

Source extension — .rs

Rust source files have .rs extension.

Minimal application

As good tradition commands we will start with Hello World (Hello Steemit World in our case) application.

fn main() {
  println!("Hello, Steemit World!");
}

fn is a keyword for a function
main function will be called by default when application is executed
{} is a block, function block in this case similar to many other languages
println!() is a function, resp. macro in this case for printing output to console.

Compilation

Compilation is process where compiler takes our source code, compiles it and if it's without errors it also built here binary executable file.

rustc main.rs

Execution

Now it's time to execute compiled and built binary application

./main

# output
Hello, Steemit World!

Congrats! You did it.
Your rank: Rust novice

That's all for today, thanks for all appreciations, feel free to comment and point out possible mistakes (first 24 hours works the best but any time is fine). God bless your programming skills and stay tuned for next episodes.

Meanwhile you can check more at main Rust site: https://www.rust-lang.org/en-US/

#rust-series
#rust-lang
#rust

Sort:  

Great little series, I hope you continue it! :)

Thank you and yes, I also hope I'll be able to prepare many episodes.

Coin Marketplace

STEEM 0.15
TRX 0.17
JST 0.028
BTC 69075.42
ETH 2475.71
USDT 1.00
SBD 2.35