Introduction To Rust: Adityo Pratomo (@kotakmakan)
Introduction To Rust: Adityo Pratomo (@kotakmakan)
AdityoPratomo(@kotakmakan)
ThisTalkisAlsoAvailable
at
github.com/froyoframework/rust-intro/slide
Background
Chief Academic O cer at Framework
Chief Technology O cer at Labtek Indie
Certi ed Unity Developer
Framework
Providing software development course, training and workshop
Based in BSD
Codewise,I'm
Generalist
Creative Coder
C/C++, Java, JS
WhenIMeetRust
Fast and safe system programming language
Like C++, without segfaults (yum!)
Better handling of reference and pointers
Mixture of imperative and functional paradigm
WhattoDowithRust?
System programming
Something low-level enough to bene t from precise memory
management
Web Browser (Mozilla Firefox)
Distributed storage system (Dropbox)
3D Games
Device drive
Operating System
General tool
Rust'sKillerFeatures
Concept of "Borrowing and Ownership"
Type safety
Memory safety
Zero-cost abstractions
Pattern matching
HowRustisFastandSafe?
Extensive compiler checking
Fast: No garbage collection, Rust automatically detect when to free
memory
Lifetime
Ownership of data
Safe: No data race, guaranteed data lifetime, no dangling-pointer
Ownership and Borrowing only allows one mutable reference
(write access)
AlsoinRust
Built-in unit testing
Cargo: Rust's built-in package and build manager
Helpful error messages in compiler
ATourofRust'sSyntax
github.com/froyoframework/rust-intro/basic-rust-sample
Variable
Variable by default is immutable
A binding to value exists
let angka = 9;
let salam = "Selamat datang, Android no ";
let halo = format!("{} {}", salam, angka);
println!("{:?}", halo);
Function
Return value in function is explicitly denoted using arrow
The returned value is the last variable stated without semicolon
let angka_saya = calc(angka);
};
pemain_saya
}
pemain_favorit
}