Great Article on Stack vs. Heap in the CLR

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Great Article on Stack vs. Heap in the CLR

Post by dandymcgee »

Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Great Article on Stack vs. Heap in the CLR

Post by Falco Girgis »

I think the heap vs stack portion of this article is a huge "no shit" for a developer of a natively compiled language... Whether you're using a garbage collector or not, heap management and fragmentation still exists (only you have to care about it even more), and the stack operates in exactly the same manner. An allocation is literally a pointer addition. A deallocation is a pointer subtraction.

He didn't mention that the stack is also more conducive towards caching either... All the variables of a function are spatially local on the stack, and parent functions' stack frames and their closest childrens' stack frames are temporally local.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Great Article on Stack vs. Heap in the CLR

Post by dandymcgee »

Falco Girgis wrote:I think the heap vs stack portion of this article is a huge "no shit" for a developer of a natively compiled language...
For a very strict definition of "developer", sure. But there are a lot of people calling themselves developers these days who couldn't even describe a stack data structure, let alone differentiate between the two types of memory allocation.

I posted this as a helpful introduction for someone who has not studied data structures proper but has heard the terms "stack" and "heap" thrown about colloquially without explanation. I also found the tidbit about the stack being an implementation detail in the CLR informative.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Great Article on Stack vs. Heap in the CLR

Post by Falco Girgis »

dandymcgee wrote:
Falco Girgis wrote:I think the heap vs stack portion of this article is a huge "no shit" for a developer of a natively compiled language...
For a very strict definition of "developer", sure. But there are a lot of people calling themselves developers these days who couldn't even describe a stack data structure, let alone differentiate between the two types of memory allocation.
Just because you call yourself something clearly does not make it so...

If you don't know the difference between the stack and the heap, you aren't a developer. Sorry. :mrgreen:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Great Article on Stack vs. Heap in the CLR

Post by dandymcgee »

Falco Girgis wrote:Just because you call yourself something clearly does not make it so...

If you don't know the difference between the stack and the heap, you aren't a developer. Sorry. :mrgreen:
+1
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: Great Article on Stack vs. Heap in the CLR

Post by bbguimaraes »

Falco Girgis wrote:If you don't know the difference between the stack and the heap, you aren't a developer. Sorry. :mrgreen:
Wait... what have I been working with all these years, then?
Post Reply