Stack/Heap Allocation, Frames, Call Stacks, Recursion - Computer Stuff They Didn't Teach You #12

Поделиться
HTML-код
  • Опубликовано: 27 сен 2024

Комментарии • 172

  • @dirtcorps
    @dirtcorps 4 года назад +166

    Scott - this is like listening to Bob Ross teach code. "How about some happy little binary trees over here" 👨‍🎨
    Thanks for a soothing refresher on these topics.

    • @justjosh42
      @justjosh42 3 года назад

      Came to say the same thing. So relaxing to listen to.

    • @lucianocase6982
      @lucianocase6982 3 года назад

      Instablaster

  • @dosya6601
    @dosya6601 4 года назад +84

    Please make a video about Threads and Async Programming. I know that there are tons of videos on RUclips, however, I would like to hear about these topics from your explanation. Thank you in advance, Scott.

  • @everyonesview
    @everyonesview 4 года назад +16

    You know what, Scott? I always make my world a better place to live with every one of your tutorials. I appreciate you, mate! Please carry on enlightening us - I speak for most of self-taught developers.

  • @The8merp
    @The8merp 4 года назад +5

    This channel has become my favorite programming / tech channel on RUclips, thank you Scott for taking the time to make these videos. I will share this channel with people so they can learn from you as well.

  • @gatsdev
    @gatsdev 4 года назад +3

    Man this is the clearest explanation of call by stack and call by reference.

  • @BryanChance
    @BryanChance 4 года назад +14

    Yes! I remember learning this on my own..:) Most of today's developers (web developers) don't know much about stacks, heap memory management, CPU context switching. "Programmers" (low level) in the traditional sense have to know.

  • @alexanderjohnston8652
    @alexanderjohnston8652 4 года назад

    Scott, you are my personal hero. I'm an adult with a healthy C# career and yet I still want to grow up to be like you one day.
    Thank you from the bottom of my heart for the passion you show for the language and for teaching people. ❤

  • @emmanueladebiyi2109
    @emmanueladebiyi2109 4 года назад

    Way to go, lots of education done here... Suddenly, the call stack doesn't look so magical anymore. Thanks for bringing it down to earth.

  • @Chrisknot94
    @Chrisknot94 4 года назад +12

    "I'll live up here for now" had me laughing more than I want to admit xD

  • @gosnooky
    @gosnooky 4 года назад +29

    "Happy little stack", this guy is the Bob Ross of computers.

    • @aztec7676
      @aztec7676 3 года назад +2

      I was literally going to comment the same thing! This guy puts the stress of learning this stuff at ease. Very informative, fun, and positive videos! Thanks for making these videos!!

  • @hp___n_
    @hp___n_ 2 года назад

    Thank you for your 4 levels knowledge steps and how to deal with it. That's one of the what they didn't teach in school.

  • @amaterasu48
    @amaterasu48 4 года назад +4

    Scott, you always inspire me. Thank you! :)

  • @omri9325
    @omri9325 4 года назад +20

    Do one about processes, threads, OS threads, CPU, cores etc.

    • @shanselman
      @shanselman  4 года назад +5

      Good idea!

    • @greggalf6140
      @greggalf6140 3 года назад

      I support this idea!

    • @zabinitro
      @zabinitro 3 года назад

      @@shanselman something similar for Channels in Go too

  • @polatayd
    @polatayd 3 года назад +3

    Hello Scott, great video! I want to clarify something. At 22:03 you say the object p is being passed by reference. Actually, the Person object is not passed by reference when the DoSomethingCool (p, c) method is called. Only the reference of the object in the heap is passed by value. If DoSomethingCool was called (ref p, c), it would be called by reference, and when a new assignment was made on object p, the object p in the Main method would also be affected.

  • @HabtamuDesalegn
    @HabtamuDesalegn 4 года назад +4

    Thank you! and I am so happy to see Amharic book in your hand. with that I have seen your contribution to Microsoft product features having Amharic language

    • @shanselman
      @shanselman  4 года назад +2

      Habtamu Desalegn Gobez! Amaseganalehu

    • @HabtamuDesalegn
      @HabtamuDesalegn 4 года назад +2

      @@shanselman egnam betam betam enamesegnalen.

  • @DavidGilden
    @DavidGilden 3 года назад

    Excellent presentation I actually learned something I’ve been doing.net for 15 years so thank you!

  • @CannibalWarthog
    @CannibalWarthog 3 года назад +3

    Did Bob Ross cut his hair and start programming?
    This is awesome!

  • @abidanbrito
    @abidanbrito 4 года назад

    Straight to the point and eye-opening examples. If you're open to suggestions, here are some topics I think would make a great fit for the series: floating-point arithmetic, asynchronous programming, memory management / fragmentation, threads / multithreading and bitwise operators.

  • @joels978
    @joels978 3 года назад

    Thanks Scott! Always really informative and enjoyable to watch!

  • @raghavddps2
    @raghavddps2 3 года назад

    Finally youtube recommends great stuff!!

  • @nithinchandran7959
    @nithinchandran7959 4 года назад

    The book analogy really worked for me 😄

  • @hrgwea
    @hrgwea 4 года назад +1

    Technically speaking, a stack is an "Abstract Data Type", not a "Data Structure".
    The difference being that an ADT doesn't specify how the data is structured in memory. You can implement a stack using different data structures, like an array, a linked list or a hash table.

    • @shanselman
      @shanselman  4 года назад

      Thanks! That's a fair comment. I tried to keep it simple but this is a good hair to split!

  • @kamilziemian995
    @kamilziemian995 2 года назад

    Good introduction to this topic.

  • @IK-ow2zk
    @IK-ow2zk 3 года назад

    Thanks a lot for your video, Scott!

  •  3 года назад

    Thanks, I constructed heaps, stacks, trees, nodes and so on, back at the university......

  • @Leofmoura87
    @Leofmoura87 3 года назад

    Thanks Scott, keep it up, you make things really easy to understant!

  • @scotolivera8207
    @scotolivera8207 3 года назад

    For me you are my mentor, thanks

  • @arlvinmoyo9290
    @arlvinmoyo9290 4 года назад

    Great video! Also love the illustrations on how we can use the VS tools like the Diagnostic Tools.

  • @snk-js
    @snk-js 4 года назад +2

    You are helping so much, OMG., I remember i learnt this too

  • @alexvanheerden5702
    @alexvanheerden5702 4 года назад +4

    Also, 6:00. Someone has been doing Ruby 💥

  • @alexvanheerden5702
    @alexvanheerden5702 4 года назад +3

    Hey! As a South African it's cool to see you're learning Zulu or at least trying to! 😝❤

    • @shanselman
      @shanselman  4 года назад +4

      unkosikazi wami uNdebele. Sineminyaka engama-20 sishadile.

    • @alexvanheerden5702
      @alexvanheerden5702 4 года назад +2

      @@shanselman Hahaha Congratulations! Mr. Hanselman!! 🥳

  • @Kylua
    @Kylua 4 года назад

    Cool! Just realised why my attempt to create fractals on a Spectrum 48K 30 odd years ago may have failed! I'd love to dig that code out now!

  • @clearlyunwell
    @clearlyunwell 3 года назад

    How are you doing with learning Zulu? My cousins in Kwazulu-Natal Durban can speak Zulu fluently, but where I live they taught Southern Sotho in school. Dumela ... :) *means “Hello”. In Zulu it’s “Sawubona”. Love this series a lot, and I’ve been programming for 28 years. Thanks for creating them, your blog, and all your talks - you give back and it means a lot to me, and I’m sure many others.

    • @shanselman
      @shanselman  3 года назад

      Basically I speak like a small child, but been married to a Zulu 20 years. I need to do better. ;)

    • @clearlyunwell
      @clearlyunwell 3 года назад

      @@shanselman lol, it’s like everything - practice, practice, practice. 👍

  • @thatsweetlilthing2
    @thatsweetlilthing2 4 года назад +1

    Me: *starts scouring his videos*
    Me: *sees this, gets ready to comment how they DID teach this*
    Me: *calms down after 5s intro*

  • @HaithamShaabanB
    @HaithamShaabanB 4 года назад

    Thanks Scott very good explanation.

  • @courseprovider9871
    @courseprovider9871 4 года назад

    Another lean and great explanation. Shared in linkedin.

  • @satyabratamohapatra3397
    @satyabratamohapatra3397 4 года назад

    Thank you Scott !! As always very informative indeed.

  • @tuckercoffin2164
    @tuckercoffin2164 3 года назад

    I love your videos so much.

  • @HolyRamanRajya
    @HolyRamanRajya 4 года назад

    Excellent video. This was a revelation!

  • @lucienchu9649
    @lucienchu9649 3 года назад

    LOL, it is always nice to learn sth new from you, thank you sir.

  • @MartinAlix
    @MartinAlix 4 года назад +3

    Love this series!
    Seeing the books: What do you use for your Zulu learning? Would it apply to other languages? Would it make a good video?

    • @shanselman
      @shanselman  4 года назад +3

      I use my wife for my Zulu learning ;)

  • @jasoncoder
    @jasoncoder 4 года назад +5

    Talk about some random books to be found on one's desk: "calculus made easy" and "learn zulu".... lolwut

  • @ChaimMosheStern
    @ChaimMosheStern 3 года назад

    i have 1 question, how come there is 9 dislikes on such an amazing video

  • @drewprof
    @drewprof 3 года назад

    Happy stacks!

  • @dixztube
    @dixztube Год назад

    This was great! Thanks

  • @JonathanSwiftUK
    @JonathanSwiftUK 4 года назад

    I need to create a REST listener service and be able to use a Powershell script to send data to that REST listener. I want to collect info, like a list of running processes, or volume size/free space, then send the JSON output to that listener. I think you are just the sort of person who will know how to do that, more importantly you're good at explaining things.

  • @impeRAtoR28161621
    @impeRAtoR28161621 2 года назад

    26:29 Happy End function :)

  • @johnrobdoyle
    @johnrobdoyle 3 года назад

    Calculus,Aramaic & Zulu an unusual combination of Interests

  • @mangadd1836
    @mangadd1836 3 года назад

    Thank you soo much for this. Just came across your channel. Great explaination. (subscribed)

  • @be_b_50_ankitkumar_singh79
    @be_b_50_ankitkumar_singh79 2 года назад

    Appreciable Sir :)

  • @eyobtse
    @eyobtse 3 года назад

    Reading amharic book. Love that

  • @beanondaddy3397
    @beanondaddy3397 3 года назад

    thank you for making this.

  • @CKZA10
    @CKZA10 4 года назад +2

    That pause in the beginning right? I was scrambling to check my volume 😂

    • @shanselman
      @shanselman  4 года назад +1

      lol sorry

    • @CKZA10
      @CKZA10 4 года назад

      @@shanselmanNo worries. I should've noticed your lips weren't moving but here we are.
      Thanks for your videos! Somehow it calms some hectic days for me.

  • @sona184
    @sona184 3 года назад

    Thanks for sharing Scott, very interesting session, sorry, but I have a question, could the forum have the answer? Why does Scott use the Power Shell many times? I don't understand, my PowerShell is very simple, does anyone know something about it that helps?

  • @wolvAUS
    @wolvAUS 4 года назад

    This will be handy for my exam!

  • @drackaris_
    @drackaris_ 3 года назад

    When do you decide to use VS over VS Code and what makes you want to use either?

  • @fake_tourist
    @fake_tourist 3 года назад

    Hey Scott, it would be cool if you could make something on the basics of computer architecture and hardware end

  • @Lindvni
    @Lindvni 4 года назад

    Ok a ZULU man from South Africa can't help but notice the Learn Zulu book :)

  • @aberba
    @aberba 4 года назад

    Scott, would like to see how Windows desktop application packaging work..more like an overview

  • @raashidkhaan3717
    @raashidkhaan3717 4 года назад

    Can you please do a video on the correct usage of await async and the new awaiy for each.

  • @Джой-42
    @Джой-42 4 года назад

    Hey Scott. Thank you for the series. Could you make a video about http / https requests? Ask you like a complete novice in this question, so some examples of them would be appreciated

  • @Kampouse
    @Kampouse 3 года назад

    i wished i watched that last year ;c

  • @evans8245
    @evans8245 3 года назад

    I want your brain scott hanseldude !!!

  • @Noceo
    @Noceo 4 года назад +1

    Lovely stuff (as usual). Two questions though:
    1. Why do you use int for a and b, but long for c?
    2. Is there a way to see (in Visual Studio for instance) if a variable is passed by reference or value, assuming that it’s not explicitly defined?

    • @HabtamuDesalegn
      @HabtamuDesalegn 4 года назад

      @Noceo If it helps for question 1. for example for range of int is 0-10 and range of long is 0-20, so if we declare variables a,b,c are int then by adding a and b then we cant store the value in variable c example a=5, b=7 then c=12 so int range is 0-10 so we must declare c as long this is the intention but you can declare the variables a,b,c are int if you know the bound of your inputs.

    • @shanselman
      @shanselman  4 года назад

      1. Because the maximum size of an int plus the maximum size of an int doesn’t fit in an int.
      2. Good question. I don’t think so but I’ll check.

  • @oceanview3165
    @oceanview3165 3 года назад

    pls make one on prallel programming in c.

  • @Phantom-nb5li
    @Phantom-nb5li 3 года назад

    Hi Scott, do let us know presentation software you are using for making your videos ? Looks quite handy & cool :) ..

  • @ujjwalbansal1070
    @ujjwalbansal1070 3 года назад

    22:44 Stack frame

  • @tomthunderforest1681
    @tomthunderforest1681 4 года назад

    Create video, thank you for your work :)

  • @ArielErlijman
    @ArielErlijman 4 года назад

    Hanselman University... the best in town.

  • @fshiruba
    @fshiruba 4 года назад +1

    Love the video, but it's really necessary to have 1/9 of the screen being your cam? specially if only 1/3 of the cam is your face? I can see that you noticed it was getting on your way all the time. Maybe you could change to full screen when doings the explanations, but have a smaller (or maybe none) box with your cam or something.

    • @shanselman
      @shanselman  4 года назад

      Good call. I can try cropping it next time.

  • @LukeAvedon
    @LukeAvedon 4 года назад +1

    The stack is just like LIFO in accounting. Weird how random disciplines relate to each other.

    • @diddlybop
      @diddlybop 3 года назад

      LIFO is also a term in cs so it's just like LIFO in general

    • @LukeAvedon
      @LukeAvedon 3 года назад

      @@diddlybop truth

  • @RheaAyase
    @RheaAyase 4 года назад +3

    This is "Computer Stuff They DID Teach Me" over here in Europe. Both at high school and university.

    • @shanselman
      @shanselman  4 года назад +2

      RheaAyase definitely. I mention that at the beginning 😀

    • @RheaAyase
      @RheaAyase 4 года назад +3

      ​@@shanselman I feel like this topic is strong with the modern "programmers" raised on Python alone :/
      Kinda funny how the older generation had better computer science education than the youngsters.

    • @HabtamuDesalegn
      @HabtamuDesalegn 4 года назад

      @@RheaAyase yes you are right. we can learn from one session about memory(heap & stack), function call, recursion, overflow errors in one hands-on practical code lecture. If we have some theoretical background then this kind of lessons from @Scott Hanselman help us to clearly understand the theory, organize our knowledge(concepts) and teach others and mostly uses of tools tasks such as advanced debugging (for sure we didnt learn at school).

  • @siya.abc123
    @siya.abc123 4 года назад

    Wow Scott are you learning Zulu? I saw the books at 4:40. That's my home language. Thanks for the upload

    • @shanselman
      @shanselman  4 года назад

      Unkosikazi wami uNdebele, sineminyaka engama-20 sishadile.

    • @rodneymajola1196
      @rodneymajola1196 4 года назад

      @@shanselman Excellent Zulu - time to pop those Zulu books off the book stack

  • @4rawgnas
    @4rawgnas 3 года назад

    dat MAME cabinet

  • @extremedrone5365
    @extremedrone5365 Год назад

    Not Google it. Bing it! The new Bing

  • @ericus-scottkickoutofbedle6464
    @ericus-scottkickoutofbedle6464 2 года назад

    hotkey

  • @Daysra
    @Daysra 4 года назад +1

    The dislikes are from the overflow

  • @MJSmithGroup
    @MJSmithGroup 4 года назад

    More Volume!

  • @MatthewBishop64
    @MatthewBishop64 4 года назад

    camelCase method name is triggering my OCD ;)

  • @erikporter
    @erikporter 4 года назад +2

    👋--

  • @TheBeats4ya
    @TheBeats4ya 4 года назад

    Am i the only one that keeps looking at arcade behind him? 🎮

    • @shanselman
      @shanselman  4 года назад

      google hanselman arcade cabinet for a 7 part series on that

  • @ashishkhatiwada1880
    @ashishkhatiwada1880 4 года назад +1

    Lets be second

  • @haley8004
    @haley8004 4 года назад +1

    You know best but I think you should leverage your greater knowledge and make more advanced videos.

    • @shanselman
      @shanselman  4 года назад

      Why do you think?

    • @nishant30589
      @nishant30589 4 года назад

      @@shanselman would love see videos on advance topic as debugging memory dump or analysing the same

    • @haley8004
      @haley8004 4 года назад +2

      Scott Hanselman As a beginner c# developer I benefit from the teachers on RUclips but there’s an abundance of coverage of things I already know about. What’s often most valuable are implicit things, which perhaps come from years of experience. I rarely find a topic too advanced. Admittedly jumping in the deep end is a learning strategy not everyone uses, but I think it’s a good one.

  • @Fruitslycer
    @Fruitslycer 2 года назад

    I heavily disagree with part "You don't need to know everything". Look from the perspective of entry level people. There is no security. You need to beat seniors. You don't want them busting your back with stupid comments whole your life. Therefore you need to surpass them the sooner the better. Otherwise you either won't have job, or you will need to listen to trash people next 20 years. Henceforth you should know as much as possible. I worked for Microsoft, i know its soothing and such culture there etc, its not in rest of companies. Even knowing much doesn't give you US/UK Visa for example. What if you live in trash country such as myself? If no connections knowledge is only power. Would MSFT Redmond interview me? I doubt it. Open source / Linux community is welcoming, and boosts people to know more.

  • @LogicException
    @LogicException Год назад

    "Computer Stuff They Didn't Teach You"? Sorry, but that's what I learned both in college and in training. I hate these clickbait generalization-absolute statements. Dislike

  • @RoboDragonJediKnight
    @RoboDragonJediKnight 2 года назад +1

    Minor pedantic distinction. Many texts refer to stacks as an abstract data type (ADT), not a data structure. That is to say that a stack is defined in terms of the operations one can logically perform on a stack (push, pop) and not any particular implementation of a stack. A particular programming language implementation of a stack (System.Collections in C#) will use the constructs of a language (built-in data types, data structures, OO concepts/features) to implement the expected behavior.
    Using that definition, you are moreso using a particular implementation of a stack when you get to lower levels of abstraction such as machine language. The one instruction set architecture I'm somewhat familiar with, MIPS, uses certain calling conventions and instructions to implement the behavior of the procedure call at the machine level (jal instruction, $ra register, etc.), which includes putting the procedure parameters in an accessible location, transferring control, performing its stuff, putting return value in accessible location for caller, returning control to caller, etc..
    But at the higher level abstraction of programming languages, you know how a function/method call mechanism behaves in your language. (or at least aim to) You know that your arguments passed into your functions/methods are likely either passed by value or reference and you can use that knowledge of "stack-like" behavior to either reason about your programs or debug them using the tools provided by a debugger without having to dive into the lower level details of machine code (or at least consider it for the moment).
    Only pointing this out to add to the conversation, not a pedantic gotcha.
    Great video. Always looking for new perspectives and ideas regarding these concepts and tooling and technology to explore. The memory snapshot feature in Visual Studio is something I'll add to to the toolbox.👍
    Also I know next to nothing about how bytecode/virtual machine languages like Java and C# implement things like objects, handling instance variables and methods, so if anyone has anything to add, feel free to.

  •  3 года назад +1

    Nodes, pointers, registers, wow, It is like receiving a nice sandwich at a picnic...... lovely..... I studied this here at venerable Guatemala, Central America

  • @michaelnurse9089
    @michaelnurse9089 4 года назад +3

    Zulu. That was unexpected fork in a stack tutorial.

  • @IUfidi
    @IUfidi 2 года назад

    _scott : String = "youKnowYourWayAroundSomeVeryPowerfulSoftwares!"
    Liked! Subbed!

  • @lokzarts
    @lokzarts 4 года назад +1

    What's the font that you're using in notepad?

  • @Fr3gU
    @Fr3gU 4 года назад +2

    Thanks for taking the time to make these videos. Even if I have a grasp of the concepts I always get a "aha!"-moment. And it's so refreshing with the one-take-format compared with the "I cannot put two coherent sentences so I must cut after a sentence"-experience that is so common atm. Keep it coming!

  • @AshishSinghBaghel
    @AshishSinghBaghel 4 года назад +5

    I am first !!!

  • @jcscbiz
    @jcscbiz 4 года назад

    Do not forget to transform for your HEX getHEX.info much love!! Keep Stackin

  • @Nikkes02
    @Nikkes02 4 года назад +1

    Even though I'm very familiar with stacks and their usage, I very much enjoy listening this :)

  • @thegimel
    @thegimel 4 года назад +1

    I'm always looking forward to your next video. I enjoy them thoroughly!
    Thank you

  • @eugenestan2188
    @eugenestan2188 2 года назад

    That face in the thumbnail is priceless!

  • @Themrhamoud
    @Themrhamoud Год назад

    Your voice ASMR I feel so sleepy 😊

  • @gower1973
    @gower1973 4 года назад

    How is the first example stack allocation? It’s using the new keyword, I thought the new keyword is heap allocation, it looks to me like all you did was create an array of strings, In fact it looks really similar to the dynamic array allocation of the Vector class in c++ where you push back elements into the array

    • @shanselman
      @shanselman  4 года назад

      Yes, new is heap allocation, while the int and long are on the stack.

  • @viniciusvbf22
    @viniciusvbf22 4 года назад +1

    As expected, another quality video, no edits or cuts (which is really hard), demystifying what happens behind the curtains!
    Quick tip: you can use Ctrl+D to duplicate objects on draw.io (as you do in PowerPoint and other MS softwares).

  • @monukash
    @monukash 3 года назад

    Very informative :)