{"id":1081,"date":"2018-04-19T18:43:26","date_gmt":"2018-04-19T18:43:26","guid":{"rendered":"http:\/\/cppdepend.com\/blog\/?p=1081"},"modified":"2019-03-13T22:35:56","modified_gmt":"2019-03-13T22:35:56","slug":"the-road-to-the-c-fifth-generation","status":"publish","type":"post","link":"https:\/\/cppdepend.com\/blog\/the-road-to-the-c-fifth-generation\/","title":{"rendered":"The road to the C++ fifth generation."},"content":{"rendered":"<p>Since its creation, C++ evolved continuously and it passed many major milestones from the C with classes to the rise of the new standards. What&#8217;s the next step to evolve the C++ language? Let&#8217;s first discover the evolution of C++ over years:<!--more--><\/p>\n<p><strong>C++\u00a0 first generation:\u00a0 C with classes<\/strong><\/p>\n<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.<span id=\"more-543\"><\/span><\/p>\n<p>Here\u2019s a snippet of the code from the first generation:<\/p>\n<pre>WriteFraction(n) long n;\r\n{\r\n   unsigned short i, low, digit; unsigned long k;\r\n   putchar(n &lt; 0 ? '-' : ' '); n = abs(n);\r\n   putchar((n&gt;&gt;fractionBits) + '0'); putchar('.');\r\n   low = k = n &lt;&lt; (longBits-fractionBits); \/* align octal point at left *\/\r\n   k &gt;&gt;= 4; \/* shift to make room for a decimal digit *\/\r\n   for (i=1; i&lt;=8; ++i)\r\n   {\r\n      digit = (k *= 10L) &gt;&gt; (longBits-4);\r\n      low = (low &amp; 0xf) * 10;\r\n      k += ((unsigned long) (low&gt;&gt;4)) - ((unsigned long) digit &lt;&lt;   (longBits-4));\r\n      putchar(digit+'0');\r\n   }\r\n}\r\n<\/pre>\n<p>Here&#8217;s another code\u00a0snippet with \u201cMicrosoft Word 1.1\u201d\u00a0 released recently\u00a0 in the \u00a0<a href=\"http:\/\/www.computerhistory.org\/atchm\/microsoft-word-for-windows-1-1a-source-code\/\">Computer History Museum.<\/a><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.javadepend.com\/Blog\/wp-content\/uploads\/c11.png\" alt=\"c1\" \/><\/p>\n<p><strong>C++ second generation: OOP revolution<\/strong><\/p>\n<p>In 1989, C++ 2.0 was released, followed by the updated second edition of\u00a0<i>The C++ Programming Language<\/i>\u00a0in 1991.New features in 2.0 included multiple inheritance, abstract classes, static member functions,\u00a0const member functions, and protected members. In 1990,\u00a0<i>The Annotated C++ Reference Manual<\/i>\u00a0was published. This work became the basis for the future standard.\u00a0 In the 1990s the OOP become very popular and many developers adopted this paradigm. Herb Sutter in his <a href=\"http:\/\/www.gotw.ca\/publications\/concurrency-ddj.htm\">article<\/a>\u00a0considered the OOP adoption as a revolution :<\/p>\n<p><em>Remember that people have been doing object-oriented programming since at least the days of Simula in the late 1960s. But OO didn\u2019t become a revolution, and dominant in the mainstream, until the 1990s. Why then? The reason the revolution happened was primarily that our industry was driven by requirements to write larger and larger systems that solved larger and larger problems and exploited the greater and greater CPU and storage resources that were becoming available. OOP\u2019s strengths in abstraction and dependency management made it a necessity for achieving large-scale software development that is economical, reliable, and repeatable.<\/em><\/p>\n<p><strong>C++ third generation: Generics and Meta Programming<\/strong><\/p>\n<p>The templates were introduced in 1991 and at this time only a few C++ experts are interested in the generic programming paradigm and few publications talked about it.<\/p>\n<p>Alexandre Stephanov was\u00a0a pioneer C++ expert who try to explore the generic programming possibilities to provide a modern approach to develop the\u00a0 C++ projects.<\/p>\n<p>Here\u2019s an interesting\u00a0<a href=\"http:\/\/stepanovpapers.com\/algor.pdf\">document<\/a>\u00a0entitled \u201cAlgorithm-Oriented Generic Libraries\u201d published in 1993 by Alexandre A Stepanov and David R Summer.<\/p>\n<p>Here\u2019s the motivation from the document as explained by the authors:<\/p>\n<pre>We outline an approach to construction of software libraries in which generic algorithms (algorithmic abstractions) play a more central role than in conventional software library technology or in the object-oriented programming paradigm. Our approach is to consider algorithms first, decide what types and access operations they need for efficient execution, and regard the types and operations as formal parameters that can be instantiated in many different ways, as long as the actual parameters satisfy the assumptions on which the correctness and efficiency of the algorithms are based. The means by which instantiation is carried out is language dependent; in the C + + examples in this paper, we instantiate generic algorithms by constructing classes that define the needed types and access operations. By use of such compile-time techniques and careful attention to algorithmic issues, it is possible to construct software components of broad utility with no sacrifice of efficiency.<\/pre>\n<p>The effort and amazing work of Alexandre Stephanove , David Musser,\u00a0Meng Lee and the\u00a0C++ standardization committee, a first release version of STL was released in 1994.<\/p>\n<p>&nbsp;<\/p>\n<p>The STL was\u00a0a breath of fresh air to the C++ developers, it provided many interesting features needed to modernize the C++ code which makes the C++ algorithms implementations different to the C\u00a0 implementations ones.<\/p>\n<p>In 1998 a\u00a0<a href=\"http:\/\/www.boost.org\/users\/proposal.pdf\">proposal for \u00a0a C++ Library Repository Web Site<\/a>\u00a0was posted by\u00a0Beman G. Dawes to develop Boost.<\/p>\n<p>Boost\u00a0is a set of\u00a0libraries\u00a0for the\u00a0C++\u00a0programming language that provides support for tasks and structures such as\u00a0linear algebra,\u00a0pseudorandom number generation, multithreading,\u00a0image processing,\u00a0regular expressions, and\u00a0unit testing. It contains over eighty individual libraries.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>C++ forth generation: The new C++ standards<\/strong><\/p>\n<p>From 1991 to 2011 the language evolved slowly and the evolution comes from the libraries like STL and Boost.\u00a0 From 2011 many features were added to the standard, we can enumerate C++11, C++14, C++17 and the coming C++20.<\/p>\n<p>Here\u2019s a code snippet from the folly library that uses intensively the new standards.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.javadepend.com\/Blog\/wp-content\/uploads\/c0.png\" alt=\"c0\" \/><\/p>\n<p><strong>C++ fifth generation: Break with the legacy C++<\/strong><\/p>\n<p>Currently C++ evolve very quickly. Many new interesting features are added and others where deprecated. It&#8217;s now time to remove some language possibilities and if it&#8217;s break the compilation.<\/p>\n<p>Until now the standadisation comitee chose to not do a breaking change in the previous C++ features. However this approach could change in the near future. Indeed from this <a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2018\/p0684r2.pdf\">proposal<\/a> updated recently that discuss the stability of the language and try to answer to these questions:<\/p>\n<ul>\n<li><em>Is C++ a language of exciting new features?<\/em><\/li>\n<li><em> Is C++ a language known for great stability over a long period?<\/em><\/li>\n<li><em> Do we believe that upgrading to a new language version should be effortless?<\/em><\/li>\n<li><em> If so, how do we reconcile those effortless upgrades with a practical need to evolve the language?<\/em><\/li>\n<li><em> If we instead prioritize stability over all else, are we bound to move slowly &#8211; only making a change when we are certain it is correct and will never need future fixes?<\/em><\/li>\n<\/ul>\n<p>From the proposal we have this suggestion:<\/p>\n<p><em>The Committee should be willing to consider the design \/ quality of proposals even if they may cause a change in behavior or failure to compile for existing code.<\/em><\/p>\n<p>Maybe the\u00a0fifth\u00a0 generation\u00a0will be\u00a0 the break with the legacy C++ to remove the possibilities inherited from C.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since its creation, C++ evolved continuously and it passed many major milestones from the C with classes to the rise of the new standards. What&#8217;s the next step to evolve the C++ language? Let&#8217;s first discover the evolution of C++ over years:<\/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":[],"class_list":["post-1081","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/1081","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=1081"}],"version-history":[{"count":12,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/1081\/revisions"}],"predecessor-version":[{"id":1237,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/posts\/1081\/revisions\/1237"}],"wp:attachment":[{"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/media?parent=1081"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/categories?post=1081"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cppdepend.com\/blog\/wp-json\/wp\/v2\/tags?post=1081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}