I am learning about operating systems and the thing that I do not understand exactly are heaps and stacks. I know the benefits and how each works, but in the case of dynamic languages I can not figure out how is the stack allocated.
In static typed languages all primitive data types are stored on the stack since they are small and will be deallocated more or less in the same order they were allocated, however in languages like PHP this is not known until the run time. So how is the stack size and variable allocation possible?
If I understand correctly stack size is determined on compile time by analysing number of primitive data types and some offset. How is the process done in PHP or other dynamic languages?
If this question is kick in the dark, please give me some guides how to learn about this