This document provides an overview of the Go and Rust programming languages. It discusses Go's history from 1973 to present day and compares features of Go and Rust such as performance, concurrency, and memory management. Rust is highlighted as a potential replacement for C due to its prevention of common security vulnerabilities like buffer overflows through its borrowing system and garbage collection. The document advocates adding Rust to one's toolbox of programming languages.
33. ● Use after free
● Double free
● Memory leaks
● Buffer overreads/overwrites
● Null pointers
● Data races
34.
35. “Around 70 percent of all the
vulnerabilities in Microsoft
products addressed through a
security update each year are
memory safety issues”
Matt Mileer, MS security engineer ZDNet, 11.02.2019
39. fn main() {
let x = String::from("Go!");
println!("{}", x);
}
40. fn main() {
let x = String::from("Go!");
println!("{}", x);
}
41. fn main() {
let x = String::from("Go!");
println!("{}", x);
}
42. fn main() {
let x = String::from("Go!");
println!("{}", x);
}
43. fn main() {
let x = String::from("Go!");
println!("{}", x);
} Memory get’s FREE!
44. fn main() {
let x = String::from("Go!");
let y = x;
println!("{}", x);
println!("{}", y);
}
45. fn main() {
let x = String::from("Go!");
let y = x;
println!("{}", x);
}
error[E0382]: borrow of moved value:`x`
^ value borrowed
here after move
46. fn main() {
let x = String::from("Go!");
let y = x;
println!("{}", x);
println!("{}", y);
}
Move ownership x → y
47. fn main() {
let x = String::from("Go!");
let y = &x;
println!("{}", x);
println!("{}", y);
}
Immutable borrow
48.
49. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
50. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
Immutable borrow
51. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
52. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
53. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
54. fn main() {
let mut v = vec![1, 2, 3];
let v2 = &v;
v.push(4);
println!("{:?}", v2);
println!("{:?}", v);
}
error[E0502]: cannot borrow `v` as
mutable because it is also borrowed as
immutable
| ^^^^^^^^^ mutable borrow occurs
here
80. Rust Book
Community
Diving Into Rust For The First Time
A Case for Oxidation: The Rust Programming Language
Rust: A Language for the Next 40 Years - Carol Nichols
#rust-beginners http://irc.mozilla.org/