This solved lots of misunderstandings I had about Rust. It should be placed right in the documentation of the language (at least a link, so one could find it easily and early on the rust book)
This is not just a great video for Rust developers, but a great introduction for all developers into the process' memory layout and workings of the operating system!
Genuinely, thank you SO much for this video. I was banging my head against a wall trying to PRECISELY understand fat pointers, why str is a primitive type, and other low-level questions
Just remember about the memory layout of things like structs. You CANNOT rely on the memory layout or ordering of fields to be a certain way, as it's not defined how it will end up. If you need to rely on this, you need to use things like `#[repr(C)]`. In fact, not even the tuple struct's memory layout is guaranteed. To guarantee it, you would need to use `#[repr(transparent)]`
*UPDATE: This video is re-uploaded with a better audio here* ruclips.net/video/7_o-YRxf_cc/видео.html Corrections: * 6:10, it should be 2^64 - 1 (without parenthesis) * Trait is dynamically sized. Trait object has known size.
28:22 this isn't precise. Gargabe collection (as in JS, Go or Java) does not keep track of refernces. In its cleanup run GC just checks wether there is a reference to this memory or not and after it is finished it forgets about it. Your description fits more to automatic reference counting used by Objective-C and Swift.
* trait objects are dynamically sized types, meaning that their size is known at runtime. Pointer types to trait objects are sized at compile-time but have twice the size of pointers to sized types. Correct me if i got something wrong
I was looking for info on dynamically sized types, but I found so much more in the video. One of the clearest explanations for such confusing concepts in Rust. Great video!
Great video. I wanted to check out Rust for use in userspace applications, however the types seemed too high level and convoluted to me, since I primarily program in C. This video helped visualize the types and allows me to think of them in a more familiar C like way and visualize them in memory. I feel like every languages needs videos like this, as it makes mechanisms within the language more explicit and easy to understand in simpler terms.
this is the best memory video ever made. I downloaded it because of fear to lose it if youtube servers shut down or volcano, earthquake, meteor or something... lifesaving enum memory tip @23:55
Beautiful, I'd consider the topics covered here to be required knowledge, and the video is a nice way to present things that can be difficult to visualize.
Great lecture, but in the future, consider asking a friend to narrate! I know a lot of people don’t like posting themselves online, but many people would probably be happy to help out! :)
It would be awesome if you put more Rust-related videos with the same level of explanation. IMHO there are a lot of videos of Rust internals available on RUclips but only a few like this, are actually understandable by novice Rustaceans.
The mention of "malloc" made me think of the assertions around self-compiled language aspects, something I first remember hearing about with Pascal, then C. I presume then this does not include the libc and some other libraries, or perhaps just not always. I guess if it is a clang compilation, by implication, it's not self-compiled, so perhaps the assertion is it is self-compiled in some environments, or that some copies are self-compiled, or that the core of the compiler is self-compiled, but not all the libraries it uses.
Why the Array(Vec) variant of the Data enum is stored in stack if in the Vector section of the video it was explained that Vectors were stored in the heap so they can grow.
The three elements that constitute the Vec header (pointer to data, length and capacity) are stored on the stack. The Vec elements will be stored in the heap.
@@sreekanthpr thank you!!!!, I watched that section again and now I understood it better. I loved this visual explanation, everyone else does it with charts and words, but having it visually explained like you did totally improves and easies the understanding of these abstractions. Again, thank you!
18:50 Couldn't the compiler get the size for a slice from it's initializer? It should know the size is 2 if I say 0..2. It's something like `constexpr` in C++.
Great video, thanks! At 6:10, there is an error for the address range. The caption reads 2^(64-1), which is incorrect, as it implies 2^63 because of the parenthesis. The parens either needs to be removed, or put around the exponent to be correct.
Is it possible to make borrow-checker to take care of individual structure fields? I mean I want to pass the whole structure mutable reference in/out for functions, but to make the borrow-checker to care about what fields has been modified. Is it?
why does the kernel add some paddings in memory when storing enums. I know it's to have the same size for every enum type. but why do we have to have the same size?
Appreciate if you could explain the way Rust return structs created in stack. Does the entire struct members get copied from lower stack frame to the upper ( caller ) ?
Yes, Rust will copy the whatever is stored in the stack for that struct. If there's something in the heap (eg. if one field is a String), that is not copied. The heap part of a data structure is copied only if you explicitly call the `.clone()` method.
This solved lots of misunderstandings I had about Rust. It should be placed right in the documentation of the language (at least a link, so one could find it easily and early on the rust book)
Maybe the ownership is different, but everything else is school thing explained here.
@@MrEnsiferum77 could you point me to a program or a book where theese things are taught to people?
This was extremely enlightening in visualizing rust's memory model. Thank you for taking the time to create this!
This is not just a great video for Rust developers, but a great introduction for all developers into the process' memory layout and workings of the operating system!
Fax
这个视频实在讲的太好了,解答了我好多关于Rust的疑惑以及Java中的一些疑惑!!追过来点赞
Genuinely, thank you SO much for this video. I was banging my head against a wall trying to PRECISELY understand fat pointers, why str is a primitive type, and other low-level questions
Just remember about the memory layout of things like structs. You CANNOT rely on the memory layout or ordering of fields to be a certain way, as it's not defined how it will end up. If you need to rely on this, you need to use things like `#[repr(C)]`.
In fact, not even the tuple struct's memory layout is guaranteed. To guarantee it, you would need to use `#[repr(transparent)]`
*UPDATE: This video is re-uploaded with a better audio here* ruclips.net/video/7_o-YRxf_cc/видео.html
Corrections:
* 6:10, it should be 2^64 - 1 (without parenthesis)
* Trait is dynamically sized. Trait object has known size.
28:22 this isn't precise. Gargabe collection (as in JS, Go or Java) does not keep track of refernces. In its cleanup run GC just checks wether there is a reference to this memory or not and after it is finished it forgets about it. Your description fits more to automatic reference counting used by Objective-C and Swift.
by which software are the pictures drawn?
@@shumudu5377 For this video, I used Powerpoint. For all other videos in this channel, I use manim library (Python).
at 28:10, I suppose the indices should be 0, 1, 2 instead of 0, 2, 3.
btw great video, thanks you ❤
* trait objects are dynamically sized types, meaning that their size is known at runtime.
Pointer types to trait objects are sized at compile-time but have twice the size of pointers to sized types.
Correct me if i got something wrong
I was confused about box, rc, and arc until now. Thanks!
I'm really impressed, what a great content avaliable for FREE! Please keep up uploading videos.
Wow, I really love this. Nice refresher of multiple topics even for someone who is intermediate-advanced rust user.
Definitely the best Rust video on RUclips. I will keep this video and watch again and again! 감사합니다🙏
Thank you Sreekanth. Coming from a C background, this really helped me understand what Rust is about.
I was looking for info on dynamically sized types, but I found so much more in the video. One of the clearest explanations for such confusing concepts in Rust. Great video!
The best video on vtable , Smart pointers, trait object..Awesome job. Thanks
Great video. I wanted to check out Rust for use in userspace applications, however the types seemed too high level and convoluted to me, since I primarily program in C. This video helped visualize the types and allows me to think of them in a more familiar C like way and visualize them in memory. I feel like every languages needs videos like this, as it makes mechanisms within the language more explicit and easy to understand in simpler terms.
Jesus Christ. This is so awesome explanation. Thanks to you I can be now understanding how stack and heap grows up
This video will remain as the best go-to video for new rustaceans! Excellent work Sreekanth!!!
A nice overview and/or refresher.
This is very clear and great explanation on rust memory management. thanks for the explanations
Thank a lot, this makes learning Rust a lot easier. The less magic the better.
Very useful and nice depiction of memory layout of each data type. It should be placed right inside the documentation
Rust is the way forward and this is a great piece of work. Thanks.
this is the best memory video ever made. I downloaded it because of fear to lose it if youtube servers shut down or volcano, earthquake, meteor or something... lifesaving enum memory tip @23:55
Beautiful, I'd consider the topics covered here to be required knowledge, and the video is a nice way to present things that can be difficult to visualize.
finally I've understood strings in rust. thank you a lot!
Great lecture, but in the future, consider asking a friend to narrate! I know a lot of people don’t like posting themselves online, but many people would probably be happy to help out! :)
Hey! Great video! I’d love to do a voiceover for this to make it easier to listen to.
Thanks for this. It is brilliant!
Hats off for making everything clear🙌 You're extremely talented. You're able to explain things logically by providing reasons. Thanks❤️
Really appreciate this video, thank you
Easy to understand video for complex concepts. Thanks for sharing.
It would be awesome if you put more Rust-related videos with the same level of explanation. IMHO there are a lot of videos of Rust internals available on RUclips but only a few like this, are actually understandable by novice Rustaceans.
This video help me understand rust memory a lot , thanks ~
Extremly well delivered information with not a single wasted second. Very good work!
This is worth more than some of computer arch classes at university.👍
Visualization helps a lot, thanks!
I recently started with rust and holy shit i can'ttell how helpful this was
Your video helped me a lot. Thank you.
This video is so good and easy to understand
the best introduction has ever seen.
This is the best explain to Rust
The best video!!! Thnx
This video is gold. Thanks for the hard work!
This video is beautiful
Wonderful. So thorough.
This is awesome! I didn't know that I needed this that badly! Thanks for sharing this great work!
Such wisdom, oh great one.
Nice work! Hope to see more Rust videos from you.
This is gold! Congrats :)
Bro this was so cool, loved the video even tho it was with an AI voice, usually dont like those but the content was NOICE
We rustacean loved it! you should create more videos about rust, like this one!
need more videos like this
Great explanation. Love to see more such deep dive video about Rust.
Amazing video! Would be awesome if you made more videos like this for Rust
awesome explanation 👏👏👏👏👏
This makes so much more sense! Could you please cover RefCell?
bruh I loved this video. thanks for your great content.
The mention of "malloc" made me think of the assertions around self-compiled language aspects, something I first remember hearing about with Pascal, then C. I presume then this does not include the libc and some other libraries, or perhaps just not always. I guess if it is a clang compilation, by implication, it's not self-compiled, so perhaps the assertion is it is self-compiled in some environments, or that some copies are self-compiled, or that the core of the compiler is self-compiled, but not all the libraries it uses.
very informative! thank you
I cannot thank you enough 🙏
thank you for sharing knowledge. appreciate the effort.
very good and clear
This is exactly i want. Thank you!
An unsecure low shy stuttering voice sounds always better than any AI voice.... Remember this for your next videos
This is golden, thanks!
Thank you man for sharing this stuff
This is high quality stuff!
Amazing video thanks.
Wow this is awesome
This is so useful! Thanks
O Captain! My Captain! Are you going to publish a book? I think we need more lectures for memory dynamics.
Wow, honestly incredible
is the first word in each spoken sentence omitted?
love it help me a lot i hope you do cargo next!
Dude, amazing work! Just amazing
Awesome explaination
Thank you! this was very helpful.
Thank you so much
Great explanation! Thanks
It is a cool video. Not only for Rustaceans.
this is the best video I have ever watched on youtube
holy shit this was amazing
Why the Array(Vec) variant of the Data enum is stored in stack if in the Vector section of the video it was explained that Vectors were stored in the heap so they can grow.
The three elements that constitute the Vec header (pointer to data, length and capacity) are stored on the stack. The Vec elements will be stored in the heap.
@@sreekanthpr thank you!!!!, I watched that section again and now I understood it better. I loved this visual explanation, everyone else does it with charts and words, but having it visually explained like you did totally improves and easies the understanding of these abstractions. Again, thank you!
love to learn thanks for sharing
just beca a subscriber keep up the good work Sir.
good stuff, thank you very much
Thanks!
What tts do you use?
Microsoft one note >> View >> Immersive reader
great work, very helpful for me
Enlightening! Thank you!
That was very useful 👍
18:50 Couldn't the compiler get the size for a slice from it's initializer? It should know the size is 2 if I say 0..2. It's something like `constexpr` in C++.
can u upload same kind of video for cpp r/l values / move semantics?
Thanks!!! Your video is too good
Could you put it in the video description of what NTTS model/engine you are using to dub this amazing video?
I use Microsoft onenote/word >> View >> Immersive Reader
extremely well done video!
Great video, thanks!
At 6:10, there is an error for the address range. The caption reads 2^(64-1), which is incorrect, as it implies 2^63 because of the parenthesis. The parens either needs to be removed, or put around the exponent to be correct.
Thank you. Happened during the final subtitle edits. It was written in words for generating the sound in the original text.
Is it possible to make borrow-checker to take care of individual structure fields? I mean I want to pass the whole structure mutable reference in/out for functions, but to make the borrow-checker to care about what fields has been modified. Is it?
why does the kernel add some paddings in memory when storing enums. I know it's to have the same size for every enum type. but why do we have to have the same size?
Appreciate if you could explain the way Rust return structs created in stack. Does the entire struct members get copied from lower stack frame to the upper ( caller ) ?
Yes, Rust will copy the whatever is stored in the stack for that struct. If there's something in the heap (eg. if one field is a String), that is not copied. The heap part of a data structure is copied only if you explicitly call the `.clone()` method.
I was looking forward to this video wehn seeing the title and then bam! Text to speech 😢
The video was cool anyways
Great ty ty