Golang Tutorial 3 - Golang pointers explained, once and for all
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
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!
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.
@@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)
@@jamie_dev hai mam good explanation plz upload more videos about go language
@@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?
@@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.
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.
And she has the nerves to be easy on the eyes too ❤
Absolutely agreed. I'm in love with these explanations.
Great video, the animations make such a big difference compared to just an IDE. Can't wait to see more!
Hi Matt! thanks! more is coming 😀
@@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.
@@jamie_dev how do you make those animations, what do you use?
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!!!)
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!
Wow. This woman is pro teacher. Would be a shame to not use this talent. Thanks!
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.
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.
Wow, thanks! that is one of the best thing anyone has said to me!!
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!
This video was a god send! The animations make it so much easier to understand
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
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!
You are the GOAT, thanks so much for taking the time to make this
I really wish you made more Go content this is amazing.
The pacing, diagram and explanation is marvellous. Thank you
Thank you - I was not clear with heap and garbage collector at all. This is gold standard
I really found this tutorial very useful. The visual and your explanation was really helpful. Thank you for sharing!
A big thumbs up, thanks a million for making this tutorial video.
This is the best Golang video I've ever seen. The animation is so good. ❤
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.
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 😀
Seriously one of the best programming concept explanations I've ever watched. Thanks for this!!
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.
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
Excellent :-) ... Can't wait to see more
THANK YOU! I have been struggling to understand pointers and this has been the most helpful by far!
Came across this by chance and this made it so simple to fully understand!
best video on pointers I've ever seen
Coming from Javascript, pointer has been quite a confusing topic for me, especially with the syntax (* and &). This video perfectly explains it!
Damn, came here looking for copper and found gold!
What an amazing explanation, really appreciate it.
Excellent video! I really like the format and thought your explanation was very clear and easy to understand!
Glad it was helpful!
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.
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!
@@jamie_dev My pleasure, can't wait for your upcoming video 😁👍
This is the best explanation I have seen so far. Thank you.
What a great video! Not many programmers can explain this down to the memory level like you
Wow, this is a great explanation! Thank you for taking the time to do it! 👋🏽
Sure... when you think you know everything, you don't. This video took me to new level of pointers perspective. Much love from Tanzania!
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!
The best explanation I have found online, thank you!
I was really struggle with pointers and address. You made my life so much easier with the detailed explanation and graphics. 100% LIKE!!!
thanks!!
This is the BEST video about memory allocation in Go i've ever seen. Finally I understand pointers omfg
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!
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 ☺
Wow!, the best explanation of the Go pointers I've seen, congratulations, I hope you keep uploading more Go videos, thank you very much!
the best explanation of pointers i've ever seen!!
This is the best explanation in the internet...
One of the best videos I saw about this topic, I love it everything was smooth and clean, just subed! Greetings from Chile!
This was really well made. The animation help drive home the concepts. Than you!
the animations made it so clear! Watching other videos was just so confusing compared to this
This should be the benchmark for any tutorial video
Amazing video, super clearly presented, the graphics are fun and easy to follow, I'm excited about this!
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 :)
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)
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 ! :)
Here to say that this explanation is pure gold and the best i remember seeing. Thank you soooo much!
Great content, coming from a non CS background, working as a software engineer, that helped me a lot ! Thanks
Hi Thomas!! My pleasure, just glad that it helped!!
Awesome!! Junmin Lee. Your visual explanation is really great.
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!
wow this video was great, worth watching and helpful! thank you! great animations, great colours, great language. What a joy! Thanks again.
Wow awesome visuals! The best explanation I’ve come across so far
Incredibly clear and comprehensive. Thanks for this!
amazing...
your accent and the explanation are so clear. thank you.
Thank you! 😃
Thanks for being the most beautiful teacher in the universe
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…
Thanks. It was very clear to understand. I can’t wait for next ones.
Very well explained !
The animations make it very easy to understand.
Thank you !
Why is this video so good! Really good explanation.
It only took you 13 minutes for me to finally understand this damn topic, thank you!!!🤩🤩🤩
Perfect level for a programming ”tutorial”. No blur in the beginning or end. Straight to the point, super clear!
Definitely the greatest tutorial on golang
Your visuals are top notch. Thanks for the video!
I loved the way you explained it.
Never understood the GC Concept better.
Thanks a ton!
Looking forward to more amazing content
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!
It’s always great to review basics such as stacks, heap. Great video. Thanks !
Best video i ve seen to explain pointers! thank you
I believe this is the most beautiful explanation of concept I have ever seen. Clear, concise and well presented! Great job.
Finally a video I understand about pointers
Excellent explanation!! I'm so happy I found this video
The visualizations are so amazing. Thanks for doing this. Really appreciate it.
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.
FANTASTIC Class!
Thank you!
This was a concept I was really struggling with coming from interpreted languages but you simplified it so well! Thank you so much :)
Loved the video Jamie . it was very concise. this is golden!
Brilliant! I love your videos. You are an amazing technical teacher. Bravo!
Animation is worth a thousand words ! Love the way you explain these concepts!
It has not even been 2 mins and the animations are this amazing!! M stunned from the efforts made
Very clear and understandable explanation with helpful graphics
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
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!
Perfect video to explain Golang pointer! Thank you!
Amazing explanation. Great animations, thank you.
really once and for all!! amazing video. extremely clear & concise. perfect
와… 이해가 쏙 쏙 되네요! 퀄리티 있는 강의 그리고 비디오 감사합니다~~
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 :)
This was incredibly helpful, thank you! I hope you continue teaching golang concepts.
This was an excellent presentation and just what I was looking for. Subscribed!
Wow!!! This was awesome. One of the best educational videos out there on any topic. Keep it up!
Beautifully exlained. Thank you
Thank you for the great explanation! It is the best videos about Go I've seen on CZcams
Timestamps that untangle my confused head:
2:33
4:06
Thank you!
You explained it very well! Thanks for making it clearer for me
this video really filled some knowledge gaps for a self-taught like myself! Thank you :D
This is such a well put together video. The animations are amazing and make it really easy to understand what you are talking about