
{"id":867,"date":"2014-11-23T11:33:25","date_gmt":"2014-11-23T11:33:25","guid":{"rendered":"http:\/\/www.codergears.com\/Blog\/?p=867"},"modified":"2014-12-04T21:02:54","modified_gmt":"2014-12-04T21:02:54","slug":"the-first-enemy-of-c-is-its-past","status":"publish","type":"post","link":"https:\/\/codergears.com\/Blog\/?p=867","title":{"rendered":"The first enemy of C++ is its past."},"content":{"rendered":"<p>During\u00a0\u00a0the last few years we talk about the &#8220;C++ Renaissance&#8221;. We have to admit that Microsoft was a major actor\u00a0of this movement, I remember this <a href=\"http:\/\/channel9.msdn.com\/Shows\/Going+Deep\/Craig-Symonds-and-Mohsen-Agsen-C-Renaissance\">video<\/a> where\u00a0Craig Symonds and Mohsen Agsen talked about it.<\/p>\n<p>In 2011 Microsoft announced in many articles the come back of\u00a0C++, and Microsoft C++ experts like Herb Sutter did many conferences to explain why C++ is back and mostly recommend\u00a0the use of Modern C++. In the same time the standard C++11 was approved and we begin to talk about \u00a0C++ as new \u00a0language.<!--more--><\/p>\n<p>However, in 2011, C++ had a past of more than 30 years. And it&#8217;s not easy to convince developers that the new C++ simplified many \u00a0frustrating C++ usage, and there&#8217;s a new modern way to improve the C++ Code.<\/p>\n<p>Let&#8217;s take as example\u00a0the memory management, which is maybe the most criticized mechanism in C++. For many years the object allocation was done by the new keyword, and the developer must never forget to invoke delete somewhere in the code. \u00a0The &#8220;Modern C++&#8221; resolved this issue and promotes the use of shared pointer.<\/p>\n<p>But unfortunately all the effort from the active C++ community and the known experts\u00a0was not sufficient. Moral of the story: <strong>If you give to someone the possibility to do something with a language or a tool, don&#8217;t be surprised if he did it.<\/strong><\/p>\n<p>It&#8217;s what happens with C++, we still \u00a0had the possibility to use new and delete, and of course we can&#8217;t remove this possibility for many reasons. Even if the modern C++ promoted for many years the use of smart pointers. the object allocation with new will still used for many years.<\/p>\n<p>The C++ past influences a lot its using even for new created projects, and many not C++ developers still thought that this language is very complex.<\/p>\n<p><strong>How the C++ past affects it?\u00a0<\/strong><\/p>\n<p>To discover that, let&#8217;s do a test, just search on the web &#8220;C++ object allocation&#8221; and try to look\u00a0for the first link talking about shared pointers. We will be surprised by the result.<\/p>\n<p>Another interesting test is to go to any university library, ask\u00a0for a C++ book and read\u00a0the object allocation chapter. We talk mostly about the new keyword.<\/p>\n<p>To resume if a new C++ developer want to learn it, he will find more resources about the &#8220;C with classes&#8221; instead of the modern C++.<\/p>\n<p><strong>How to prevent the big impact of the C++ past?<\/strong><\/p>\n<p>There&#8217;s no magic solution, we can hope that C++ compilers could help us by emiting some warnings related to the deprecated usage, like the old string manipulation (strcpy,strcat,&#8230;). But this solution \u00a0will not have a big impact. The modern C++ is more new idioms to learn and practice.<\/p>\n<p>Another solution will be to consider that C++ has changed its name and became &#8220;<strong>Modern C++<\/strong>&#8221; . Even if this solution is very simple, but its result is very interesting. And to be convinced let&#8217;s do the same search on the web as before, but this time we search for &#8220;Modern C++&#8221; object allocation, the first link\u00a0will talk about smart pointers.<\/p>\n<p>An advice to\u00a0\u00a0new C++ developers, consider that C++ was changed its name, and for all your search on the web always use &#8220;Modern C++&#8221; instead of C++, the result will be very different, using C++ will mostly give you the past practices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>During\u00a0\u00a0the last few years we talk about the &#8220;C++ Renaissance&#8221;. We have to admit that Microsoft was a major actor\u00a0of this movement, I remember this video where\u00a0Craig Symonds and Mohsen Agsen talked about it. In 2011 Microsoft announced in many articles the come back of\u00a0C++, and Microsoft C++ experts like Herb Sutter did many conferences &hellip; <a href=\"https:\/\/codergears.com\/Blog\/?p=867\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The first enemy of C++ is its past.&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-867","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=867"}],"version-history":[{"count":13,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/867\/revisions"}],"predecessor-version":[{"id":1144,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=\/wp\/v2\/posts\/867\/revisions\/1144"}],"wp:attachment":[{"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codergears.com\/Blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}