From: Ian Jackson Date: Tue, 14 May 2019 16:27:25 +0000 (+0100) Subject: finished B X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=419e4532a780680243c4ceec405160bc6663a298;p=talk-2019-ghm-rust.git finished B --- diff --git a/talk.txt b/talk.txt index 9980de0..5eb0dc1 100644 --- a/talk.txt +++ b/talk.txt @@ -63,9 +63,29 @@ Borrows (that is, references) come in two kinds: mutable and immutable. You can have many immutable references at once. A mutable reference permits modification, and provides exclusive access. -[ Borrowing example slide ] https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references +[ Borrowing example slide with mut missing ] ABOVE https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references + +That's what the `mut' is doing in that example. If you leave it out +the compiler complains. This is the Rust `borrow checker' that you +have may have heard about: the part of the compiler which enforces the +object ownership rules. + +Overall, this scheme makes use-after-free and double-free bugs +impossible. You have to work at it to make a memory leak. Rust +programs are safe (by default): you can write bugs, but you cannot +randomly corrupt memory (or otherwise trigger what in C/C++ is called +"undefined behaviour"). The ownership rules even give you safe +multithreading! + +And, the ownership system means that the compiler can often optimise +very aggressively, because it has really good visibility of all the +aliases of and references to the objects its working with. Compared +to garbage collected languages, the ownership system eliminates a lot +of runtime memory management. I have found Rust programs to generally +be very fast. + + -That's what the `mut' is doing in that example.