Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

One of the most popular questions on is this one:

Many of the answers seem to gravitate toward the fact that students often don't get a good understanding of what is physically going on when code executes... the very most basic part of this seems to be stack/heap.

I've read through K&R twice and finally have a good understanding of the language, but I don't think that is enough. Nearly every tough question here has the work "stack" or "heap" in the answer, and while I have a limited understanding of what those mean just from context and wikipedia searches, I prefer the comprehensive approach of a textbook. So, please recommend a textbook which explains things like stack, heap, memory allocation, etc from a physical standpoint, as it relates to C programming.

I tried asking this question on stackoverflow and apparently it was not the right place to ask it. So I hope this site is a better location. If not, please consider migrating it to the proper stackexchange site. Thanks.

share|improve this question

closed as off-topic by gnat, Ixrec, Bart van Ingen Schenau, Scant Roger, GlenH7 Jan 10 at 16:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to find or recommend tools, libraries, programming languages, resources (including books, blogs, tutorials, and examples), or projects to undertake are off-topic on Programmers as they attract opinionated answers that won't have lasting value to others. You may be able to get help in The Whiteboard, our chat room." – gnat, Ixrec, Bart van Ingen Schenau, Scant Roger, GlenH7
If this question can be reworded to fit the rules in the help center, please edit the question.

+1. Really needed knowledge base for many people who venture in C. While concepts of OO is important to better connect higher level problem domain- the lower level concepts actually makes you effective. – Dipan Mehta Jan 2 '12 at 7:03
up vote 3 down vote accepted

Many of the answers seem to gravitate toward the fact that students often don't get a good understanding of what is physically going on when code executes... the very most basic part of this seems to be stack/heap.

This is indeed true. And one of the most essential need for understanding the machine is even more important when you are in C.

Ref: 1
There is a book to deal with exactly this subject - Write Great Code

There are two volumes of the book - the first one essentially is only about the way in which a typical machine architecture book. Unlike many microprocessor books which focus on particular architecture - here is a book that captures what high level abstractions matter at the time of programming.

The second volume actually tells you about "Thinking Low-Level, Writing High-Level"

Ref: 2
If you want to go even more deep, here is another book - "The art of Assembly language programming"

Unlike most other books - this book introduces Highlevel Assembly language. This is best reference on low level understanding.

Ref: 3
Many issues with C programming revolves around effective usage of memory. These abstractions become key to be able to write scalable systems in C.

Here is a very good resource that focuses on this.

Hope this helps.

share|improve this answer

During my study I used the book "Programming Language Concepts" (Ghezzi, Jazayeri), which has a detailed description of execution models (global variables, stack variables, activation record, heap variables).

share|improve this answer

The first two chapters of The Art of Exploitation do a pretty good job into describing C programming from a low level point of view: disassembling C code, CPU registers, debugging, pointers and memory, static variables, memory segmentation (including the stack and the heap), and more. Note that the book is using GNU/Linux tools (objdump, gcc, gdb, etc.).

share|improve this answer

Answering my own question. This may not be the best book for an explicit understanding of C, but it is an excellent book for learning how memory (and all hardware) work with your software. It's helped me immensely. Once I finish it I will tackle some of the other books suggested by the other responders (thanks!).

The Elements of Computing Systems: Building a Modern Computer from First Principles

It's a book/course with the nickname "from NAND to tetris in 12 steps" which teaches you how to build a modern computer with high level applications starting from very basic digital building blocks. Projects in the book include building hardware (gates, adders, ALU, registers, RAM, ROM, CPU, and eventually an entire computer) and then software for it, starting with native machine instructions, then writing an assembler, virtual machine, compiler, OS, and applications. There's really nothing else like it, an entire top to bottom view of a computing system in one digest!

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.