Flu, handstands, programming course, stack and heap!
Posted on January 30, 2017
Flu and handstand
Okay so, I did not update you any more frequently obviously. There is a reason for that. And the reason is… dananananana… THE FLU! I got the fluuuuhuuhu. I’ve been at home for 2 weeks, except for 2 days when I thought I was fine and went to RC and to the gym, but I got worse again. However, I felt fine when I woke up today! I was finally going to the gym in the morning and then later on to RC. So I put my backpack on, ready for school! I turned around and saw brown splashes on the bed. What the? I had missed to close my thermos full of coffee, which was in my backpack. So, there I stood, coffee in the whole backpack, on the floor, on the bed. Yaaaay great start.. I took a deep breath, tried hard not to get upset, said to myself “shit happens” and cleaned it up. So later on at the gym, halfway through my session I did my first handstand kick-up, and I stayed up. FOR 58 SECONDS! My goal is to be able to stand for one whole minute before I get home, and I pretty much got it today. I’m so insanely happy about this. Sooo despite the coffee spilling my day started pretty good.
Alright, some updates about programming. I’ve been admitted to a basic programming course in Sweden and they allowed me to submit the assignments online, even though they normally don’t. This is great news for me, since it means that I’ll be able to apply for more advanced courses later on. This one is basic programming in Java so the assignments don’t take up too much of my time, but I still learn a lot from taking the course. So during my time at home with the flu, I completed 3 of the 5 assignments. I won’t be home for the exam, but I can still get admitted to course nr 2 if I do all the assignments. So I’ll just do that and take the exam before the summer.
I’m still making some progression with my game. The aliens can move around and they are also dropping bombs now! Yaay! Not sure what to do now, I should probably track the score. Lately I’ve done a lot of reading and trying to answer all my unanswered questions. I also started with a tutorial of a platform game in C++. If you are interested in trying to make your own game, you should check this out! Also read the comments. It might not be perfect but it seems like a good start. I’ll go through it as well. Here it is: https://www.reddit.com/r/learnprogramming/comments...
Stack and heap
I’m also thinking that I should probably share some valuable information with you regarding stuff I learn. Lately I’ve been trying to understand more about the heap and the stack. Ever heard the terms but never really understood what it is? Mehrnaz has explained it to me several times, but some things you just need to hear/read about a hundred times. But I think I’ve got a pretty good picture of it now.
Both the stack and the heap are two regions in your computer's memory. Let’s start with the stack. The stacks memory is pretty much managed for you. It stores temporary variables, e.g variables in functions and they disappear when you go out of that scope (e.g the scope of a function). So when a function declares a new variable, it is pushed to the stack. And when a function exits, those variables are deleted and the memory is free. Cool right? This is pretty fast so you want to use the stack as much as possible. This memory allocation is done at compile time, and the memory allocation is static, meaning you can not change the size. So when you are declaring a vector, of which you can change the size after you have initiated and declared it, the memory for that vector can not be allocated on the stack. The stack also has size limits.
Our vector will instead be allocated on the heap. The heap is where the dynamic allocation happens, so if you don’t know the size when you create the object, it will be allocated on the heap. The heaps memory is not managed for you, and it is larger than the stack. It basically does not have size restrictions, other than the physical limitations of your computer of course. Since the allocation is not managed for you, you have to make sure that you delete stuff you no longer need, or else you will have memory leaks. This is a bit slower than the stack and data that is on the heap can be fragmented, so the use of memory on the heap is not guaranteed to be efficient. Sooo this is also where pointers (in C++) comes in. In other, more high-level languages this is still managed for you though, through the language.
So now you know a little bit about the memory on your computer!