{"id":857,"date":"2018-03-25T18:45:36","date_gmt":"2018-03-25T18:45:36","guid":{"rendered":"http:\/\/cppdepend.com\/blog\/?p=857"},"modified":"2018-03-28T14:24:43","modified_gmt":"2018-03-28T14:24:43","slug":"the-first-enemy-of-c-is-its-past","status":"publish","type":"post","link":"https:\/\/cppdepend.com\/blog\/the-first-enemy-of-c-is-its-past\/","title":{"rendered":"The first enemy of C++ is its past."},"content":{"rendered":"<p>Before the initial standardization in 1998, C++ was developed by\u00a0Bjarne Stroustrup\u00a0at\u00a0Bell Labs\u00a0since 1979, as an extension of the\u00a0C language\u00a0as he wanted an efficient and flexible language similar to C<\/p>\n<p>In 1983, \u201cC with Classes\u201d was renamed to \u201cC++\u201d, adding new features that included\u00a0virtual functions, function name and\u00a0operator overloading, references, constants, type-safe free-store memory allocation (new\/delete), improved type checking.<!--more--><\/p>\n<p>The 90s was the golden age of C++, it was very popular and many projects were developed with it especially after the OOP revolution. But after 1998 C++ was stagnated for many years. And between 2000 and 2010 no big companies supported the evolution of the language. Microsoft supported more their new .Net technology.<\/p>\n<p>Surprisingly after 2010, we talk about the \u201cC++ Renaissance\u201d. We have to admit that Microsoft was a major actor\u00a0in this movement, I remember this\u00a0<a href=\"http:\/\/channel9.msdn.com\/Shows\/Going+Deep\/Craig-Symonds-and-Mohsen-Agsen-C-Renaissance\">video<\/a>\u00a0where\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 language.<span id=\"more-867\"><\/span><\/p>\n<p>However, in 2011, C++ had a past of more than 30 years. And it\u2019s not easy to convince developers that the new C++ simplified many frustrating C++ usages, and there\u2019s a new modern way to improve the C++ Code.<\/p>\n<p>Let\u2019s 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 \u201cModern C++\u201d resolved this issue and promotes the use of the\u00a0shared 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:\u00a0<strong>If you give to someone the possibility to do something with a language or a tool, don\u2019t be surprised if he did it.<\/strong><\/p>\n<p>It\u2019s what happens with C++, we still had the possibility to use new and delete, and of course, we can\u2019t 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 in use for many years.<\/p>\n<p>The C++ past influences a lot it using even for newly created projects, and many 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\u2019s do a test, just search on the web \u201cC++ object allocation\u201d and try to look\u00a0at the results, almost all the links of the first page talk about new\/delete or even malloc.<\/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 wants to learn it, he will find more resources about the \u201cC with classes\u201d instead of the modern C++.<\/p>\n<p><strong>How to prevent the big impact of the C++ past?<\/strong><\/p>\n<p>There\u2019s no magic solution, we can hope that C++ compilers could help us by emitting some warnings related to the deprecated usage, like the old string manipulation (strcpy,strcat,\u2026). But this solution will 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 \u201c<strong>Modern C++<\/strong>\u201d . Even if this solution is very simple, but its result is very interesting. And to be convinced let\u2019s do the same search on the web as before, but this time we search for \u201cModern C++\u201d object allocation, the first link\u00a0will talk about smart pointers.<\/p>\n<p>An advice to new C++ developers, consider that C++ was changed its name, and for all your search on the web always use \u201cModern C++\u201d 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>Before the initial standardization in 1998, C++ was developed by\u00a0Bjarne Stroustrup\u00a0at\u00a0Bell Labs\u00a0since 1979, as an extension of the\u00a0C language\u00a0as he wanted an efficient and flexible language similar to C In 1983, \u201cC with Classes\u201d was renamed to \u201cC++\u201d, adding new features that included\u00a0virtual functions, function name and\u00a0operator overloading, references, constants, type-safe free-store memory allocation (new\/delete), &hellip; <a href=\"https:\/\/cppdepend.com\/blog\/the-first-enemy-of-c-is-its-past\/\" 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":[1],"tags":[13],"class_list":["post-857","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-cpp"],"_links":{"self":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/comments?post=857"}],"version-history":[{"count":1,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/857\/revisions"}],"predecessor-version":[{"id":858,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/857\/revisions\/858"}],"wp:attachment":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/media?parent=857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/categories?post=857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/tags?post=857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}