Rust: Smart Pointers, Linked Lists - CS196 SP20

  Рет қаралды 10,406

CS Honors @ Illinois

CS Honors @ Illinois

Күн бұрын

Пікірлер: 26
@Muaahaa
@Muaahaa 2 жыл бұрын
The other day I thought, "creating a linked list type will be a nice exercise as a Rust beginner". Didn't take too long to realize it wasn't going to be nearly as obvious as I expected XD
@shivenigma
@shivenigma 3 жыл бұрын
5 minutes in and I love this video already. The folks who can attend classes in this university and with this teacher are really lucky. Good luck to y'all. Thanks for the great video.
@Titere05
@Titere05 Жыл бұрын
Finally I really understand what a box is. I don't get why nobody said to me, a box is a smart pointer. So simple
@flippert0
@flippert0 11 ай бұрын
Java doesn't run into the problem of infinite recursion, bc. in the class body, the "List next" ist implicitly a reference (or "pointer"), so not a full definition, so there's no recursion actually. In Rust, the pointer/reference must be made explicit. Haskell avoids the same recursion problem by "Lazy Evaluation". When it sees the same type within a type definition, it says: "as long as there's no actualy evaluation, but only a type declaration, I don't need to follow that recursion".
@andrew121410
@andrew121410 4 жыл бұрын
I’m 17 years old and I know Java completely and started learning rust like 4 days ago your lectures are very good thank you!
@ClearerThanMud
@ClearerThanMud 4 жыл бұрын
Thanks for these videos, Sami. The comparison with Java around 5:30 might have been clearer -- and fairer -- if the Java version also used generics. Realistically you wouldn't make a Node contain a reference to Object in Java. Showing side-by-side *generic* code in Java and Rust would allow you to focus on the *relevant* differences between the two languages.
@cshonorsillinois2080
@cshonorsillinois2080 4 жыл бұрын
Thank you for the feedback and definitely something I will fix for next semester! I wasn't sure if the students knew about Java generics or not when I used the example but I suppose if I'm already using it in the Rust example it only makes sense to have them both that way.
@ajinkyax
@ajinkyax 4 жыл бұрын
Thanks Sami. Your way of teaching a amazing. RUST
@Ashton351
@Ashton351 4 жыл бұрын
Great course content - thanks!
@ErikBongers
@ErikBongers Жыл бұрын
In the single linked example, the head node will not point to the next node, but a copy of the next node on the heap!
@raymondhill7837
@raymondhill7837 4 жыл бұрын
C++ has smart pointers too! You wouldn't need to automatically clear memories. It's C that doesn't have any in the stdlib.
@cshonorsillinois2080
@cshonorsillinois2080 4 жыл бұрын
This was said at 10:20 The comparison is Rust's Ownership model vs. C++'s raw pointers/ability to leak memory (this along with Concurrency is what Rust is famous for, which is why you'll see this comparison very often in Rust material), not Rust Ownership vs. C++ smart pointers.
@MarcusWillock
@MarcusWillock 4 жыл бұрын
In terms of your face square covering the text, you could play with the transparency of your square so that, even when you cover text, it can be seen.
@MarcusWillock
@MarcusWillock 4 жыл бұрын
Also, thank you for the video!!!
@simonfarre4907
@simonfarre4907 3 жыл бұрын
Technically we can't do multiple owners in safe Rust. Technically, we can only do it using the standard library or implementing the feature itself using unsafe. But, again technically, multiple ownership is impossible using only safe Rust.
@jeffg4686
@jeffg4686 3 жыл бұрын
Rc is the TV remote controller - easy to remember
@asdfasdf9477
@asdfasdf9477 3 жыл бұрын
“Memory blocks touching each other“ didn’t watch any further
@RD-fb6ei
@RD-fb6ei 2 жыл бұрын
My school is teaching racket 😭😭😭
@heater5979
@heater5979 4 жыл бұрын
I love what's going on here. Very useful. But is it possible to silence the terrible music and sound effects during the quizzes. Sounds like some horrible TV quiz show.
@cshonorsillinois2080
@cshonorsillinois2080 4 жыл бұрын
Perhaps we could lower the volume on it a bit 🤔
@redcrafterlppa303
@redcrafterlppa303 2 жыл бұрын
Isn't just one & mut violating the "one writer rule"? let s = string::new() ; let s1 = & mut s; s.push_str("writer1"); s1.push_str("writer2"); So we already have the problem. In my opinion the one writer rule is dumb. Having multiple mutable and immutable refrencees at the same time is often needed and no problem when it comes to memory safety. Since we would still have 1 owner. Many languages work perfectly fine with this. For example in java you could consider every object refrence to be a &mut. Even the simplest of data structure in rust (vec) needs to violate this idiom to exist. The iter_mut() on vec uses unsafe rust because it is impossible to do without it.
@redcrafterlppa303
@redcrafterlppa303 2 жыл бұрын
@PeepNSheep but 2 mutable references wouldn't do anything in terms of memory safety. The owner of the value is still clear. Even if 2 mutable references exist they still can't outlive the owner. Where is the difference between mutable and non mutable references? Sure one can modify the variable but that doesn't effect memory management.
@redcrafterlppa303
@redcrafterlppa303 2 жыл бұрын
@PeepNSheep thats thread safety and not memory safety in aspect of memory leaks and segfaults. It's a completely different topic. And forcing thread safety onto potential single threaded operations or even programs is bothersome and potentially slower. Java for example gives no guarantees for thread safety if you don't explicitly use some sort of mutex. This removes the burden of mutation correctness from single threaded operations.
Rust: Functional programming, Closures - CS196 SP20
39:52
CS Honors @ Illinois
Рет қаралды 2,3 М.
Linked Lists in Rust - CS 128 Honors Lecture 11
13:59
CS Honors @ Illinois
Рет қаралды 2,1 М.
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 100 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 83 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 31 МЛН
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 60 МЛН
Rust: Memory, Ownership, Borrowing - CS196 SP20
50:26
CS Honors @ Illinois
Рет қаралды 4,3 М.
Why You Should AVOID Linked Lists
14:12
ThePrimeTime
Рет қаралды 280 М.
The Box Smart Pointer in Rust
12:18
Let's Get Rusty
Рет қаралды 73 М.
are "smart pointers" actually smart?
9:44
Low Level
Рет қаралды 78 М.
Box / Rc / Arc / Mutex - Smart Pointers Simplified - Rust
23:39
Bocksdin Coding
Рет қаралды 13 М.
Rust: RefCell
20:00
The Dev Method
Рет қаралды 7 М.
Rust Programming Exercises: Double Linked List
22:47
Thomas 🏕
Рет қаралды 8 М.
A Singly Linked List in Rust
1:19:30
Ryan Levick
Рет қаралды 19 М.
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 100 МЛН