How memory works?

If you really want to understand better. Try some assembly:

http://schweigi.github.io/assembler-simulator/

All programming languages makes somethings easy and other things hard. There is no silver bullet. I use Assembly for example on microcontrollers fairly often even today. I find it easier than even C for that sort of thing.

ugh thinking about it , the program when a variable is declared it will request a memory location based on its type (size in bytes) , it will then return a pointer from this , now to use this it is a bit complicated , generally the address when in use will be stored within cache when possible , however if not the location of a second set of memory in rams location will be stored in the cache , this is then accessed when it is required. Honestly its all handled for you , I wouldnt go around trying to figure it out , its painful , its long and its really really strenuous to understand the principality , I however will gladly explain how the circuit works :D.