Golang Tutorial 3 - Golang pointers explained, once and for all

Sdílet
Vložit
  • čas přidán 10. 06. 2024
  • This video is about pointers explained in #golang, along with some basic memory allocation concepts, stack and heap allocations and also how they relate to pointers.
    It is beginner friendly so I start explaining with the basic syntax, but if you are already familiar with the basics, skip to 04:30.
    If you wish to support me 🤗 :
    www.buymeacoffee.com/junminlee
    paypal.me/junminlee3
    00:00 Introduction
    00:40 Pointer concepts
    01:30 Basic pointer syntax
    04:30 Stacks
    09:37 Heaps
    12:24 Garbage collector
  • Věda a technologie

Komentáře • 674

  • @MinhTran-vl4vz
    @MinhTran-vl4vz Před 3 lety +58

    In case of returning a value, when would you suggest returning a pointer and when the copy of the value.
    Until what kind of orientation point would you choose copying the variable over returning the pointer (costs heap allocation)
    Is there a specific rule?
    Love your videos! Best greets from Germany!

    • @jamie_dev
      @jamie_dev  Před 3 lety +66

      Hi! there are no solid rules for that, and there is no way to decide whether variables will be allocated to the stack or heap just with the code, without running a test for the compilers escape analysis. but in my opinion, generally, if you return a large constructor returning a pointer might be better. if you overflow the stack you can cause more burden. Also if the context of the code is to mutate the original variable, pointers, if you just want to do something with it but not change it, then value semantics. However, most of what we do, i think correctness and maintainability should be prioritized than thinking about small performance issues.

    • @MinhTran-vl4vz
      @MinhTran-vl4vz Před 3 lety +2

      @@jamie_dev lovely! Thank you so much for your help! I am doing a startup in Germany right now and try to really nail Go so that in long term everything can easily scale.
      I really want to meet you one day! (If possible)

    • @rajurajesh3029
      @rajurajesh3029 Před 3 lety +1

      @@jamie_dev hai mam good explanation plz upload more videos about go language

    • @rajarshibarman4474
      @rajarshibarman4474 Před 2 lety

      @@jamie_dev by large contructors do you mean large variables holding lot of data? If we use pointers a lot then the stack is going to run out and heaps will be used which we dont want, so I think in case of small variables we can pass them to other functions but in case of heavy vars we should pass their address so that those big chunk of data does not get copied multiple times in our program, am I correct?

    • @konjikiyami7301
      @konjikiyami7301 Před 2 lety +3

      @@rajarshibarman4474 That sounds correct that it is in regards to variables that point to types that can contain large amounts of data.
      It is also worth mentioning that the intent behind the code will also lead to different implementations for it. If you don't mind mutation and potential side effects, then you might be more inclined to pass pointers in the code. If you are more focused on implementation similar to functional programming, one of the key aspects to it is keeping functions pure, that is, they do not mutate anything passed to them nor have unintended side effects. So in this case, we want to pass a copy of the values and their type contained by the variable. What this helps to ensure is that if we run the same function with the same inputs, we get the same outputs every time, barring something like a low-level API change.

  • @luigikart11
    @luigikart11 Před 3 lety +118

    I am not understating when I say this is the most beautiful explanation of this concept I have ever seen. The fact that you break it down to memory stack level is super fundamental to understanding WHY pointers are references are required/desirable and this is something people frustratingly skip ALL the time - the creativity with the animations is incredible too, absolutely love it.

    • @nellatl
      @nellatl Před rokem +2

      And she has the nerves to be easy on the eyes too ❤

    • @maniac5411
      @maniac5411 Před 3 měsíci

      Absolutely agreed. I'm in love with these explanations.

  • @mattlewandowski5742
    @mattlewandowski5742 Před 3 lety +187

    Great video, the animations make such a big difference compared to just an IDE. Can't wait to see more!

    • @jamie_dev
      @jamie_dev  Před 3 lety +10

      Hi Matt! thanks! more is coming 😀

    • @kapiljoshi1986
      @kapiljoshi1986 Před 2 lety +9

      @@jamie_dev This is really a dream come true to have such animated tutorial which gets right into you. Really appreciate your hard work and time. Looking forward to have more Golang topics covered.

    • @nathanthomas9395
      @nathanthomas9395 Před 2 lety +8

      @@jamie_dev how do you make those animations, what do you use?

  • @vinisantos.
    @vinisantos. Před 3 měsíci +4

    As others in here, I'm truly amazed about how well-done this video is.
    I'm sure a LOT of time was spent on the animations alone.
    Not to mention all the rest.
    Thanks for such an awesome explanation and video, just the perfect combination.
    I really appreciate all the effort you put on it because it really shows (and pays!!!)

  • @SeanLazer
    @SeanLazer Před 3 měsíci +3

    this video was unbelievably helpful to me coming from a self-taught background and with limited experience in languages with pointer semantics. you cleared up a lot of questions in under 15 minutes!

  • @user-wi6bs1ml7j
    @user-wi6bs1ml7j Před 4 dny

    Wow. This woman is pro teacher. Would be a shame to not use this talent. Thanks!

  • @chandipandi
    @chandipandi Před 2 lety +24

    I know this series may not have gotten to amount of views you'd like, but you should definitely continue it.
    This is unbelievably helpful and great.

  • @dellaian
    @dellaian Před 3 lety +11

    You just set the standard for how tutorial videos should be made. Good speed, graphical annotations to explain concepts and indexing the movie to relevant parts. Thanks for sharing and taking the time to explain pointers in such clear depth.

    • @jamie_dev
      @jamie_dev  Před 3 lety +2

      Wow, thanks! that is one of the best thing anyone has said to me!!

  • @AdamMarcus930
    @AdamMarcus930 Před 2 lety +30

    This explanation was amazing. The animations really help explain the concepts and it also makes it more entertaining. It's so rare to see a well-done programming tutorial, so this was a treat. Thanks for the awesome content!

  • @elitistnoob9564
    @elitistnoob9564 Před 13 dny

    This video was a god send! The animations make it so much easier to understand

  • @AnnaKendrickBeMyBFF
    @AnnaKendrickBeMyBFF Před 2 lety +9

    Just started learning Go for my new job, and this video made it so much easier. This is the best visualization of pointers I've seen yet :) animations make all the difference! So glad to have found this channel

  • @herzaislad
    @herzaislad Před 2 měsíci

    Been coding golang for some time without really understanding pointer (only relying on visual studio code error linter), after watching your video, now all makes sense when I look again at my codes... lol... Great video! Thank you!

  • @henryconner780
    @henryconner780 Před 4 dny

    You are the GOAT, thanks so much for taking the time to make this

  • @amadujalloh4700
    @amadujalloh4700 Před 2 měsíci +1

    I really wish you made more Go content this is amazing.
    The pacing, diagram and explanation is marvellous. Thank you

  • @rajendragosavi2233
    @rajendragosavi2233 Před 2 lety

    Thank you - I was not clear with heap and garbage collector at all. This is gold standard

  • @dan4pr
    @dan4pr Před 7 dny

    I really found this tutorial very useful. The visual and your explanation was really helpful. Thank you for sharing!

  • @mrvil
    @mrvil Před 2 lety +1

    A big thumbs up, thanks a million for making this tutorial video.

  • @smarchz
    @smarchz Před rokem +1

    This is the best Golang video I've ever seen. The animation is so good. ❤

  • @geoffreycallaghan9649
    @geoffreycallaghan9649 Před 3 lety +11

    Thought we had lost you Junmin :) Your videos on Golang are simply the best and the easiest to understand that I have found! Keep up the good work. I bet it takes along time to make them the way you do.

    • @jamie_dev
      @jamie_dev  Před 3 lety +2

      Hi Geoffrey! thank you for your kind words, it takes a lot of time, but if it helps learning i think it's totally worth it 😀

  • @mattyoungberg3102
    @mattyoungberg3102 Před 2 lety +2

    Seriously one of the best programming concept explanations I've ever watched. Thanks for this!!

  • @_Verac
    @_Verac Před 3 měsíci

    Wow, after almost a decade since I first learnt cpp, someone gave the right explanation that I had all those years ago. People often tends to abstract the real working of memory allocation for the sake for simplicity thinking it helps in compression but I've often found that it's only in understanding the nuances of inner workings of any complex process can we truly comprehend the simplicity of things and your explanation is a stark example of that.

  • @joseaterana6843
    @joseaterana6843 Před rokem

    I really love you so much!! I managed to fix a important issue in my job because I saw your video 3 days before. Thanks a lot. Please continue doing videos

  • @Kavinnathcse
    @Kavinnathcse Před 2 lety +1

    Excellent :-) ... Can't wait to see more

  • @noxythedhole9626
    @noxythedhole9626 Před rokem

    THANK YOU! I have been struggling to understand pointers and this has been the most helpful by far!

  • @datguy4104
    @datguy4104 Před rokem

    Came across this by chance and this made it so simple to fully understand!

  • @simonestaffoli
    @simonestaffoli Před 2 lety +1

    best video on pointers I've ever seen

  • @linhnguyen05111999
    @linhnguyen05111999 Před 3 měsíci +1

    Coming from Javascript, pointer has been quite a confusing topic for me, especially with the syntax (* and &). This video perfectly explains it!

  • @GabrielGasp
    @GabrielGasp Před rokem

    Damn, came here looking for copper and found gold!
    What an amazing explanation, really appreciate it.

  • @feignenthusiasm
    @feignenthusiasm Před 3 lety +4

    Excellent video! I really like the format and thought your explanation was very clear and easy to understand!

  • @gerinsz
    @gerinsz Před 3 lety +6

    100% will promote this channel to my friends 👍😁
    btw, as long as i know, there is three condition where values are constructed on the Heap
    1. When a value could possibly be referenced after the function that constructed the value returns.
    2. When the compiler determines a value is too large to fit on the stack.
    3. When the compiler doesn't know the size of a value at compile time.

    • @jamie_dev
      @jamie_dev  Před 3 lety +4

      Hi Gerin!! thanks for the addition that's going to help others in this comment section, I only mentioned the one that was related to pointers in this video. 😀. just with the code, i think it's difficult to determine whether it's a stack or heap allocation before we do a test on escape analysis, and also when the stack runs out during run time, it copies everything to a larger stack. I will pin your comment in case it can help others. and thanks for recommending my channel to others, i definitely wish that this channel can reach more learners out there!

    • @gerinsz
      @gerinsz Před 3 lety +1

      @@jamie_dev My pleasure, can't wait for your upcoming video 😁👍

  • @nabromov
    @nabromov Před rokem

    This is the best explanation I have seen so far. Thank you.

  • @restudwiputro2665
    @restudwiputro2665 Před 29 dny

    What a great video! Not many programmers can explain this down to the memory level like you

  • @EdgarDev5010
    @EdgarDev5010 Před 4 měsíci

    Wow, this is a great explanation! Thank you for taking the time to do it! 👋🏽

  • @swibay
    @swibay Před 2 lety

    Sure... when you think you know everything, you don't. This video took me to new level of pointers perspective. Much love from Tanzania!

  • @JaderRubini
    @JaderRubini Před 7 měsíci

    This video did indeed help me understand the concept of pointers and addresses and make sense of the the * as a type or operator. And also stack vs heap. Thank you very much!

  • @data1014
    @data1014 Před 2 lety

    The best explanation I have found online, thank you!

  • @koomooboo
    @koomooboo Před 3 lety +2

    I was really struggle with pointers and address. You made my life so much easier with the detailed explanation and graphics. 100% LIKE!!!

  • @TidusUltimate
    @TidusUltimate Před rokem

    This is the BEST video about memory allocation in Go i've ever seen. Finally I understand pointers omfg

  • @coocoobau
    @coocoobau Před 7 měsíci

    I have been working with computers and code since elementary school. In high school (in the 90s - yeah, I'm that old), when learning C did not immediately get the concept of pointers. Boy this visual approach to explain would have worked. This is one of the most beautiful and educative materials about programming I have ever seen - and I have seen many. There was nothing new for me here, but boy did I enjoyed watching! Keep up the great work Jamie!

  • @NiallDailyPay
    @NiallDailyPay Před 3 měsíci

    This is so well edited, explained and put together. Love the layout of the graphics for explaining. As someone who was a teacher prior to jumping into the tech industry, hats off! Looking forward to watching some more of your videos ☺

  • @kikecastor
    @kikecastor Před rokem +1

    Wow!, the best explanation of the Go pointers I've seen, congratulations, I hope you keep uploading more Go videos, thank you very much!

  • @Sam-rz5hw
    @Sam-rz5hw Před 4 měsíci

    the best explanation of pointers i've ever seen!!

  • @mertkaradayi3796
    @mertkaradayi3796 Před 10 měsíci

    This is the best explanation in the internet...

  • @AlexGhoro
    @AlexGhoro Před 2 lety

    One of the best videos I saw about this topic, I love it everything was smooth and clean, just subed! Greetings from Chile!

  • @yusuflawal9987
    @yusuflawal9987 Před 2 měsíci

    This was really well made. The animation help drive home the concepts. Than you!

  • @vicaf1617
    @vicaf1617 Před 2 lety

    the animations made it so clear! Watching other videos was just so confusing compared to this

  • @amalmadhugo
    @amalmadhugo Před rokem +1

    This should be the benchmark for any tutorial video

  • @mirjamuher7177
    @mirjamuher7177 Před 8 měsíci

    Amazing video, super clearly presented, the graphics are fun and easy to follow, I'm excited about this!

  • @wazazaby
    @wazazaby Před rokem +1

    I've been using Go for almost a year now and I've been struggling to understand some concepts around pointers. This video just clarified everything. Thank you so much :)

  • @denisgrin1137
    @denisgrin1137 Před 2 lety

    It is awesome. It was problem for me to understand pointers. But this video with amazing animation illuminated me from the first try. Thanks from Ukraine)

  • @yashS4201
    @yashS4201 Před rokem

    best pointers video so far amazing i 've watched several videos on pointers understood almost everything about it but this give fundamental clarity , keep up the good work ! :)

  • @DiegoWalisson
    @DiegoWalisson Před 5 měsíci

    Here to say that this explanation is pure gold and the best i remember seeing. Thank you soooo much!

  • @tomah911
    @tomah911 Před 3 lety +4

    Great content, coming from a non CS background, working as a software engineer, that helped me a lot ! Thanks

    • @jamie_dev
      @jamie_dev  Před 3 lety

      Hi Thomas!! My pleasure, just glad that it helped!!

  • @ParthaSutradhar
    @ParthaSutradhar Před 8 měsíci

    Awesome!! Junmin Lee. Your visual explanation is really great.

  • @BlackJacketWasp
    @BlackJacketWasp Před rokem

    Thanks for the video! Spoilt by Python and haven't worked with & and * for a while until now when I need to code in Golang. Keep the content coming!

  • @davidkuda7074
    @davidkuda7074 Před rokem

    wow this video was great, worth watching and helpful! thank you! great animations, great colours, great language. What a joy! Thanks again.

  • @o.k.9142
    @o.k.9142 Před 2 lety

    Wow awesome visuals! The best explanation I’ve come across so far

  • @aunyks
    @aunyks Před 3 lety

    Incredibly clear and comprehensive. Thanks for this!

  • @HusnaRamadan
    @HusnaRamadan Před 3 lety +4

    amazing...
    your accent and the explanation are so clear. thank you.

  • @yodude2493
    @yodude2493 Před 2 lety

    Thanks for being the most beautiful teacher in the universe

  • @neyk91
    @neyk91 Před 2 lety

    Was hesitant about your channel but decided to sub just after a couple of mins, explanations with animations are superior forms of life. And animations as beautiful and smooth as yours…well…

  • @satotakeru1079
    @satotakeru1079 Před 11 měsíci

    Thanks. It was very clear to understand. I can’t wait for next ones.

  • @dhaneshgujrathi4681
    @dhaneshgujrathi4681 Před rokem

    Very well explained !
    The animations make it very easy to understand.
    Thank you !

  • @kiyoshi6559
    @kiyoshi6559 Před 5 měsíci

    Why is this video so good! Really good explanation.

  • @user-zi5cs9ez8z
    @user-zi5cs9ez8z Před rokem

    It only took you 13 minutes for me to finally understand this damn topic, thank you!!!🤩🤩🤩

  • @kallesgogglemail
    @kallesgogglemail Před rokem

    Perfect level for a programming ”tutorial”. No blur in the beginning or end. Straight to the point, super clear!

  • @kanybekmomukeev4116
    @kanybekmomukeev4116 Před rokem

    Definitely the greatest tutorial on golang

  • @invisiblehippo4162
    @invisiblehippo4162 Před rokem

    Your visuals are top notch. Thanks for the video!

  • @kashishbakshi9877
    @kashishbakshi9877 Před 2 lety

    I loved the way you explained it.
    Never understood the GC Concept better.
    Thanks a ton!
    Looking forward to more amazing content

  • @gaddp
    @gaddp Před 2 lety

    I just love how you explain 'WHY' we need pointers instead of telling 'this is pointers.' Thank you so much for thorough and clear explanation. I suppose the series is asleep for now, but I look forward to more videos in the future. Thanks!

  • @Hector-Site
    @Hector-Site Před 2 lety

    It’s always great to review basics such as stacks, heap. Great video. Thanks !

  • @magalimorin1866
    @magalimorin1866 Před 9 měsíci

    Best video i ve seen to explain pointers! thank you

  • @zanfras1149
    @zanfras1149 Před rokem

    I believe this is the most beautiful explanation of concept I have ever seen. Clear, concise and well presented! Great job.

  • @liampugh4705
    @liampugh4705 Před 2 lety

    Finally a video I understand about pointers

  • @luisuran4050
    @luisuran4050 Před rokem

    Excellent explanation!! I'm so happy I found this video

  • @pragmaticsoftwareengineer7965

    The visualizations are so amazing. Thanks for doing this. Really appreciate it.

  • @wp_channel_1337
    @wp_channel_1337 Před 11 měsíci

    Your content is excellent! I truly appreciate the use of animations and the clarity with which you present concepts. It makes understanding them much easier.

  • @marcoazevedo5878
    @marcoazevedo5878 Před rokem

    FANTASTIC Class!
    Thank you!

  • @cosmicnikhil
    @cosmicnikhil Před 3 lety +2

    This was a concept I was really struggling with coming from interpreted languages but you simplified it so well! Thank you so much :)

  • @jonesgabriel9337
    @jonesgabriel9337 Před 6 měsíci

    Loved the video Jamie . it was very concise. this is golden!

  • @scottypate1032
    @scottypate1032 Před 2 lety

    Brilliant! I love your videos. You are an amazing technical teacher. Bravo!

  • @changchenchien4515
    @changchenchien4515 Před 3 lety

    Animation is worth a thousand words ! Love the way you explain these concepts!

  • @yogeshdharya3857
    @yogeshdharya3857 Před rokem

    It has not even been 2 mins and the animations are this amazing!! M stunned from the efforts made

  • @theslade31
    @theslade31 Před 4 měsíci

    Very clear and understandable explanation with helpful graphics

  • @jcnarasimhan8966
    @jcnarasimhan8966 Před 7 měsíci

    Superb explanation of pointers. It's very unfortunate that this was the last video in the Golang playlist.
    Thanks much though for this awesome content

  • @johnnychang3456
    @johnnychang3456 Před rokem

    Hey, just dropped by this video. This is awesome work! I can't imagine the time you put into this video. I am certain it helps ALOT of people around the world, well done!

  • @everyringisgood
    @everyringisgood Před rokem

    Perfect video to explain Golang pointer! Thank you!

  • @ebarquero85
    @ebarquero85 Před rokem

    Amazing explanation. Great animations, thank you.

  • @myhendry
    @myhendry Před 3 lety

    really once and for all!! amazing video. extremely clear & concise. perfect

  • @kyungminkim9012
    @kyungminkim9012 Před 2 lety

    와… 이해가 쏙 쏙 되네요! 퀄리티 있는 강의 그리고 비디오 감사합니다~~

  • @jhonatanmaia5652
    @jhonatanmaia5652 Před 2 lety

    Oh please dont give up on your channel. Your lessons is perfect, you explain in a way that's easy and relax. Please continue with your amazing job :)

  • @initialJT
    @initialJT Před 10 měsíci

    This was incredibly helpful, thank you! I hope you continue teaching golang concepts.

  • @hello-again6994
    @hello-again6994 Před 2 lety

    This was an excellent presentation and just what I was looking for. Subscribed!

  • @kyp0717
    @kyp0717 Před 2 lety

    Wow!!! This was awesome. One of the best educational videos out there on any topic. Keep it up!

  • @pranavprashant1196
    @pranavprashant1196 Před rokem

    Beautifully exlained. Thank you

  • @kolchan11
    @kolchan11 Před 3 lety

    Thank you for the great explanation! It is the best videos about Go I've seen on CZcams

  • @wuflenso
    @wuflenso Před 2 lety

    Timestamps that untangle my confused head:
    2:33
    4:06
    Thank you!

  • @MichalKoziatek
    @MichalKoziatek Před rokem

    You explained it very well! Thanks for making it clearer for me

  • @litmanyoutube
    @litmanyoutube Před rokem

    this video really filled some knowledge gaps for a self-taught like myself! Thank you :D

  • @Cethris
    @Cethris Před rokem

    This is such a well put together video. The animations are amazing and make it really easy to understand what you are talking about