Why is pointers... bit shifting.. malloc.. anything that is regarding embedded development is so hard to grasp...

  • 8
    Pointers are the best thing ever invented in the history of programming:)

    Just to clarify: are you ranting about your coworkers that have problems with it, or about difficulty to understand how it works?
  • 7
    As I've explained multiple times (and people replied that it's a very easy way to understand):

    Variables are always just names that we temporarily give to storage cells (imagine a set of P.O. Boxes or Pack Stations or square grid). You can either put stuff in these cells, or look what's in there, by knowing the temporary name assigned to them.



    Now a variable is a permanent name to that cell actually.
    A pointer is basically when you have a variable, and you look at what's in that cell, and it's the name of another cell, where the actual stuff that you need sits.

    You can keep the stuff in their original cells, but just change the label inside the pointer cell, and it will suddenly point to a different cell. And 2 cells can have a label inside that could point to exactly the same cell, so when you say Cell1->pointerCell->get, it will be the same as Cell2->pointerCell->get.

    So a pointer is basically an additional level of addressing memory.
  • 6
    malloc - yeah you basically tell the post office that you need one, two, three P.O. Boxes next to each other, and the post office tries to make that happen.

    Bit shifting is completely different topic. Represent a number in binary (done using base conversion). Bit shifting literally does what it says - shifts bits. Shifting them to the left means adding more zeroes at the end. Shifting them to the right means removing the last bits.
    It's like you get the *10 and /10 in decimal, but it's all in binary, so it's actually *2 and /2 instead.
  • 1
    @sinisas difficulty to understand the concept...
  • 2
    @AndSoWeCode thanks for giving a mini tutorial..
  • 1
    Do you guys have other topics which can help me understand more and be more familiar with at least an intermediate level as embedded developer.
  • 5
    I remember learning pointers..
    Didn't get a fucking thing UNTIL one day I was working on an RTS game and thought to myself; "it sure would be nice if i could change what this variable pointed to"

    Tldr; one day you will have that moment and you'll think pointers are the greatest thing ever.
  • 1
    If you learn binary math and the basics of how computers work, these are some of the easiest concepts there are.
  • 2
    @AlgoRythm yea I guess it’s more of a logic circuits kind of advancement right?
  • 3

    Ok I wrote something for you:
  • 2
    @sinisas wow I seriously thank you for giving a code that explains the process of pointers :)
  • 1
    Really, it's not that difficult, you just have to take the time to understand well what happens when you use them but after, it's like natural
  • 1
    I remember my first malloc for a 2 dimensional array in C... Took me 2 days to figure out what the fuck was going on in the StackOverflow code snippets I found 😆
  • 0
    Because you're a dirty muggle. 😀
  • 1
    Mmh...hard if you have no background in computer architecture.
    Study the CPU first and how it deals with memory , then come back and tell us if it's difficult anymore.
  • 1
    I sometimes wish other languages used pointers.
  • 1
    @bdhobare I think I know some stuff about computer architecture from logic gates to scheduling algorithm.. but I just dont know how does it relate to embedded dev

    @iSwimInTheC I think they have that covered using List or Collections..but to use the memory address as a reference value I dont think that it is possible in other language

    @StefanH agreed but yea I also liked to learn how are these relate to embedded dev or game dev.. just picturing the bigger picture would help understand why they exist..
Add Comment