history.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  3. <title>History - Boost.Outcome documentation</title>
  4. <link rel="stylesheet" href="./css/boost.css" type="text/css">
  5. <meta name="generator" content="Hugo 0.52 with Boostdoc theme">
  6. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  7. <link rel="icon" href="./images/favicon.ico" type="image/ico"/>
  8. <body><div class="spirit-nav">
  9. <a accesskey="p" href="./changelog.html"><img src="./images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="./index.html"><img src="./images/up.png" alt="Up"></a>
  11. <a accesskey="h" href="./index.html"><img src="./images/home.png" alt="Home"></a><a accesskey="n" href="./requirements.html"><img src="./images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both">History</h1></div></div></div>
  13. <div class="toc"><dl class="toc">
  14. <dt>
  15. <dd><dl>
  16. <dt><a href="#the-genesis-of-outcome-v1">The genesis of Outcome v1</a></dt>
  17. <dt><a href="#outcome-v2">Outcome v2</a></dt>
  18. <dt><a href="#outcome-v2-1">Outcome v2.1</a></dt>
  19. </dl></dd></dt>
  20. </dl>
  21. </div>
  22. <p>Outcome has had an interesting history, and it is worth summarising it here to show how a
  23. Boost library comes to life. The following recollections are by Niall Douglas, and may be
  24. faulty due to his aging memory.</p>
  25. <center><img src="./history/graph.png"></center>
  26. <h2 id="the-genesis-of-outcome-v1">The genesis of Outcome v1</h2>
  27. <p>The git repo began life as a &ldquo;Boost.Spinlock&rdquo; in June 2014 hived out of Boost.AFIO v1 where it had existed
  28. for some time as an internal library. In October 2014 I added in the original prototype
  29. Boost.Expected reference library as a git submodule, and began developing a non-allocating
  30. <code>future&lt;T&gt;</code>/<code>promise&lt;T&gt;</code> as an extension of <code>expected&lt;T, std::exception_ptr&gt;</code> as a faster,
  31. monadic future-promise was something which AFIO v1 sorely needed.</p>
  32. <p>The original prototype Boost.Expected library was a large and very complex beastie.
  33. I was fortunate to be employed on a contract in late 2014 early 2015 where I saw it deployed at
  34. scale into an existing large C++ codebase. Expected was really great and powerful, but it absolutely
  35. murdered compile times in a large C++ codebase, and made LTO effectively infeasible.
  36. I also found its implementation non-conducive to implementing
  37. future-promise with it, and so I resolved to implement a much more powerful policy driven
  38. monad factory which could stamp out everything from an <code>option&lt;T&gt;</code> right through to a
  39. future-promise pair, all using the exact same <code>basic_monad&lt;&gt;</code> and therefore all with a full
  40. monadic programming API, C++ 17 continuations/monadic bind and intelligently convertible into one another.
  41. Moreover, all this needed to have an absolute minimum impact on compile times and runtime
  42. overheads, neither of which were strengths of the original prototype Boost.Expected library.</p>
  43. <p>By August 2015 &ldquo;Boost.Monad&rdquo; was delivering on all those requirements and then some, but it lacked
  44. maturity through use in other code. Summer 2015 saw the Boost peer review of AFIO v1 which
  45. was roundly rejected. After considering the ample review feedback, it was realised that
  46. <a href="https://ned14.github.io/llfio/">AFIO v2</a> would be a very different design, one no longer using futures, memory allocation
  47. nor C++ exceptions. As AFIO v2 was started from scratch and using Outcome heavily from the
  48. very beginning (every AFIO v2 API returns a <code>result&lt;T&gt;</code>), Outcome began to gain bug fixes and
  49. shed features, with the non-allocating future-promise implementation being dropped in May
  50. 2016 and a large chunk of type based metaprogramming being replaced with cleaner variable template metaprogramming
  51. in June. After CppCon 2016 in September, then began the long process of getting Outcome
  52. ready for Boost peer review in Q1 2017 which involved a repeated sequence of complete rewrites
  53. of the tutorial in response to multiple rounds of feedback from the C++ community, with
  54. at least four complete rewrites currently at the time of writing.</p>
  55. <p>In parallel to all this development on Outcome, Expected went before the LEWG and entered
  56. the C++ standards track. As the WG21 meetings went by, Expected experienced a period
  57. of being stripped back and much of the complexity which had so murdered compile and
  58. link times in 2014-2015 fell away, thus the Expected proposed in P0323R1 ended up landing
  59. so close to Outcome that in January 2017 it was just a few hours work to implement
  60. Expected using the core <code>basic_monad</code> infrastructure in Outcome. That highly flexible
  61. policy based design which made monadic future-promise possible made it similarly easy
  62. to implement a highly conforming Expected, indeed in early 2017 Outcome&rsquo;s Expected was much
  63. closer to <a href="http://wg21.link/P0323">P0323R1</a> than any other implementation including the LEWG reference implementation.
  64. And unlike the LEWG reference implementation, Outcome has had eighteen months of that
  65. finely tuned patina you only get when a library is in use by other code bases.</p>
  66. <p>In February 2017 it became realised that the userbase really wanted a high quality <code>expected&lt;T, E&gt;</code>
  67. implementation rather than anything similar but not the same which Outcome had invented.
  68. The only just implemented Expected implementation based on <code>basic_monad</code> therefore took
  69. primacy. The final rewrite of the documentation before peer review submission was one
  70. which made it look like Outcome was primarily an <code>expected&lt;T, E&gt;</code> implementation with a
  71. few useful extensions like <code>outcome&lt;T&gt;</code> and <code>result&lt;T&gt;</code>. I was sad to so pivot, but it
  72. was obvious that Outcome would see far wider popularity and usage as primarily an Expected
  73. implementation.</p>
  74. <p>Almost three years after its beginning, Outcome v1 finally went before Boost peer review
  75. in May 2017 which turned into one of the longest and most detailed peer reviews Boost has
  76. done in recent years, with over 800 pieces of review feedback submitted. It was by consensus
  77. rejected, <a href="https://lists.boost.org/boost-announce/2017/06/0510.php">with substantial feedback on what to do instead</a>.</p>
  78. <h2 id="outcome-v2">Outcome v2</h2>
  79. <p>During the very lengthy peer review, roughly three groups of opinion emerged as to what
  80. a <code>value|error</code> transporting class ought to look like:</p>
  81. <dl>
  82. <dt><b>1. Lightweight</b></dt>
  83. <dd>A simple-as-possible <code>T</code> and/or <code>E</code> transport without any
  84. implementation complexity.</dd>
  85. <dt><b>2. Medium</b></dt>
  86. <dd>A variant stored <code>T</code> or <code>E1</code> ... <code>E<i>n</i></code>
  87. where <code>T</code> is the expected value and <code>E1 ...</code>
  88. are the potential unexpected values. This implemention really ought to be implemented
  89. using C++ 17's <code>std::variant<...></code> except with stronger never-empty guarantees.
  90. </dd>
  91. <dt><b>3. Heavy</b></dt>
  92. <dd>A full fat Either monad participating fully in a wider monadic programming framework for C++.</dd>
  93. </dl>
  94. <p>Peter Dimov was very quickly able to implement an <code>expected&lt;T, E1, ...&gt;</code> using his
  95. <a href="https://github.com/pdimov/variant2">variant2</a> library, and thus there seemed little
  96. point in replicating his work in an Outcome v2. The lightweight choice seemed to be the
  97. best path forwards, so in June 2017 the bare minimum <code>result&lt;T, E&gt;</code> and <code>outcome&lt;T, EC, P&gt;</code>
  98. as presented in this library was built, using the same constructor design as <code>std::variant&lt;...&gt;</code>.
  99. Significant backwards compatibility with v1 Outcome code was retained, as the review
  100. had felt the basic proposed design fine.</p>
  101. <p>A period of maturation then followed by porting a large existing codebase using Outcome v1
  102. to v2, and writing a significant amount of new code using v2 to test it for unanticipated
  103. surprises and bugs. Quite a few corner cases were found and fixed. At the end of September
  104. 2017, Outcome v2 was deemed to be &ldquo;mature&rdquo;, and a script generated &ldquo;Boost edition&rdquo; made
  105. available.</p>
  106. <p>All that remained before it was ready for a second Boost peer review was the
  107. documentation. This took four months to write (same time as to write the library itself!),
  108. and in January 2018 Outcome had its second Boost peer review, which it passed!</p>
  109. <h2 id="outcome-v2-1">Outcome v2.1</h2>
  110. <p>The changes requsted during the review of v2.0 were fairly modest: <code>result</code> and <code>outcome</code> would
  111. be renamed to <code>basic_result</code> and <code>basic_outcome</code>, and a clean separation of concerns between the
  112. <code>basic_*</code> layer and the &ldquo;convenience&rdquo; layer would be created. That suited Outcome nicely,
  113. as the <code>basic_*</code> layer could have minimum possible header dependencies and thus minimum possible build times
  114. impact, which was great for big iron users with multi-million line C++ codebases. This also
  115. had the nice side effect of permitting both Boost and <code>std</code> implementations to be supported
  116. concurrently in both Outcome and Boost.Outcome.</p>
  117. <p>By April 2018, v2.1 was feature complete and entered a six month period of maturation and
  118. battle hardening under its already extensive userbase. However Outcome passing its review in January 2018 had much more consequence than I could have ever
  119. expected. Unbeknownst to me, some of the WG21 leadership had interpreted the success of
  120. Outcome, and especially its divergences from WG21 Expected into a more complete substitute
  121. for C++ exception handling, as a sign that the C++
  122. exception handling mechanism was no longer fit for purpose. <a href="http://wg21.link/P0709">It was thus proposed
  123. to remedy the standard exception handling mechanism into something much more
  124. efficient, thus rendering Outcome obsolete in future C++ standards (P0709 <em>Zero overhead exceptions</em> aka &ldquo;Herbceptions&rdquo;)</a>.</p>
  125. <p>Concurrently to that, just before the review of Outcome 2.0, I had mooted a number of semantic and compile time performance
  126. improvements to <code>&lt;system_error&gt;</code> with the proposal that we mildly break Boost.System with
  127. improvements and see how badly real world code broke in response. This was not widely
  128. accepted at that time (though they have been since incorporated into Boost.System, and proposed
  129. defect remedies for <code>&lt;system_error&gt;</code> for C++ 23). I therefore wrote <a href="https://ned14.github.io/status-code/">an improved <code>&lt;system_error2&gt;</code></a> which fixed all the problems
  130. listed at <a href="https://wg21.link/P0824">P0824 (Summary of SG14 discussion on <code>&lt;system_error&gt;</code>)</a>
  131. and fixed up Outcome so one could use it without any system error implementation,
  132. or with the STL one or with the proposed improved one.</p>
  133. <p>This proposed improved <code>&lt;system_error2&gt;</code> was proposed by me as the library support for
  134. P0709 <em>Zero overhead exceptions</em> in <a href="https://wg21.link/P1095">P1095 <em>Zero overhead deterministic failure</em></a>,
  135. specifically as the implementation of P0709&rsquo;s proposed <code>std::error</code> value type. As
  136. proposed improved <code>&lt;system_error2&gt;</code> is bundled with Outcome in
  137. <a href="./experimental.html">experimental</a>, that means that Outcome and Boost
  138. users can gain the non-language benefits of one possible implementation of P0709
  139. today in any conforming C++ 14 compiler.</p>
  140. <p>At the time of writing, just before Outcome enters Boost (January 2019), Herbceptions have
  141. been voted upon only by SG14 Low Latency and LEWG, both giving unanimous acclamation. They have yet to be voted upon by the
  142. rest of the committee. The P1095 proposed implementation of P0709 has been voted upon by
  143. WG14 <em>C Programming Language</em>, where the C-relevant parts were approved in principle by a large majority. So
  144. the future currently looks hopeful that C, and C++, will gain language support for
  145. specifying deterministic failure sometime in the 2020s.</p>
  146. <p>In the meantime, Outcome is a peer reviewed, battle tested, library-only implementation
  147. of <em>Zero overhead exceptions</em> with proposed <code>std::error</code> available under Experimental.
  148. Please strongly consider helping us test the proposed <code>&lt;system_error2&gt;</code> based <code>std::error</code>
  149. design! The committee would greatly welcome empirical experience.</p>
  150. </div><p><small>Last revised: February 11, 2019 at 17:43:30 UTC</small></p>
  151. <hr>
  152. <div class="spirit-nav">
  153. <a accesskey="p" href="./changelog.html"><img src="./images/prev.png" alt="Prev"></a>
  154. <a accesskey="u" href="./index.html"><img src="./images/up.png" alt="Up"></a>
  155. <a accesskey="h" href="./index.html"><img src="./images/home.png" alt="Home"></a><a accesskey="n" href="./requirements.html"><img src="./images/next.png" alt="Next"></a></div></body>
  156. </html>