{"id":970,"date":"2012-05-16T10:03:20","date_gmt":"2012-05-16T10:03:20","guid":{"rendered":"http:\/\/kera.name\/articles\/?p=970"},"modified":"2012-05-16T10:04:09","modified_gmt":"2012-05-16T10:04:09","slug":"yes-alex-the-standard-doesnt-mention-the-stack-and-thats-fine","status":"publish","type":"post","link":"https:\/\/kera.name\/articles\/2012\/05\/yes-alex-the-standard-doesnt-mention-the-stack-and-thats-fine\/","title":{"rendered":"Yes Alex, The Standard Doesn&#039;t Mention The Stack, And That&#039;s Fine"},"content":{"rendered":"<p><a href=\"http:\/\/www.altdevblogaday.com\/2011\/12\/14\/c-c-low-level-curriculum-part-3-the-stack\/\">Alex Darby writes about &#034;the Stack&#034;<\/a>, referring to both the ISO standard and Bjarne&#039;s C++ book and complains that they both evade the concept of a stack or a heap as used for laying-out objects in memory:<\/p>\n<blockquote>\n<p>But the fact that the standard text on C++ all but ignores something as core to the internal operation of C++ as the Stack is telling indeed. In my experience, this is symptomatic of the disconnect between programming language and underlying implementation that exists in the academic mindset.<\/p>\n<\/blockquote>\n<p>In fact, it&#039;s very deliberate, and has nothing to do with academia. You shouldn&#039;t need to know about implementation details like a memory stack or heap because (a) you&#039;re writing in a programming language that abstracts those details away from you, and (b) they are implementation-specific. In Bjarne&#039;s case he&#039;s writing only about C++, not how some specific platform implements it. It&#039;s a book about the <em>language<\/em>, not the <em>computer<\/em> that compiles it into another language.<\/p>\n<p>Understanding this abstraction is key to writing good, portable code. That&#039;s why he&#039;s done it and it&#039;s a <em>good<\/em> thing.<\/p>\n<p>When books jump into talking about a &#034;stack&#034; or &#034;heap&#034;, they are mistraining people into thinking that these are part of C++ when they are in fact programming with a combination of technologies including C++, machine code, a stick of memory, an OS&#8230; and Darby seems to have fallen into that trap, as his article gives the impression that he believes a stack is a core part of C++ itself. Indeed, Bjarne is correct to talk instead about the notion of <em>storage duration<\/em>, which is the only thing the C++ language defines on the matter.<\/p>\n<p>Of course, that&#039;s not to say that such details should be forever ignored or that we should pretend that, say, an x86 machine doesn&#039;t typically use a stack. Certainly in the game development world, a programmer must be aware of lower-level implementation details. I&#039;m not advocating some academic approach that completely removes real-world components from the equation.<\/p>\n<p>It&#039;d just be helpful if Darby didn&#039;t pretend that these lower-level details were actually part of C++ at all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alex Darby writes about &#034;the Stack&#034;, referring to both the ISO standard and Bjarne&#039;s C++ book and complains that they both evade the concept of a stack or a heap as used for laying-out objects in memory.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[21,20,12],"_links":{"self":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/970"}],"collection":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":2,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"predecessor-version":[{"id":972,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/970\/revisions\/972"}],"wp:attachment":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}