<?xml version="1.0" encoding="utf-8" ?><transcript><text start="0" dur="4.98">people online welcome to everybody here</text><text start="2.73" dur="4.589">just gonna be really quick very</text><text start="4.98" dur="4.86">efficient dyslexia us plus not going to</text><text start="7.319" dur="4.32">talk very long I just want to say a few</text><text start="9.84" dur="3.99">thanks and the people who helped make</text><text start="11.639" dur="3.96">this possible that&amp;#39;s of course the</text><text start="13.83" dur="4.199">people in the back the channel nine team</text><text start="15.599" dur="4.801">streaming live Denis Begley who made all</text><text start="18.029" dur="5.371">the logistics possible and what we&amp;#39;re</text><text start="20.4" dur="6.389">gonna do is invite herb Sutter up here</text><text start="23.4" dur="5.94">in about 20 seconds he&amp;#39;s going to make a</text><text start="26.789" dur="4.441">very special announcement so I just</text><text start="29.34" dur="5.809">wanted to say again thank you welcome</text><text start="31.23" dur="3.919">and her come up here man</text><text start="37.94" dur="3.279">thank you Charles and thank you</text><text start="39.66" dur="3.059">everybody for coming and all those who</text><text start="41.219" dur="4.351">are watching even in the room we have</text><text start="42.719" dur="4.951">folks from 18 countries 23 states in the</text><text start="45.57" dur="4.649">United States and a worldwide audience</text><text start="47.67" dur="4.619">so thank you for attending and before I</text><text start="50.219" dur="4.891">invite our most distinguished and most</text><text start="52.289" dur="5.191">important speaker we wanted to dedicate</text><text start="55.11" dur="3.69">this conference to a very important</text><text start="57.48" dur="4.5">gentleman so if we could have his</text><text start="58.8" dur="5.84">picture on the screen please we&amp;#39;d like</text><text start="61.98" dur="2.66">to dedicate this</text><text start="68.93" dur="5.92">- one of the most influential computer</text><text start="72.18" dur="6">scientists in our young industry&amp;#39;s</text><text start="74.85" dur="5.43">history there are very few people on the</text><text start="78.18" dur="4.65">face of the planet who have made as</text><text start="80.28" dur="5.31">great a contribution and he&amp;#39;s also the</text><text start="82.83" dur="4.17">reason why we&amp;#39;re here today when we</text><text start="85.59" dur="4.77">think about what happened at Bell Labs</text><text start="87" dur="6.27">where yarda and AT&amp;amp;T and c+ also grew up</text><text start="90.36" dur="6.42">before there was a C with classes before</text><text start="93.27" dur="5.13">there was C++ there was C the most</text><text start="96.78" dur="4.619">influential programming language in the</text><text start="98.4" dur="4.92">world every single modern language I was</text><text start="101.399" dur="4.141">a debt to it and is either directly</text><text start="103.32" dur="5.909">derived from it or borrows heavily from</text><text start="105.54" dur="6.42">it and has been influenced in all the</text><text start="109.229" dur="6.241">coding we do by what this man did 40</text><text start="111.96" dur="5.7">years ago now he was also famous for</text><text start="115.47" dur="4.41">another thing the UNIX operating system</text><text start="117.66" dur="5.67">together with Ken Thompson which has</text><text start="119.88" dur="5.4">again directly influenced or actually</text><text start="123.33" dur="4.14">directly led to almost every major</text><text start="125.28" dur="6.179">operating system in use today in</text><text start="127.47" dur="6.39">mainstream that&amp;#39;s a very big set of</text><text start="131.459" dur="3.871">shoulders so we appreciate very much his</text><text start="133.86" dur="4.08">contribution and we think of all the</text><text start="135.33" dur="5.4">awards that Ritchie has received it&amp;#39;s</text><text start="137.94" dur="5.64">because coming back to see it is such an</text><text start="140.73" dur="5.37">empowering part of native code it is</text><text start="143.58" dur="5.939">what has made our industry possible</text><text start="146.1" dur="5.22">because libraries that are portable that</text><text start="149.519" dur="5.551">are efficient are what this world is</text><text start="151.32" dur="4.77">built on this world runs on C and C++ it</text><text start="155.07" dur="3.21">is the foundation of everything</text><text start="156.09" dur="5.04">including the manage languages it is</text><text start="158.28" dur="6.209">what we all build on and so we&amp;#39;d like to</text><text start="161.13" dur="5.55">dedicate this event to the memory of the</text><text start="164.489" dur="5.161">recently passed Dennis Ritchie any</text><text start="166.68" dur="5.22">creator of C co-creator of UNIX to whom</text><text start="169.65" dur="5.399">we all and everybody who uses software</text><text start="171.9" dur="5.58">on this planet owes a great debt so with</text><text start="175.049" dur="5.431">that we&amp;#39;d like to dedicate that and I&amp;#39;d</text><text start="177.48" dur="5.19">like now to introduce our keynote</text><text start="180.48" dur="3.66">speaker the artist drew soup needs no</text><text start="182.67" dur="2.49">introduction he&amp;#39;s the creator of scene</text><text start="184.14" dur="4.08">cloth sauce and a friend of Dennis</text><text start="185.16" dur="5.639">Ritchie and we would like now to see C++</text><text start="188.22" dur="5.03">11 style a touch of class the Artic</text><text start="190.799" dur="2.451">thank</text><text start="197.239" dur="8.56">yes thank you very much Dennis as much</text><text start="202.56" dur="7.709">missed his he was a a real real</text><text start="205.799" dur="6.69">gentleman and when I talk about memory</text><text start="210.269" dur="4.95">model issues that&amp;#39;s borrowed straight</text><text start="212.489" dur="10.351">from C and that&amp;#39;s a very important part</text><text start="215.219" dur="10.44">of C++ okay so I have to talk about in</text><text start="222.84" dur="5.879">the future and I&amp;#39;m going to talk about</text><text start="225.659" dur="5.94">the issue of style how do you write code</text><text start="228.719" dur="4.95">and how do you write code so it&amp;#39;s</text><text start="231.599" dur="6.72">maintainable performing all of these</text><text start="233.669" dur="7.35">good things when I when I come into a</text><text start="238.319" dur="5.07">room especially one of these virtual</text><text start="241.019" dur="5.241">rooms on the web I seem to be the only</text><text start="243.389" dur="5.25">one who doesn&amp;#39;t quite know what C++ is</text><text start="246.26" dur="5.439">everybody has some kind of simple</text><text start="248.639" dur="4.891">explanation that that that fits their</text><text start="251.699" dur="6.361">view of it and you see a few of them</text><text start="253.53" dur="7.44">there and the effect is like the blind</text><text start="258.06" dur="5.01">men and the elephant if you have only</text><text start="260.97" dur="4.83">seen the tail of the elephant you know</text><text start="263.07" dur="6.36">what it&amp;#39;s like if you only seen a leg</text><text start="265.8" dur="5.91">you know what it&amp;#39;s like I try to to look</text><text start="269.43" dur="4.29">at the whole elephant and I try to</text><text start="271.71" dur="4.17">characterize it but it&amp;#39;s hard</text><text start="273.72" dur="4.729">there&amp;#39;s many bits to the elephant they</text><text start="275.88" dur="5.219">are all essential for the elephant but</text><text start="278.449" dur="7.451">it&amp;#39;s it&amp;#39;s hard to be simple about what</text><text start="281.099" dur="7.56">it is so - here&amp;#39;s my sort of trying to</text><text start="285.9" dur="10.049">characterize what C++ is particularly</text><text start="288.659" dur="12.331">good at and particularly particularly</text><text start="295.949" dur="7.051">aimed at it takes off from C and it on</text><text start="300.99" dur="4.56">systems programming but where it really</text><text start="303" dur="6.57">matters where it makes a difference is</text><text start="305.55" dur="6.48">in the area of infrastructure that is</text><text start="309.57" dur="5.61">where you build something that other</text><text start="312.03" dur="5.729">things build on that people rely on</text><text start="315.18" dur="5.64">where you have resource constraints</text><text start="317.759" dur="5.991">there can be a cellphone it can be a</text><text start="320.82" dur="5.94">Google style lookup</text><text start="323.75" dur="6.13">you&amp;#39;re constrained by various resources</text><text start="326.76" dur="5.91">and you have to have reliability and</text><text start="329.88" dur="5.1">dependability and performance that kind</text><text start="332.67" dur="3.93">of application we can be infrastructure</text><text start="334.98" dur="5.58">or it can be applications it has a</text><text start="336.6" dur="7.11">similar kind of constraints is where C++</text><text start="340.56" dur="5.4">shines I tried to come up with a</text><text start="343.71" dur="4.2">buzzword but I&amp;#39;m not very good at it</text><text start="345.96" dur="4.86">lightweight abstraction programming</text><text start="347.91" dur="7.74">language is accurate but it&amp;#39;s probably</text><text start="350.82" dur="7.47">not good marketing speech so let&amp;#39;s go on</text><text start="355.65" dur="4.68">one thing that&amp;#39;s I think it&amp;#39;s important</text><text start="358.29" dur="4.14">to realize when you talk about</text><text start="360.33" dur="6.63">programming is that no one-size-fits-all</text><text start="362.43" dur="6.33">I always hear these things like what is</text><text start="366.96" dur="3.99">the programming language what&amp;#39;s the</text><text start="368.76" dur="4.32">dominant programming language what&amp;#39;s the</text><text start="370.95" dur="4.77">future programming language which is the</text><text start="373.08" dur="7.22">best programming language this</text><text start="375.72" dur="6.69">programming language who fought for what</text><text start="380.3" dur="3.82">there&amp;#39;s no reason to believe that</text><text start="382.41" dur="3.66">there&amp;#39;s one language that&amp;#39;s good for</text><text start="384.12" dur="4.5">that&amp;#39;s best for everything I don&amp;#39;t think</text><text start="386.07" dur="5.01">there is and so I&amp;#39;m trying to</text><text start="388.62" dur="3.96">characterize what C++ is good for where</text><text start="391.08" dur="5.1">it fits</text><text start="392.58" dur="7.02">there&amp;#39;s things I would probably use</text><text start="396.18" dur="5.97">JavaScript or Python for but I probably</text><text start="399.6" dur="6.65">wouldn&amp;#39;t use them for say the JavaScript</text><text start="402.15" dur="7.65">interpreter that&amp;#39;s that C++ domain</text><text start="406.25" dur="5.4">anyway so dependent different</text><text start="409.8" dur="4.82">applications have different constraints</text><text start="411.65" dur="5.29">you you worry about hardware resources</text><text start="414.62" dur="5.23">reliability efficiency constraint it</text><text start="416.94" dur="7.76">varies a lot of applications can crash</text><text start="419.85" dur="9.54">doesn&amp;#39;t hurt anybody the extremes are</text><text start="424.7" dur="5.62">where all that matters is to get to the</text><text start="429.39" dur="4.2">market fast</text><text start="430.32" dur="5.31">that&amp;#39;s not C++ as core domain</text><text start="433.59" dur="7.65">there are however places in the other</text><text start="435.63" dur="7.71">extreme program fails people die it&amp;#39;s</text><text start="441.24" dur="4.65">it&amp;#39;s always uncomfortable if your tumors</text><text start="443.34" dur="5.31">are used in such an area but somebody</text><text start="445.89" dur="5.73">has to do it and there&amp;#39;s a simple fact</text><text start="448.65" dur="6.23">that it&amp;#39;s 3050 percent I mean if you</text><text start="451.62" dur="3.26">double the overhead of</text><text start="456.76" dur="3.78">something working on a server farm well</text><text start="458.77" dur="3.81">you need at least another server farm</text><text start="460.54" dur="6.06">and probably too because of the</text><text start="462.58" dur="7.86">communication so that&amp;#39;s the areas where</text><text start="466.6" dur="5.55">where C++ shines over the years we have</text><text start="470.44" dur="3.99">tried to say what we&amp;#39;re doing this he</text><text start="472.15" dur="4.92">prosper us with many words I mean people</text><text start="474.43" dur="4.59">want true object-oriented style I&amp;#39;ve</text><text start="477.07" dur="3.78">never been on that team there&amp;#39;s nothing</text><text start="479.02" dur="4.38">that says everything fits in a hierarchy</text><text start="480.85" dur="6.57">as a matter of fact it doesn&amp;#39;t although</text><text start="483.4" dur="6.33">he misses and well C is perfect and you</text><text start="487.42" dur="5.82">just need a few details well if you</text><text start="489.73" dur="8.07">write C with void stars and macros and</text><text start="493.24" dur="8.55">costs you get C style bugs and and you</text><text start="497.8" dur="7.11">see all of this in in the C++ world and</text><text start="501.79" dur="5.27">the C++ code and you just tried to say</text><text start="504.91" dur="5.76">multi-paradigm but that doesn&amp;#39;t actually</text><text start="507.06" dur="7.27">capture anything they were never meant</text><text start="510.67" dur="5.52">to be separate ways of programming they</text><text start="514.33" dur="5.16">were meant to take part of a synthesis</text><text start="516.19" dur="6.27">that is C++ and so we can think about</text><text start="519.49" dur="5.76">what we really want we want something</text><text start="522.46" dur="4.64">that&amp;#39;s easy to understand for humans and</text><text start="525.25" dur="5.28">true we want something that&amp;#39;s correct</text><text start="527.1" dur="5.71">maintainable modularity is good the</text><text start="530.53" dur="5.49">interfaces are absolutely essential in</text><text start="532.81" dur="5.46">in in modern software we want to have</text><text start="536.02" dur="4.47">effective resource management we don&amp;#39;t</text><text start="538.27" dur="4.08">want to leak memory we don&amp;#39;t want to</text><text start="540.49" dur="6.14">leak locks we don&amp;#39;t want to lead file</text><text start="542.35" dur="7.47">leaked files etc etc that&amp;#39;s a big issue</text><text start="546.63" dur="7.3">today&amp;#39;s world tend to be multi-threaded</text><text start="549.82" dur="6.78">concurrent so we want to be able to do</text><text start="553.93" dur="5.88">thread safety without losing all the</text><text start="556.6" dur="5.79">other advantages efficiency we want in</text><text start="559.81" dur="6.11">many many applications it seems to be</text><text start="562.39" dur="7.83">getting more critical in critical areas</text><text start="565.92" dur="6.61">cell phone and and sort of webserver</text><text start="570.22" dur="4.74">kind of things are the extremes but also</text><text start="572.53" dur="7.53">some high-performance numerical stuff</text><text start="574.96" dur="8.04">and portability except when when there&amp;#39;s</text><text start="580.06" dur="4.83">reasons not to because next year&amp;#39;s model</text><text start="583" dur="3.45">next year&amp;#39;s operating system is going to</text><text start="584.89" dur="3.57">be different if you don&amp;#39;t want to port</text><text start="586.45" dur="3.81">to anything else at least you want to</text><text start="588.46" dur="3.84">port to your future hardware</text><text start="590.26" dur="4.53">and that&amp;#39;s not going to be the same so</text><text start="592.3" dur="5.34">that&amp;#39;s what we want that&amp;#39;s hard to get</text><text start="594.79" dur="5.22">I picked Don Quixote here from this</text><text start="597.64" dur="4.35">slide for for that reason because</text><text start="600.01" dur="4.5">sometimes it feels like an impossible</text><text start="601.99" dur="4.74">task but we&amp;#39;re making progress we&amp;#39;ve</text><text start="604.51" dur="5.31">made steady progress or many years and</text><text start="606.73" dur="6.12">now we are we&amp;#39;re actually better than</text><text start="609.82" dur="6.11">what we used to be by March by large</text><text start="612.85" dur="5.13">measure so we&amp;#39;re looking for synthesis</text><text start="615.93" dur="4.75">integrate the set of language features</text><text start="617.98" dur="5.37">and si+ processes step in that direction</text><text start="620.68" dur="5.19">and then we need an articulated</text><text start="623.35" dur="6.38">guideline for how to use it if you just</text><text start="625.87" dur="7.29">use the new features just as features</text><text start="629.73" dur="5.23">we&amp;#39;re wasting time and if we don&amp;#39;t use</text><text start="633.16" dur="6">them while we&amp;#39;re getting the old stuff</text><text start="634.96" dur="6.72">we need to use a new set of features new</text><text start="639.16" dur="2.99">set of techniques to gain what we really</text><text start="641.68" dur="4.08">want</text><text start="642.15" dur="6.46">dependable well performing maintainable</text><text start="645.76" dur="4.74">software and it&amp;#39;s those guidelines I</text><text start="648.61" dur="7.14">refer to when I&amp;#39;m calling when I talk</text><text start="650.5" dur="7.44">about style so here&amp;#39;s an overview first</text><text start="655.75" dur="4.02">I&amp;#39;ll give you an example of what I think</text><text start="657.94" dur="5.61">is ghastly I don&amp;#39;t like to do without</text><text start="659.77" dur="7.92">then I&amp;#39;m going to talk about the various</text><text start="663.55" dur="7.16">aspects of this as this stuff and that&amp;#39;s</text><text start="667.69" dur="5.94">that&amp;#39;s that there&amp;#39;s a paper that I wrote</text><text start="670.71" dur="5.02">this one doesn&amp;#39;t work over there on the</text><text start="673.63" dur="4.11">screen but you see that paper software</text><text start="675.73" dur="3.78">structure for infrastructure software</text><text start="677.74" dur="4.38">development for infrastructure that&amp;#39;s</text><text start="679.51" dur="4.65">paper I wrote at the same time as I was</text><text start="682.12" dur="4.35">writing this talk so there&amp;#39;s great</text><text start="684.16" dur="4.74">overlap in the examples there&amp;#39;s not a</text><text start="686.47" dur="4.41">written version of this talk but if you</text><text start="688.9" dur="6.39">read that paper you&amp;#39;ll do fine it&amp;#39;s in</text><text start="690.88" dur="5.94">this it&amp;#39;s a key paper and this week in</text><text start="695.29" dur="6.57">this monsters</text><text start="696.82" dur="9.87">a terribly computer so I&amp;#39;m going to talk</text><text start="701.86" dur="6.57">about C++ 11 but not really about the</text><text start="706.69" dur="4.7">language features I&amp;#39;m going to talk</text><text start="708.43" dur="5.85">about how to use it well and this is</text><text start="711.39" dur="5.56">part of a long term project to figure</text><text start="714.28" dur="4.56">out how to use C++ well how to figure</text><text start="716.95" dur="4.41">out how to blend the language features</text><text start="718.84" dur="4.74">into coherent</text><text start="721.36" dur="4.65">style and I&amp;#39;m not going to talk about</text><text start="723.58" dur="4.89">the individual features except when I</text><text start="726.01" dur="5.75">absolutely have to if you want to have a</text><text start="728.47" dur="7.59">feature by feature explanation of C++ 11</text><text start="731.76" dur="5.95">which was approved last year there&amp;#39;s a</text><text start="736.06" dur="5.28">picture of the committee in Spain</text><text start="737.71" dur="6.39">sharing after the final vote then you</text><text start="741.34" dur="6.09">can go to my C++ 11 FAQ and there&amp;#39;s</text><text start="744.1" dur="4.83">feature feature feature feature and if</text><text start="747.43" dur="4.14">that&amp;#39;s your view of the world that&amp;#39;s</text><text start="748.93" dur="5.55">fine that&amp;#39;s where you look I&amp;#39;m trying to</text><text start="751.57" dur="5.28">see how to blend it most of this is</text><text start="754.48" dur="5.7">shipping this is not a science fiction</text><text start="756.85" dur="6.09">talk no compiler ships every detail and</text><text start="760.18" dur="8.28">but all the major compilers ship</text><text start="762.94" dur="7.29">important parts of the of C++ 11 so you</text><text start="768.46" dur="5.7">can experiment with it you can actually</text><text start="770.23" dur="6.12">use some of it in shipping code and the</text><text start="774.16" dur="5.43">standard library is shipping basically</text><text start="776.35" dur="6.3">complete so here is some piece of code</text><text start="779.59" dur="5.999">that I think is pretty ugly and it&amp;#39;s</text><text start="782.65" dur="6.57">asking for inefficiencies and asking for</text><text start="785.589" dur="8.671">errors this happens to be Q sort very</text><text start="789.22" dur="9.54">common very popular nineteen sort of</text><text start="794.26" dur="7.23">early seventies kind of function it&amp;#39;s</text><text start="798.76" dur="4.59">sort some memory you have to give the</text><text start="801.49" dur="4.11">number of bytes of elements you have to</text><text start="803.35" dur="7.47">write an element comparison function and</text><text start="805.6" dur="6.93">passed it if you if you have to explain</text><text start="810.82" dur="2.25">this to a novice you&amp;#39;re probably in</text><text start="812.53" dur="3.27">trouble</text><text start="813.07" dur="4.35">like I have some calls of Q sort there</text><text start="815.8" dur="4.07">and I have to give the number of</text><text start="817.42" dur="5.31">elements I mean why don&amp;#39;t why doesn&amp;#39;t</text><text start="819.87" dur="5.59">doesn&amp;#39;t the array know it&amp;#39;s a number of</text><text start="822.73" dur="5.4">elements why does an array of dobrow</text><text start="825.46" dur="5.55">doesn&amp;#39;t know the size of a double well</text><text start="828.13" dur="6.09">and why does the language not know how</text><text start="831.01" dur="5.4">to compare doubles the pipe point is</text><text start="834.22" dur="4.41">that we have carefully thrown away all</text><text start="836.41" dur="4.14">the useful information that could have</text><text start="838.63" dur="3.93">answered those questions and we&amp;#39;re</text><text start="840.55" dur="6.48">dealing with memories and number of</text><text start="842.56" dur="6.75">bytes in memory and that&amp;#39;s just throwing</text><text start="847.03" dur="4.35">away you have to use an inefficient</text><text start="849.31" dur="3.99">indirect function call that prevents</text><text start="851.38" dur="3.09">inlining just to make sure that things</text><text start="853.3" dur="3.69">are slow</text><text start="854.47" dur="6.51">and you have many opportunities for</text><text start="856.99" dur="7.11">writing more code and for writing bugs</text><text start="860.98" dur="6.72">and if you look at the implementation of</text><text start="864.1" dur="6.78">Q sort it&amp;#39;s pretty ghastly I looked at</text><text start="867.7" dur="6.42">the web and out of about 20 versions of</text><text start="870.88" dur="6.99">Q sort that I found I would say 18 was</text><text start="874.12" dur="5.76">educational frauds they they they were</text><text start="877.87" dur="4.14">simplified so they were easier to</text><text start="879.88" dur="3.99">understand and in the process of</text><text start="882.01" dur="5.46">simplification they became totally</text><text start="883.87" dur="5.43">unrealistic they could compare integers</text><text start="887.47" dur="5.91">for instance but if you look at it</text><text start="889.3" dur="6.42">swap swaps bites it only works for plain</text><text start="893.38" dur="4.82">old data if you have a higher level data</text><text start="895.72" dur="5.31">structure it doesn&amp;#39;t work furthermore</text><text start="898.2" dur="7.03">swapping element byte for byte is just</text><text start="901.03" dur="6.54">not a good idea it it&amp;#39;s slow a lot of</text><text start="905.23" dur="4.95">indirect function calls again slows</text><text start="907.57" dur="4.77">things down this this is what I would</text><text start="910.18" dur="6.18">like to get away from it&amp;#39;s far too much</text><text start="912.34" dur="5.34">code it&amp;#39;s far too error-prone it&amp;#39;s far</text><text start="916.36" dur="2.88">too hard to maintain</text><text start="917.68" dur="4.04">it&amp;#39;s far too hard to maintain</text><text start="919.24" dur="6.78">efficiently when when Hardware change</text><text start="921.72" dur="8.32">this is an unfair example I don&amp;#39;t think</text><text start="926.02" dur="7.05">so I didn&amp;#39;t make it up it&amp;#39;s been used in</text><text start="930.04" dur="6.6">education for decades to teach new</text><text start="933.07" dur="5.61">programmers how to write code and the</text><text start="936.64" dur="5.28">style is not uncommon in production code</text><text start="938.68" dur="7.04">I wish it were what it isn&amp;#39;t and I&amp;#39;ve</text><text start="941.92" dur="6.9">seen worse much much worse than this</text><text start="945.72" dur="7.03">what I showed you was quality shipping</text><text start="948.82" dur="7.23">code of that style the amateurs do much</text><text start="952.75" dur="5.76">worse and the students aim for this</text><text start="956.05" dur="4.289">level of code they feel great when they</text><text start="958.51" dur="4.92">write this code they are convinced</text><text start="960.339" dur="7.951">they&amp;#39;re writing efficient good code it&amp;#39;s</text><text start="963.43" dur="7.53">cool I add they think it&amp;#39;s cool and then</text><text start="968.29" dur="4.14">I adults did it maybe their idols did it</text><text start="970.96" dur="4.17">back when there was nothing else you</text><text start="972.43" dur="5.72">could do but still this is the kind of</text><text start="975.13" dur="4.88">code that bright students aims all right</text><text start="978.15" dur="7.45">this is sad</text><text start="980.01" dur="7.62">and it&amp;#39;s not just a C C++ style issue it</text><text start="985.6" dur="6.47">happens in other languages</text><text start="987.63" dur="7.53">but I see it more in C and C style C++</text><text start="992.07" dur="6.18">so that that&amp;#39;s the problem I&amp;#39;m talking</text><text start="995.16" dur="5.88">about C++ and using C++ so this is what</text><text start="998.25" dur="7.74">I like to to get away from and it</text><text start="1001.04" dur="9.24">matters I think it&amp;#39;s the the bad use the</text><text start="1005.99" dur="7.56">the inefficient use of C++ is it&amp;#39;s one</text><text start="1010.28" dur="5.31">of the worst problems it the good news</text><text start="1013.55" dur="4.17">is that makes progress relatively easy</text><text start="1015.59" dur="4.8">you don&amp;#39;t need any new compilers new</text><text start="1017.72" dur="7.89">language features on the other hand bad</text><text start="1020.39" dur="8.13">code breeds more bad code people people</text><text start="1025.61" dur="5.67">imitate what there is people think that</text><text start="1028.52" dur="4.53">it if it&amp;#39;s that ugly it must be that</text><text start="1031.28" dur="6.15">ugly for a reason and therefore it must</text><text start="1033.05" dur="6.24">be good or this is our house style new</text><text start="1037.43" dur="3.899">things different things must be</text><text start="1039.29" dur="4.44">dangerous and bad and definitely</text><text start="1041.329" dur="5.25">inefficient that&amp;#39;s the kind of sick</text><text start="1043.73" dur="5.82">logic you see and many are self-taught</text><text start="1046.579" dur="6.151">they take books that are written decades</text><text start="1049.55" dur="3.99">ago they asked other novices that</text><text start="1052.73" dur="4.77">doesn&amp;#39;t know either</text><text start="1053.54" dur="6.86">and well the problem is bad so what I</text><text start="1057.5" dur="5.52">want instead I mean it&amp;#39;s easy enough to</text><text start="1060.4" dur="5.26">criticize but let&amp;#39;s put something and</text><text start="1063.02" dur="4.59">said I want simple interfaces if I want</text><text start="1065.66" dur="4.62">to sort a container I want to declare</text><text start="1067.61" dur="6.39">sort of a container can&amp;#39;t quite do that</text><text start="1070.28" dur="6.03">yet but we&amp;#39;re close I can sir get simple</text><text start="1074" dur="4.62">cores you have a container that&amp;#39;s a</text><text start="1076.31" dur="5.67">vector of strings you can say sort of</text><text start="1078.62" dur="6.44">the vector of strings we can do that now</text><text start="1081.98" dur="6.36">that&amp;#39;s all right and we can get on</text><text start="1085.06" dur="6.16">compromised performance out of that that</text><text start="1088.34" dur="5.76">salt runs faster than Q sort by a large</text><text start="1091.22" dur="5.43">margin I&amp;#39;ll get back to that but the</text><text start="1094.1" dur="5.37">reason it beats it well to sort by large</text><text start="1096.65" dur="4.98">margin is it doesn&amp;#39;t throw away all that</text><text start="1099.47" dur="6.93">nice useful information we just gave it</text><text start="1101.63" dur="7.65">and we would like to write code without</text><text start="1106.4" dur="6.12">breaking the static type system we can</text><text start="1109.28" dur="6.29">do that just stay out of the dark</text><text start="1112.52" dur="6.78">corners where you make type errors and</text><text start="1115.57" dur="5.41">resource leaks well you don&amp;#39;t have to</text><text start="1119.3" dur="4.32">leak resources</text><text start="1120.98" dur="4.35">that that&amp;#39;s such an old-style code and I</text><text start="1123.62" dur="3.929">don&amp;#39;t mean Prague in a garbage collector</text><text start="1125.33" dur="4.62">I just mean don&amp;#39;t sleek it&amp;#39;s not I&amp;#39;m not</text><text start="1127.549" dur="5.821">saying it&amp;#39;s trivial in all areas but</text><text start="1129.95" dur="5.37">major progress has been done so I&amp;#39;m</text><text start="1133.37" dur="4.62">going to talk about type rich programs</text><text start="1135.32" dur="5.58">these sort of intermediate slides with</text><text start="1137.99" dur="5.13">with the big pictures just to give me a</text><text start="1140.9" dur="4.769">chance to breathe and think about coming</text><text start="1143.12" dur="4.23">next and notice you that there&amp;#39;s a break</text><text start="1145.669" dur="6.121">in the performance so I&amp;#39;m going to talk</text><text start="1147.35" dur="8.43">about hyperedge programming and when I</text><text start="1151.79" dur="7.53">talk about interfaces I mean interfaces</text><text start="1155.78" dur="5.85">that are not just strongly typed in the</text><text start="1159.32" dur="5.28">traditional sense but actually typed</text><text start="1161.63" dur="4.799">with meaningful types so if you look at</text><text start="1164.6" dur="4.89">the first set of examples of their</text><text start="1166.429" dur="9.151">increased speed with a double double</text><text start="1169.49" dur="10.95">what what&amp;#39;s that mean is it meters per</text><text start="1175.58" dur="8.04">second is it miles per hour what does</text><text start="1180.44" dur="3.72">that double mean I want to draw an</text><text start="1183.62" dur="2.04">object</text><text start="1184.16" dur="4.889">what&amp;#39;s an object there&amp;#39;s no information</text><text start="1185.66" dur="7.59">in an object ok can I can I draw an</text><text start="1189.049" dur="5.01">object that that happens to be a Fourier</text><text start="1193.25" dur="5.61">transform</text><text start="1194.059" dur="7.081">I don&amp;#39;t know and and there&amp;#39;s an example</text><text start="1198.86" dur="4.949">of a rectangle to give the rectangle</text><text start="1201.14" dur="4.44">four integers what does that mean one of</text><text start="1203.809" dur="5.581">those four integers means are the two</text><text start="1205.58" dur="6.78">points are they a point and Hytner width</text><text start="1209.39" dur="7.74">what are they I mean these kind of</text><text start="1212.36" dur="7.65">examples are pervasive in software and</text><text start="1217.13" dur="4.83">they&amp;#39;re just their interfaces they&amp;#39;re</text><text start="1220.01" dur="3.9">checked but they don&amp;#39;t check very much</text><text start="1221.96" dur="4.62">there they are basically free of</text><text start="1223.91" dur="5.31">semantics so what I&amp;#39;m recommending is a</text><text start="1226.58" dur="6.39">style where if you increase the speed</text><text start="1229.22" dur="6.92">give it a speed which is a type that so</text><text start="1232.97" dur="8.13">that you can&amp;#39;t throw in any old</text><text start="1236.14" dur="7.12">meaningless floating-point number if we</text><text start="1241.1" dur="4.59">want to draw shapes let&amp;#39;s say we draw</text><text start="1243.26" dur="5.85">shapes not not objects that&amp;#39;s sort of an</text><text start="1245.69" dur="5.04">extremely early general thing we&amp;#39;re sort</text><text start="1249.11" dur="4.199">of anything can be an object so I&amp;#39;ve</text><text start="1250.73" dur="6.84">said nothing and for the rectangle</text><text start="1253.309" dur="9">I can say what I mean a point and point</text><text start="1257.57" dur="7.079">or a point and a box an area outline and</text><text start="1262.309" dur="4.59">notice that the minute you start saying</text><text start="1264.649" dur="4.921">what you really mean you can have</text><text start="1266.899" dur="8.431">different versions as I have for</text><text start="1269.57" dur="9.75">rectangle here so one of the most</text><text start="1275.33" dur="7.589">effective ways of of controlling your</text><text start="1279.32" dur="6.66">you&amp;#39;re thinking controlling your code so</text><text start="1282.919" dur="6.411">that you don&amp;#39;t make mistakes is units we</text><text start="1285.98" dur="6.24">all talked about units in in high school</text><text start="1289.33" dur="6.309">here speed is something that&amp;#39;s meters</text><text start="1292.22" dur="8.97">per second it&amp;#39;s not meters per second</text><text start="1295.639" dur="8.221">squares it&amp;#39;s not an on a no unit thing</text><text start="1301.19" dur="6.719">divided by seconds and an acceleration</text><text start="1303.86" dur="8.189">is speed divided by some seconds people</text><text start="1307.909" dur="7.74">have again and again designed systems</text><text start="1312.049" dur="6.391">for writing such code to save them to</text><text start="1315.649" dur="5.22">from errors to what they learnt in in</text><text start="1318.44" dur="5.13">high school but they are not used in in</text><text start="1320.869" dur="6.211">in the real world in particular that&amp;#39;s</text><text start="1323.57" dur="6.27">the mass climate orbiter it tried to</text><text start="1327.08" dur="7.62">land on Mars a few years ago</text><text start="1329.84" dur="7.89">unfortunately it was about 150 miles off</text><text start="1334.7" dur="6.51">course at the time and that was the end</text><text start="1337.73" dur="8.85">of that that&amp;#39;s a five hundred and some</text><text start="1341.21" dur="7.62">sixty million dollar gadget it&amp;#39;s the</text><text start="1346.58" dur="5.13">equivalent of the lifetimes work of two</text><text start="1348.83" dur="6.809">hundred good engineers down the drain on</text><text start="1351.71" dur="8.819">this case down to Mars because somebody</text><text start="1355.639" dur="9.27">didn&amp;#39;t calculate with units Imperial</text><text start="1360.529" dur="6.99">measures here MKS system SI system here</text><text start="1364.909" dur="3.061">a constant move from the one world to</text><text start="1367.519" dur="4.62">the other</text><text start="1367.97" dur="7.199">through one of those double interfaces</text><text start="1372.139" dur="6.03">and it changed its meaning by a factor</text><text start="1375.169" dur="5.85">of four and a half in that process and</text><text start="1378.169" dur="5.521">and this one went down so why are people</text><text start="1381.019" dur="4.35">not doing this because languages don&amp;#39;t</text><text start="1383.69" dur="3.3">support them except for specialized</text><text start="1385.369" dur="4.171">languages</text><text start="1386.99" dur="3.96">and you can&amp;#39;t use specialized languages</text><text start="1389.54" dur="3.24">all the time because you have to invent</text><text start="1390.95" dur="5.07">a new one for each special application</text><text start="1392.78" dur="6.75">you could do what is on that slide at</text><text start="1396.02" dur="5.91">runtime but at one time you have to</text><text start="1399.53" dur="5.49">store the values and then you have to</text><text start="1401.93" dur="4.7">compute the correct answer when you do</text><text start="1405.02" dur="5.21">that you&amp;#39;ve doubled your memory</text><text start="1406.63" dur="6.85">requirements you&amp;#39;ve doubled your compute</text><text start="1410.23" dur="5.41">requirements and on on spaceships at</text><text start="1413.48" dur="4.17">least there&amp;#39;s two things you have a</text><text start="1415.64" dur="5.49">constant shortage of and one is memory</text><text start="1417.65" dur="7.05">and the other one is this is compute</text><text start="1421.13" dur="5.55">speed so the engineers decided like</text><text start="1424.7" dur="4.23">everybody else in their situation that</text><text start="1426.68" dur="4.85">they&amp;#39;ll just keep track of the units and</text><text start="1428.93" dur="6.48">get it right and in this particular case</text><text start="1431.53" dur="7.45">fortunately a rare case they blew it so</text><text start="1435.41" dur="6.81">let&amp;#39;s see what we can do in in C++ we</text><text start="1438.98" dur="6.72">can actually write with units if we go</text><text start="1442.22" dur="6.81">and define units and then use them so</text><text start="1445.7" dur="4.8">the basic idea of a lot of C++ is that</text><text start="1449.03" dur="3.39">you build your own types and then you</text><text start="1450.5" dur="6.12">use them as opposed to trying to write</text><text start="1452.42" dur="6.51">in a basically low-level language so</text><text start="1456.62" dur="6">here I&amp;#39;m saying that first I want some</text><text start="1458.93" dur="6.21">units and units are in the MKS system</text><text start="1462.62" dur="5.97">the subset of the SI system that can</text><text start="1465.14" dur="5.97">meters kilograms and second and a value</text><text start="1468.59" dur="5.01">is something that has a magnitude which</text><text start="1471.11" dur="9.33">is that double we&amp;#39;re seeing before and</text><text start="1473.6" dur="10.38">it has a unit so you can be two meters</text><text start="1480.44" dur="6.48">per second or you can be three kilograms</text><text start="1483.98" dur="8.82">or something like that and I can define</text><text start="1486.92" dur="13.25">speed as the unit that is meters divided</text><text start="1492.8" dur="11.82">by seconds to work and acceleration is</text><text start="1500.17" dur="7.48">is meter divided by second squared so</text><text start="1504.62" dur="7.47">you can write that and then this code</text><text start="1507.65" dur="7.11">becomes standard C++ so the code as what</text><text start="1512.09" dur="7.11">have been the textbook kind of version</text><text start="1514.76" dur="5.82">would work now the interesting thing is</text><text start="1519.2" dur="3.51">that we&amp;#39;ve been able</text><text start="1520.58" dur="4.02">what I just showed you here on the slide</text><text start="1522.71" dur="4.65">for about 10 years</text><text start="1524.6" dur="4.74">a bit longer than that and libraries</text><text start="1527.36" dur="4.83">like that has been built particularly</text><text start="1529.34" dur="5.25">there was a nice one from Fermilab that</text><text start="1532.19" dur="4.11">could do this and people had to write it</text><text start="1534.59" dur="4.83">and they had to write a notation like</text><text start="1536.3" dur="5.19">you saw there and that was a downfall of</text><text start="1539.42" dur="3.96">those libraries the physicists the</text><text start="1541.49" dur="2.64">engineers just refused to write code</text><text start="1543.38" dur="3.21">like that</text><text start="1544.13" dur="6.15">the very explicit version is unreadable</text><text start="1546.59" dur="5.4">you start using short hands and very</text><text start="1550.28" dur="5.73">soon you get something that is fairly</text><text start="1551.99" dur="6.69">obscure and basically people didn&amp;#39;t do</text><text start="1556.01" dur="5.72">it so one of the things that we can do</text><text start="1558.68" dur="5.4">these days at least when the compilers</text><text start="1561.73" dur="6.97">shipped with the feature of user-defined</text><text start="1564.08" dur="7.74">literals in all the compilers is you can</text><text start="1568.7" dur="6.51">define your own literals so you have a</text><text start="1571.82" dur="5.82">second you have a second squared and you</text><text start="1575.21" dur="6.03">can define operators these operator</text><text start="1577.64" dur="8.34">literals that says if you if you give a</text><text start="1581.24" dur="11.28">long double sub suffix by an S you make</text><text start="1585.98" dur="11.4">it into a second you make a long double</text><text start="1592.52" dur="8.1">suffix with s - it&amp;#39;s it&amp;#39;s it&amp;#39;s second</text><text start="1597.38" dur="5.13">squared and now that code like we took</text><text start="1600.62" dur="4.5">out of the textbook will actually work</text><text start="1602.51" dur="4.8">and this is essentially free it&amp;#39;s a</text><text start="1605.12" dur="4.08">compile-time computation it&amp;#39;s a simple</text><text start="1607.31" dur="3.42">compile time computation so it&amp;#39;s not</text><text start="1609.2" dur="4.11">going to slow you down</text><text start="1610.73" dur="4.95">there&amp;#39;s no no no fancy strike early in</text><text start="1613.31" dur="4.23">that code and there&amp;#39;s no runtime</text><text start="1615.68" dur="4.08">overhead it&amp;#39;s the same number of bytes</text><text start="1617.54" dur="5.34">it&amp;#39;s the same number of cycles that is</text><text start="1619.76" dur="5.07">displayed so we can now afford to have</text><text start="1622.88" dur="5.19">the checking that we knew we should have</text><text start="1624.83" dur="6.48">done but for the last two decades didn&amp;#39;t</text><text start="1628.07" dur="5.54">do and sometimes lost big so this is an</text><text start="1631.31" dur="5.07">example of what I call the tight bridge</text><text start="1633.61" dur="5.2">programming and I&amp;#39;m recommending that</text><text start="1636.38" dur="4.56">interfaces should be strongly typed but</text><text start="1638.81" dur="5.43">not just with random type what will</text><text start="1640.94" dur="5.31">meaningful types assign types that have</text><text start="1644.24" dur="4.47">that that has a meaning has a semantics</text><text start="1646.25" dur="7.08">not just doubles and integers or objects</text><text start="1648.71" dur="5.4">they don&amp;#39;t tell you anything the next</text><text start="1653.33" dur="3.479">thing that&amp;#39;s</text><text start="1654.11" dur="7.319">part of what I think is is good style</text><text start="1656.809" dur="8.301">and I recommend is be careful dealing</text><text start="1661.429" dur="8.041">with resources and errors in a</text><text start="1665.11" dur="7.449">considered and systematic way so here&amp;#39;s</text><text start="1669.47" dur="7.77">an example of sort of fairly standard</text><text start="1672.559" dur="7.651">code it it looks alright I open a file</text><text start="1677.24" dur="6.93">and I close it the problem is its naive</text><text start="1680.21" dur="8.25">and this is a fairly common source of</text><text start="1684.17" dur="6.84">bugs that use F there if it&amp;#39;s only one</text><text start="1688.46" dur="6.839">line is probably fine but in a real</text><text start="1691.01" dur="8.49">program the code that&amp;#39;s actually done to</text><text start="1695.299" dur="6.301">use F may be a couple of pages and it</text><text start="1699.5" dur="4.919">may be split or several functions and</text><text start="1701.6" dur="6.959">it&amp;#39;s fairly easy to forget to get to the</text><text start="1704.419" dur="5.911">if plot so that F close after all there</text><text start="1708.559" dur="3.961">might be a return statement in there</text><text start="1710.33" dur="4.349">there might be a C long jump or there</text><text start="1712.52" dur="5.73">might be an exception and you never get</text><text start="1714.679" dur="5.521">to the bottom the closes F so everybody</text><text start="1718.25" dur="3.36">that&amp;#39;s looked at this decided oh dear we</text><text start="1720.2" dur="5.4">have to do something about it and we</text><text start="1721.61" dur="8.37">deal something do something to deal with</text><text start="1725.6" dur="6.27">exceptions now if you report errors as</text><text start="1729.98" dur="4.17">exceptions you need exception handling</text><text start="1731.87" dur="4.41">and so people write something like this</text><text start="1734.15" dur="7.05">there&amp;#39;s a try block there and we catch</text><text start="1736.28" dur="6.96">all exceptions close the file and</text><text start="1741.2" dur="5.16">everything is fine you can invent a</text><text start="1743.24" dur="5.189">better syntax for this if you like but</text><text start="1746.36" dur="4.23">it doesn&amp;#39;t change better since I could</text><text start="1748.429" dur="4.651">not change the fact that when you are</text><text start="1750.59" dur="4.74">acquiring a resource you have to</text><text start="1753.08" dur="5.339">remember that you&amp;#39;re acquiring a</text><text start="1755.33" dur="7.08">resource and then catch the exceptions</text><text start="1758.419" dur="7.591">that might be there and release it okay</text><text start="1762.41" dur="5.67">this is very ugly code there&amp;#39;s a lot of</text><text start="1766.01" dur="4.38">it and it&amp;#39;s more complicated than what I</text><text start="1768.08" dur="6.38">started out with I mean why would I</text><text start="1770.39" dur="8.46">expect code when this was error-prone</text><text start="1774.46" dur="7.54">why would I expect this to become have</text><text start="1778.85" dur="7.17">fewer errors bugs correlate with</text><text start="1782" dur="5.76">complication and with size of quote so</text><text start="1786.02" dur="5.31">we would expect there to be more bugs</text><text start="1787.76" dur="5.49">they&amp;#39;re in real life cook so that&amp;#39;s not</text><text start="1791.33" dur="3.9">good and the reason for the whole</text><text start="1793.25" dur="6.69">problem seems to be that I keep talking</text><text start="1795.23" dur="8.78">about a resource right do you see any</text><text start="1799.94" dur="7.29">resources there I see to function cause</text><text start="1804.01" dur="5.11">they happen to be well known function so</text><text start="1807.23" dur="7.56">I know that if I do an F open I should</text><text start="1809.12" dur="9.39">do an F close the manual says so the</text><text start="1814.79" dur="11.28">compiler doesn&amp;#39;t read manuals a lot of</text><text start="1818.51" dur="10.02">programmers don&amp;#39;t read manuals and it in</text><text start="1826.07" dur="6.78">a lot of resources it&amp;#39;s not one we know</text><text start="1828.53" dur="7.53">as a maintenance program or such so I</text><text start="1832.85" dur="6.17">think the idea is to represent your</text><text start="1836.06" dur="6.21">resources directly and get a rid of that</text><text start="1839.02" dur="5.8">mess there and so here&amp;#39;s the example we</text><text start="1842.27" dur="7.29">write a file handle a file handle is an</text><text start="1844.82" dur="6.96">object that owns a file handler and you</text><text start="1849.56" dur="5.7">create one of these file handle objects</text><text start="1851.78" dur="9.45">by giving it the name of the file and</text><text start="1855.26" dur="9.51">the the open mode and it opens the file</text><text start="1861.23" dur="8.28">if it can&amp;#39;t throws an exception and the</text><text start="1864.77" dur="7.74">destructor for that file handle releases</text><text start="1869.51" dur="5.91">the resource and now I can simplify my</text><text start="1872.51" dur="5.76">user code saying well here&amp;#39;s the file</text><text start="1875.42" dur="6.09">handle and then use it and at the end</text><text start="1878.27" dur="6.99">whatever we enter exit that block with</text><text start="1881.51" dur="5.91">an exception or with a return the</text><text start="1885.26" dur="4.02">structures coordinate releases the</text><text start="1887.42" dur="4.35">resource in this case closes the file</text><text start="1889.28" dur="6">that&amp;#39;s the resource acquisition is</text><text start="1891.77" dur="6.51">initialization idiom which is probably</text><text start="1895.28" dur="7.44">the best example of why I shouldn&amp;#39;t be</text><text start="1898.28" dur="8.1">in marketing anyway I didn&amp;#39;t have a good</text><text start="1902.72" dur="6.69">day when I named that and naming is not</text><text start="1906.38" dur="9.39">one of my strong Forge so so for all</text><text start="1909.41" dur="10.04">resources we can use ra íí- to to keep</text><text start="1915.77" dur="7.249">track of the symbol uses of</text><text start="1919.45" dur="8.25">of resources which are by far the most</text><text start="1923.019" dur="6.51">common examples so in the standard</text><text start="1927.7" dur="3.959">library we do it for Strings we do it</text><text start="1929.529" dur="8.37">for vector we use it for maps which</text><text start="1931.659" dur="8.791">keeps track of the the data the elements</text><text start="1937.899" dur="4.77">that is there located there we do it for</text><text start="1940.45" dur="4.229">locks we use it for fire streams we use</text><text start="1942.669" dur="5.09">it for thread handles it&amp;#39;s it&amp;#39;s deep</text><text start="1944.679" dur="6.511">deep into our standard library</text><text start="1947.759" dur="5.41">architecture and so here as an example</text><text start="1951.19" dur="5.309">there&amp;#39;s a mutex and there&amp;#39;s some shared</text><text start="1953.169" dur="6.57">data a very simplified example and then</text><text start="1956.499" dur="6.54">I grab the lock manipulate the share</text><text start="1959.739" dur="6.9">data and when I get out of that the lock</text><text start="1963.039" dur="7.08">is released one would think that you</text><text start="1966.639" dur="6.96">couldn&amp;#39;t mess up with a simple lock</text><text start="1970.119" dur="6">unlock but again if you know that the</text><text start="1973.599" dur="4.29">lock over and a lock operation takes a</text><text start="1976.119" dur="4.23">look and have to remember to get it out</text><text start="1977.889" dur="10.35">again you&amp;#39;ll probably get it right but</text><text start="1980.349" dur="12.03">for in general people can forget so we</text><text start="1988.239" dur="6.93">would try to have anything that</text><text start="1992.379" dur="5.88">considered resource owned by some kind</text><text start="1995.169" dur="6.09">of local handle but let&amp;#39;s see what</text><text start="1998.259" dur="5.67">people actually write so here is sort of</text><text start="2001.259" dur="4.88">a classic piece of code you take and</text><text start="2003.929" dur="3.93">make a new gadget and you assign it to</text><text start="2006.139" dur="7.39">well it should have been a gadget</text><text start="2007.859" dur="8.04">pointer and at the end we delete it even</text><text start="2013.529" dur="4.35">if there wasn&amp;#39;t a typo on this slide it</text><text start="2015.899" dur="3.93">would leak like mad fortunately to the</text><text start="2017.879" dur="5.34">compiler will stop that one but the</text><text start="2019.829" dur="7.19">compiler doesn&amp;#39;t work on my slides so</text><text start="2023.219" dur="6.481">imagine that P is a gadget pointer so</text><text start="2027.019" dur="4.931">there are several ways of leaking like</text><text start="2029.7" dur="4.889">returning or throwing an exception so we</text><text start="2031.95" dur="5.459">never gets to the delete P it&amp;#39;s exactly</text><text start="2034.589" dur="6.15">equivalent to the file open file close</text><text start="2037.409" dur="6.661">example and it&amp;#39;s not actually uncommon</text><text start="2040.739" dur="5.76">people use a lot of pointers and the</text><text start="2044.07" dur="5.4">pointers are not safe against exceptions</text><text start="2046.499" dur="6.751">so it leaks and people start screaming</text><text start="2049.47" dur="7.709">for garbage collectors my answer usually</text><text start="2053.25" dur="6.109">and don&amp;#39;t leak let&amp;#39;s see we could use a</text><text start="2057.179" dur="8.071">SharePoint Oh takes care of this problem</text><text start="2059.359" dur="7.81">a SharePoint er will the destructor for</text><text start="2065.25" dur="4.919">the shared pointer will release the</text><text start="2067.169" dur="6.601">resource if you&amp;#39;re you&amp;#39;re leaving its</text><text start="2070.169" dur="6.391">scope and if it&amp;#39;s shared by others the</text><text start="2073.77" dur="4.889">last structure will destroy it but look</text><text start="2076.56" dur="4.829">at the sample I saw if the leak problem</text><text start="2078.659" dur="5.281">but why am I using a SharePoint I&amp;#39;m not</text><text start="2081.389" dur="9.301">sharing anything with anybody this is</text><text start="2083.94" dur="8.87">just just my my local use of this so we</text><text start="2090.69" dur="7.08">can use what&amp;#39;s called a unique pointer</text><text start="2092.81" dur="7.299">which simply keeps track of a pointer in</text><text start="2097.77" dur="7.2">a scope so that&amp;#39;s what you use if you</text><text start="2100.109" dur="7.831">just want exception safety and want to</text><text start="2104.97" dur="5.04">have a very efficient way of making sure</text><text start="2107.94" dur="5.61">that that your pointers don&amp;#39;t mess up</text><text start="2110.01" dur="8.22">your code so this works but why have any</text><text start="2113.55" dur="8.039">kind of pointer I mean I&amp;#39;m not passing</text><text start="2118.23" dur="5.22">around anything at all so really we</text><text start="2121.589" dur="4.801">should go back to just grabbing the</text><text start="2123.45" dur="5.7">resource using it and let the destructor</text><text start="2126.39" dur="5.79">release it and again the resulting code</text><text start="2129.15" dur="6.5">is much simpler it&amp;#39;s also more efficient</text><text start="2132.18" dur="7.159">so elegance and short code and</text><text start="2135.65" dur="7.87">performance tend to go hand in hand so</text><text start="2139.339" dur="6.731">basically the lesson I draw for this is</text><text start="2143.52" dur="4.53">that we should prefer classes where the</text><text start="2146.07" dur="5.76">resource management is part of their</text><text start="2148.05" dur="5.61">fundamental semantics I mean vector</text><text start="2151.83" dur="6.45">keeps track of elements that&amp;#39;s what they</text><text start="2153.66" dur="7.17">test do threads keep track of some</text><text start="2158.28" dur="6.11">things in the runtime environment that&amp;#39;s</text><text start="2160.83" dur="6.39">their job they know about stacks and</text><text start="2164.39" dur="4.27">various mappings and share tooling and</text><text start="2167.22" dur="3.96">things like that I don&amp;#39;t have to do it</text><text start="2168.66" dur="5.31">it&amp;#39;s their job and so their resource</text><text start="2171.18" dur="6.03">management is embedded in the semantics</text><text start="2173.97" dur="5.369">of those types so that&amp;#39;s fine and if you</text><text start="2177.21" dur="4.32">absolutely have to pass pointers around</text><text start="2179.339" dur="3.421">and such you can pass unique pointers</text><text start="2181.53" dur="4.079">around when you&amp;#39;re just transferring</text><text start="2182.76" dur="4.079">something and you can use a share point</text><text start="2185.609" dur="4.861">if you have</text><text start="2186.839" dur="5.881">shared ownership my opinion is that you</text><text start="2190.47" dur="5.549">don&amp;#39;t share as often less you think you</text><text start="2192.72" dur="5.94">do and so you don&amp;#39;t need it as often but</text><text start="2196.019" dur="5">it&amp;#39;s certainly better then then then</text><text start="2198.66" dur="5.22">just trying to keep track of it yourself</text><text start="2201.019" dur="4.99">the reason I&amp;#39;m little bit worried about</text><text start="2203.88" dur="6.33">unique point and SharePoint and prefer</text><text start="2206.009" dur="6.6">the objects themselves is that if you</text><text start="2210.21" dur="5.039">have two pointers to something there has</text><text start="2212.609" dur="6.66">to be a protocol of who uses that object</text><text start="2215.249" dur="7.441">when and so somebody else is any point</text><text start="2219.269" dur="6.51">as a potential race condition who reads</text><text start="2222.69" dur="5.19">who writes not even with concurrency but</text><text start="2225.779" dur="7.441">just in a program when do you do the</text><text start="2227.88" dur="8.399">updates there is a problem that tends to</text><text start="2233.22" dur="5.43">get people to use pointers or shared</text><text start="2236.279" dur="4.5">pointers and things like that and that&amp;#39;s</text><text start="2238.65" dur="5.669">basically how to get a lot of data out</text><text start="2240.779" dur="8.161">of function I mean take take a simple</text><text start="2244.319" dur="7.591">example I want to add to two matrices</text><text start="2248.94" dur="5.129">the way you usually do that is you take</text><text start="2251.91" dur="5.01">in two references that&amp;#39;s a very</text><text start="2254.069" dur="5.371">efficient way of getting to the elements</text><text start="2256.92" dur="5.46">of a matrix the problem is how do you</text><text start="2259.44" dur="6.45">get the resulting matrix out again you</text><text start="2262.38" dur="5.879">have to make a new matrix and then get</text><text start="2265.89" dur="5.669">it out one way you could think about is</text><text start="2268.259" dur="6.151">pass out a pointer but then you have to</text><text start="2271.559" dur="6.06">write code like that and that&amp;#39;s just too</text><text start="2274.41" dur="5.52">ugly to to even think about and anyway</text><text start="2277.619" dur="4.321">if you did that there&amp;#39;ll be a new</text><text start="2279.93" dur="5.309">insight the function and who does the</text><text start="2281.94" dur="6.24">delete now you&amp;#39;re getting yourself a</text><text start="2285.239" dur="4.8">memory management problem and sooner or</text><text start="2288.18" dur="4.2">later you will start inventing use</text><text start="2290.039" dur="6.121">counted pointers or garbage collection</text><text start="2292.38" dur="5.639">or something like that and that&amp;#39;s not a</text><text start="2296.16" dur="4.109">good solution let&amp;#39;s try something else</text><text start="2298.019" dur="5.25">we can return a reference at least it</text><text start="2300.269" dur="8.01">looks right but again the question is</text><text start="2303.269" dur="6.661">who deletes that object and people look</text><text start="2308.279" dur="3.3">at this and it says what delete I don&amp;#39;t</text><text start="2309.93" dur="5.639">see any pointers there&amp;#39;s no pointers</text><text start="2311.579" dur="7.53">here so there is a memory management</text><text start="2315.569" dur="4.681">problem that&amp;#39;s hidden that&amp;#39;s even worse</text><text start="2319.109" dur="4.261">so there&amp;#39;s</text><text start="2320.25" dur="5.19">a lot of things that we can do this we</text><text start="2323.37" dur="5.64">can just pass in the target that we feel</text><text start="2325.44" dur="6.24">so the plus should take the two matrices</text><text start="2329.01" dur="3.87">and fill that the third matrix of your</text><text start="2331.68" dur="4.35">party is a target</text><text start="2332.88" dur="5.42">but now the normal notation of rest</text><text start="2336.03" dur="5.61">equals a plus B will no longer work</text><text start="2338.3" dur="6.25">instead we have to say operator plus of</text><text start="2341.64" dur="5.22">a comma B and dress and allocate rest</text><text start="2344.55" dur="6.18">we&amp;#39;re regressing into a simple code a</text><text start="2346.86" dur="7.35">simple code can be very efficient it can</text><text start="2350.73" dur="5.31">be very logical but you know there&amp;#39;s a</text><text start="2354.21" dur="4.64">lot of writing to be done there&amp;#39;s a lot</text><text start="2356.04" dur="5.73">of optimizations that can&amp;#39;t be done</text><text start="2358.85" dur="4.84">automatically because well the</text><text start="2361.77" dur="5.22">programmer is supposed to do it himself</text><text start="2363.69" dur="5.79">so let&amp;#39;s see what we can do I want to</text><text start="2366.99" dur="5.55">get the data cheaply out of the function</text><text start="2369.48" dur="5.76">I want to write code like that that I</text><text start="2372.54" dur="6.06">take things in by reference and I return</text><text start="2375.24" dur="8.67">a matrix I after all what does matrix</text><text start="2378.6" dur="6.9">plus - it creates a new matrix and so I</text><text start="2383.91" dur="4.38">can write code like that that&amp;#39;s what I</text><text start="2385.5" dur="6.39">want now the problem is that if say this</text><text start="2388.29" dur="7.05">was 10,000 by 10,000 matrix copying the</text><text start="2391.89" dur="5.55">matrix out is is rather expensive you</text><text start="2395.34" dur="3.66">you don&amp;#39;t want to do that and people</text><text start="2397.44" dur="3.69">start thinking how can we get it out</text><text start="2399" dur="5.97">without actually copying and that&amp;#39;s a</text><text start="2401.13" dur="6.96">couple of dirty tricks you can you can</text><text start="2404.97" dur="6.21">have a result stack of matrices and when</text><text start="2408.09" dur="5.43">it becomes unmanageable but finally</text><text start="2411.18" dur="4.47">you&amp;#39;ve just realized I don&amp;#39;t want to</text><text start="2413.52" dur="6.3">copy any matrix I just want to move it</text><text start="2415.65" dur="6.51">out I mean we know this little babies</text><text start="2419.82" dur="4.44">can do this say there&amp;#39;s a matrix it&amp;#39;s</text><text start="2422.16" dur="5.49">here I want it over here what do I do</text><text start="2424.26" dur="9.33">make a copy and destroy the original or</text><text start="2427.65" dur="9.3">do this I mean babies can do it so fine</text><text start="2433.59" dur="6.11">I don&amp;#39;t make a copy of this one give the</text><text start="2436.95" dur="4.83">copy over there and destroy the original</text><text start="2439.7" dur="4.6">there&amp;#39;s something fundamentally wrong</text><text start="2441.78" dur="5.42">that&amp;#39;s the way computers tend to work</text><text start="2444.3" dur="6.99">right you make a copy of an integer</text><text start="2447.2" dur="5.74">means that&amp;#39;s what machines do but it&amp;#39;s</text><text start="2451.29" dur="2.19">not what we want to do with matrices who</text><text start="2452.94" dur="3.24">want to be</text><text start="2453.48" dur="4.65">to move objects if it&amp;#39;s a real object if</text><text start="2456.18" dur="4.4">it&amp;#39;s a resource we want to be able to</text><text start="2458.13" dur="8.43">move it so this is the way we do this</text><text start="2460.58" dur="8.56">here is the matrix ad and I make local</text><text start="2466.56" dur="6.45">matrix inside it I fill it with all the</text><text start="2469.14" dur="6.63">right information and I return it what I</text><text start="2473.01" dur="5.31">want is instead of that to be a copy</text><text start="2475.77" dur="4.89">I want it to be the move that is our</text><text start="2478.32" dur="4.59">points or some elements and after the</text><text start="2480.66" dur="6.06">return statement rest she points to</text><text start="2482.91" dur="5.58">those elements and the internal R should</text><text start="2486.72" dur="4.55">point to no element so it goes away</text><text start="2488.49" dur="7.59">cheaply that&amp;#39;s what a move is right</text><text start="2491.27" dur="8.2">simple as that and in C++ oxs direct</text><text start="2496.08" dur="5.49">support for that way of writing code</text><text start="2499.47" dur="4.649">I&amp;#39;ve been writing code like that for a</text><text start="2501.57" dur="5.19">decade but it&amp;#39;s spit tricky now we have</text><text start="2504.119" dur="5.49">direct support that funny-looking</text><text start="2506.76" dur="6">constructor their matrix ref ref is a</text><text start="2509.609" dur="5.641">move constructor it does moves and the</text><text start="2512.76" dur="4.56">way you implement a move is to copy the</text><text start="2515.25" dur="4.619">representation that&amp;#39;s what computers can</text><text start="2517.32" dur="5.7">do and then you cero out set the</text><text start="2519.869" dur="7.801">original or representation to be be an</text><text start="2523.02" dur="8.88">empty matrix and so you do that that</text><text start="2527.67" dur="6.81">move trick and again this stuff is all</text><text start="2531.9" dur="6.27">over the standard library now vectors</text><text start="2534.48" dur="5.73">can move lists can move singly linked</text><text start="2538.17" dur="3.66">lists can move maps on orders mapped</text><text start="2540.21" dur="4.59">hash tables all these good things we</text><text start="2541.83" dur="5.49">have now they are basically resource</text><text start="2544.8" dur="6.24">handles they are treated as resources</text><text start="2547.32" dur="8.31">they can move and so if you have code</text><text start="2551.04" dur="7.62">that copies things like that that will</text><text start="2555.63" dur="5.729">now run faster which is good but also</text><text start="2558.66" dur="5.85">you can now write code that returns</text><text start="2561.359" dur="6.241">things like big vectors cheaply you</text><text start="2564.51" dur="6.24">don&amp;#39;t have to pretend you&amp;#39;re an assembly</text><text start="2567.6" dur="5.61">coder and fill a target you don&amp;#39;t have</text><text start="2570.75" dur="4.98">to mess with with memory management such</text><text start="2573.21" dur="5.55">things this is cheap this is dirt cheap</text><text start="2575.73" dur="6.3">if the matrix representation is single</text><text start="2578.76" dur="8.76">pointer to the elements as it often is</text><text start="2582.03" dur="7.75">the cost of that move is too</text><text start="2587.52" dur="5.53">integer assignments or double</text><text start="2589.78" dur="5.57">assignments that&amp;#39;s cheap for passing</text><text start="2593.05" dur="6.33">immediately limits</text><text start="2595.35" dur="7.63">okay so that was roughly what I was</text><text start="2599.38" dur="7.62">going to say here the style lessons here</text><text start="2602.98" dur="6.51">are that naked pointers are dangerous</text><text start="2607" dur="3.869">pointers an array are splendid for</text><text start="2609.49" dur="3.57">dealing with hardware at the lowest</text><text start="2610.869" dur="5.581">level they are not what we want to keep</text><text start="2613.06" dur="5.73">in our productive maintainable code so</text><text start="2616.45" dur="4.56">we keep naked naked pointers inside</text><text start="2618.79" dur="4.65">functions and classes that that</text><text start="2621.01" dur="4.92">implements something that require them</text><text start="2623.44" dur="4.74">and keep the array out of the interfaces</text><text start="2625.93" dur="4.29">use containers instead we know how to</text><text start="2628.18" dur="4.22">pipe pass them both in and out so we</text><text start="2630.22" dur="6.29">don&amp;#39;t need to use pointers and arrays</text><text start="2632.4" dur="7.3">for that pointers are and arrays</text><text start="2636.51" dur="5.77">implementation level artifacts we try to</text><text start="2639.7" dur="4.23">keep them out of it you don&amp;#39;t use</text><text start="2642.28" dur="5.97">pointers or functions to represent</text><text start="2643.93" dur="6.45">ownership and one dead giveaway for for</text><text start="2648.25" dur="4.08">people writing old-style code is the</text><text start="2650.38" dur="4.68">code little literate with new and</text><text start="2652.33" dur="5.46">deletes I mean it&amp;#39;s like code letters</text><text start="2655.06" dur="5.07">with a lock and free malloc and free I</text><text start="2657.79" dur="6.09">mean if you write that level of code</text><text start="2660.13" dur="6.29">what do you expect leaks I mean if you</text><text start="2663.88" dur="6.12">write C style code you expect C style</text><text start="2666.42" dur="6.939">errors so let&amp;#39;s try and do something</text><text start="2670" dur="6.9">better the return objects by value as I</text><text start="2673.359" dur="8.01">said because we can use with you we can</text><text start="2676.9" dur="6.89">use by value now one thing that&amp;#39;s</text><text start="2681.369" dur="5.221">extremely important if you want</text><text start="2683.79" dur="5.47">performance out of fairly high level</text><text start="2686.59" dur="5.07">code is to have reasonable data</text><text start="2689.26" dur="4.68">structures and algorithms here I&amp;#39;d like</text><text start="2691.66" dur="4.08">to to show an example that first was</text><text start="2693.94" dur="7.34">shown to me by John Bentley of</text><text start="2695.74" dur="8.73">algorithms fame make a sequence of</text><text start="2701.28" dur="6.49">random integers keeping them in order</text><text start="2704.47" dur="7.23">and so you you you you&amp;#39;re given the</text><text start="2707.77" dur="6.3">numbers 5 1 4 2 and it builds up the</text><text start="2711.7" dur="4.38">sequence as you see it there and then</text><text start="2714.07" dur="4.56">you remove them again by giving a set of</text><text start="2716.08" dur="4.2">positions of which one you you take out</text><text start="2718.63" dur="4.56">and so the</text><text start="2720.28" dur="5.34">exercises for which n is a better to use</text><text start="2723.19" dur="8.57">a linked list on a vector on an array</text><text start="2725.62" dur="6.14">and everybody gets this one wrong</text><text start="2732.66" dur="25.2">here&amp;#39;s huh my graph has disappeared</text><text start="2744.96" dur="17.25">this is embarrassing okay okay so</text><text start="2757.86" dur="4.35">imagine this to be a graph</text><text start="2762.81" dur="6.63">the imaginary low line down by the</text><text start="2767.07" dur="5.94">bottom showing efficient usage little</text><text start="2769.44" dur="7.14">time is the victim the one that is</text><text start="2773.01" dur="7.49">looking like an exponential trying to go</text><text start="2776.58" dur="8.25">through the ceiling is the list and</text><text start="2780.5" dur="7.6">trying to figure out why the the list is</text><text start="2784.83" dur="5.13">so inefficient I thought maybe it&amp;#39;s all</text><text start="2788.1" dur="3.99">this allocation that&amp;#39;s been done for the</text><text start="2789.96" dur="5.37">nodes so the little middle green line</text><text start="2792.09" dur="7.56">which you can&amp;#39;t see either is is the</text><text start="2795.33" dur="7.23">lists with allocation taken out pretty</text><text start="2799.65" dur="5.31">hopefully pre-allocated the point here</text><text start="2802.56" dur="6.03">is that the vector is always better than</text><text start="2804.96" dur="6.54">the list and the list gets worse the</text><text start="2808.59" dur="4.08">further you go out and this is for the</text><text start="2811.5" dur="5.01">case where you&amp;#39;re doing a lot of</text><text start="2812.67" dur="6.33">insertions and deletions which when I</text><text start="2816.51" dur="5.34">was taught about data structures was</text><text start="2819" dur="4.53">what you use lists for because they are</text><text start="2821.85" dur="3.56">really good and inserting deleting if</text><text start="2823.53" dur="6.39">you want to insert in the middle of</text><text start="2825.41" dur="7.02">thousand a hundred thousand integer</text><text start="2829.92" dur="5.43">vector you have to shove on average</text><text start="2832.43" dur="6.13">fifty thousand elements one position if</text><text start="2835.35" dur="6.69">you take one out you have to shove them</text><text start="2838.56" dur="5.91">above the half the way back now this is</text><text start="2842.04" dur="4.41">completely irrelevant what matters is</text><text start="2844.47" dur="5.01">the linear search to get to the</text><text start="2846.45" dur="5.97">insertion point of course you have to go</text><text start="2849.48" dur="5.51">through half of the list to find on the</text><text start="2852.42" dur="5.46">average insertion point for a list and</text><text start="2854.99" dur="4.75">in an attempt to fairness I also did the</text><text start="2857.88" dur="5.88">same vectors instead of using a binary</text><text start="2859.74" dur="6.99">search but anyway so the linear search</text><text start="2863.76" dur="5.19">dominate completely and linear search</text><text start="2866.73" dur="7.38">for vectors it&amp;#39;s not actually is such a</text><text start="2868.95" dur="8.49">good idea first of all and vector is for</text><text start="2874.11" dur="6.15">a list a list is much bigger for a given</text><text start="2877.44" dur="4.65">data structure than a vector because you</text><text start="2880.26" dur="3.69">don&amp;#39;t have to just store the element the</text><text start="2882.09" dur="3.9">integer you have to store the two</text><text start="2883.95" dur="3.63">pointers forward and backwards you have</text><text start="2885.99" dur="4.47">to use a doubly linked list if you are</text><text start="2887.58" dur="5.96">inserting otherwise you have the extra</text><text start="2890.46" dur="6.269">problems and that completely dominates</text><text start="2893.54" dur="6.62">so that the</text><text start="2896.729" dur="6.161">the graph here this graph here that you</text><text start="2900.16" dur="8.669">can&amp;#39;t see shows you that there&amp;#39;s not a</text><text start="2902.89" dur="8.399">minor disadvantage here we&amp;#39;re talking</text><text start="2908.829" dur="6.66">about things being fifty a hundred times</text><text start="2911.289" dur="6.72">slower with with a linked list and the</text><text start="2915.489" dur="4.951">traversal dominates so compactness</text><text start="2918.009" dur="6.901">matters vectors are more compact and</text><text start="2920.44" dur="7.289">lists and predictable usage patterns</text><text start="2924.91" dur="4.559">matters enormously with the vector you</text><text start="2927.729" dur="7.28">have to show a lot of elements or but</text><text start="2929.469" dur="5.54">caches are really really good at that so</text><text start="2935.19" dur="7.47">surprisingly vectors are random access</text><text start="2938.68" dur="6.419">constructs but you can stream them lists</text><text start="2942.66" dur="6.039">don&amp;#39;t have random access but when you</text><text start="2945.099" dur="5.88">traverse a lists you keep doing random</text><text start="2948.699" dur="4.981">access there&amp;#39;s a note here and goes to</text><text start="2950.979" dur="4.26">that node in memory so you actually</text><text start="2953.68" dur="6.51">random access in your memory and you&amp;#39;re</text><text start="2955.239" dur="7.23">maximizing your cache misses which is</text><text start="2960.19" dur="6.269">exactly the opposite of what you want so</text><text start="2962.469" dur="7.201">the the lesson I&amp;#39;m trying to say here is</text><text start="2966.459" dur="5.64">stay compact safe predictable and you</text><text start="2969.67" dur="7.409">have three orders of magnitude of</text><text start="2972.099" dur="13.47">performance to to to deal with here to</text><text start="2977.079" dur="11.03">gain by being compact now people have</text><text start="2985.569" dur="7.26">looked at at that graph you didn&amp;#39;t see</text><text start="2988.109" dur="6.49">and said well I don&amp;#39;t use lists of a</text><text start="2992.829" dur="5.79">hundred thousand and two hundred</text><text start="2994.599" dur="6.72">thousand elements and there&amp;#39;s two kinds</text><text start="2998.619" dur="4.38">of people as a sort of the the Google</text><text start="3001.319" dur="3.571">and Amazon people that says because I</text><text start="3002.999" dur="5.52">don&amp;#39;t have such little data structures</text><text start="3004.89" dur="5.729">and then there&amp;#39;s the students that that</text><text start="3008.519" dur="6.901">I think a thousand elements is a long</text><text start="3010.619" dur="6.99">list and so I don&amp;#39;t use that many</text><text start="3015.42" dur="6.27">hundred thousand lists but using a few</text><text start="3017.609" dur="6.39">hundred thousand element lists is</text><text start="3021.69" dur="4.319">exactly the same as a matter of fact you</text><text start="3023.999" dur="4.561">can get the performance effects out of</text><text start="3026.009" dur="5.161">individual data structures so here&amp;#39;s a</text><text start="3028.56" dur="8.1">very simple one up there Victor of</text><text start="3031.17" dur="7.35">points with with four points the way</text><text start="3036.66" dur="5.04">that will be laid down in memory if you</text><text start="3038.52" dur="6.72">use the standard is up there labeled C++</text><text start="3041.7" dur="5.25">you have a little handle a lot on C++ is</text><text start="3045.24" dur="3.51">these little handles that tells you how</text><text start="3046.95" dur="3.45">to use things and then the resource</text><text start="3048.75" dur="6.63">manage which happens to be a compact</text><text start="3050.4" dur="10.32">data structure with eight integers</text><text start="3055.38" dur="8.1">because it was integer point and that&amp;#39;s</text><text start="3060.72" dur="4.68">fine it&amp;#39;s compact you have a single</text><text start="3063.48" dur="3.63">dereference to get to it you have a</text><text start="3065.4" dur="4.77">little bit of memory overhead because</text><text start="3067.11" dur="5.19">vector keeps its elements on the</text><text start="3070.17" dur="5.25">FreeStore so you get the the extra of</text><text start="3072.3" dur="4.92">word or two as a free store header but</text><text start="3075.42" dur="3.57">that&amp;#39;s the way it looks it&amp;#39;s fairly</text><text start="3077.22" dur="3.78">compact if you don&amp;#39;t want to put it on</text><text start="3078.99" dur="2.82">the free store don&amp;#39;t but usually that</text><text start="3081" dur="3.33">you can afford it</text><text start="3081.81" dur="4.7">now I&amp;#39;m told very often that I have to</text><text start="3084.33" dur="5.1">write in a truly object-oriented style</text><text start="3086.51" dur="6.73">unless languages that ensure you do that</text><text start="3089.43" dur="7.08">and in truly object-oriented style of</text><text start="3093.24" dur="5.43">course an object is referred to by a</text><text start="3096.51" dur="2.79">reference so we have a reference to the</text><text start="3098.67" dur="2.1">object</text><text start="3099.3" dur="3.36">there&amp;#39;s the object down there and the</text><text start="3100.77" dur="9.65">next line with the for the count in it</text><text start="3102.66" dur="11.04">and this happens to be a container of of</text><text start="3110.42" dur="5.74">user-defined objects so again you have a</text><text start="3113.7" dur="6.3">container of references and there you</text><text start="3116.16" dur="6.51">have the objects so that turns the</text><text start="3120" dur="6.93">linear compact data structure into a</text><text start="3122.67" dur="6.96">link structure we just saw on this</text><text start="3126.93" dur="7.98">invisible slide what link structures do</text><text start="3129.63" dur="8.34">to your performance and and here you get</text><text start="3134.91" dur="4.86">a rough doubling of the size of the data</text><text start="3137.97" dur="3.99">structure and whenever you want to</text><text start="3139.77" dur="4.47">access an element instead of getting one</text><text start="3141.96" dur="5.37">indirection you get one two three in</text><text start="3144.24" dur="5.73">directions and in directions again these</text><text start="3147.33" dur="4.76">things that come that modern computers</text><text start="3149.97" dur="4.89">don&amp;#39;t like very much</text><text start="3152.09" dur="6.06">pointers are poison to most are up</text><text start="3154.86" dur="6.949">choices so you can get the this again</text><text start="3158.15" dur="7.139">so I recommend compact data structures</text><text start="3161.809" dur="5.431">and fairly regular access to them that&amp;#39;s</text><text start="3165.289" dur="4.56">that&amp;#39;s the winner</text><text start="3167.24" dur="5.7">similarly we have to simplify our</text><text start="3169.849" dur="5.611">control structures let&amp;#39;s let&amp;#39;s let&amp;#39;s</text><text start="3172.94" dur="5.309">look at an example that some friends of</text><text start="3175.46" dur="5.309">mine force ended me with it was a very</text><text start="3178.249" dur="4.891">simple example a lot of operating</text><text start="3180.769" dur="5.451">systems a lot of gurus have the</text><text start="3183.14" dur="7.409">operation for taking something out of</text><text start="3186.22" dur="6.899">let&amp;#39;s think of a think of it as say say</text><text start="3190.549" dur="8.101">a menu and move it over there</text><text start="3193.119" dur="8.89">that&amp;#39;s the operation and a guy wrote a</text><text start="3198.65" dur="7.139">piece of code that solved this problem</text><text start="3202.009" dur="7.951">for a particular GUI system and there</text><text start="3205.789" dur="6.631">was 25 lines of code I mean I just</text><text start="3209.96" dur="5.19">explained to what we were doing in more</text><text start="3212.42" dur="5.909">roughly one sentence take an element and</text><text start="3215.15" dur="5.369">put it over there and there was one loop</text><text start="3218.329" dur="6.78">those three tests are no 14 function</text><text start="3220.519" dur="6.451">course now the author looked at this and</text><text start="3225.109" dur="6.781">says well you know this is rather messy</text><text start="3226.97" dur="6.899">code and even though it was a</text><text start="3231.89" dur="3.869">professional experienced programmer or</text><text start="3233.869" dur="4.23">maybe because he was professional</text><text start="3235.759" dur="5.52">experience programmer he worried that it</text><text start="3238.099" dur="5.94">might not be correct I mean 25 lines of</text><text start="3241.279" dur="3.27">code with loops and conditions how will</text><text start="3244.039" dur="3.54">you know</text><text start="3244.549" dur="4.53">and is it maintainable and he decided it</text><text start="3247.579" dur="4.111">probably wasn&amp;#39;t maintainable</text><text start="3249.079" dur="4.53">because he had to think about whether it</text><text start="3251.69" dur="4.5">was right or not the next guy coming</text><text start="3253.609" dur="5.071">along would probably not think as hard</text><text start="3256.19" dur="5.069">and make it make a change and is it</text><text start="3258.68" dur="4.649">usable elsewhere no it was just full of</text><text start="3261.259" dur="6.08">things I was very specific to that</text><text start="3263.329" dur="7.311">particular GUI and the author being a</text><text start="3267.339" dur="5.68">real professional requested a review</text><text start="3270.64" dur="4.09">professionalism is very important and is</text><text start="3273.019" dur="5.22">something we&amp;#39;ve got far too little of in</text><text start="3274.73" dur="5.97">our field so the story I got was from</text><text start="3278.239" dur="5.61">the guy that came in to do the review as</text><text start="3280.7" dur="4.829">requested and they looked at it for a</text><text start="3283.849" dur="4.381">while actually</text><text start="3285.529" dur="6.661">almost the whole day and found that what</text><text start="3288.23" dur="7.17">the code really did was find the answer</text><text start="3292.19" dur="4.32">point and you can write that as a find</text><text start="3295.4" dur="5.73">out where them from the standard library</text><text start="3296.51" dur="7.829">and then it has to insert it you have to</text><text start="3301.13" dur="5.82">move it into there&amp;#39;s point and that&amp;#39;s a</text><text start="3304.339" dur="4.141">rotation so you can rotate from before</text><text start="3306.95" dur="3.54">the insertion point or you can rotate</text><text start="3308.48" dur="4.68">from behind the insertion point so you</text><text start="3310.49" dur="5.359">get that code if you if you know the</text><text start="3313.16" dur="4.439">standard library this this looks fairly</text><text start="3315.849" dur="3.461">reasonable you just don&amp;#39;t know the</text><text start="3317.599" dur="3.601">standard library there&amp;#39;s a standard</text><text start="3319.31" dur="4.44">definition you can go in and find it and</text><text start="3321.2" dur="4.8">read it it&amp;#39;s it&amp;#39;s well-defined as</text><text start="3323.75" dur="5.25">opposed to the random code and it is an</text><text start="3326" dur="4.619">algorithm the only problem is so its</text><text start="3329" dur="4.53">maintainable but it&amp;#39;s very special</text><text start="3330.619" dur="8.131">purpose Victor wasn&amp;#39;t standard vector</text><text start="3333.53" dur="7.5">it was the vector of GUI objects and the</text><text start="3338.75" dur="4.95">coordinate was was very specific to that</text><text start="3341.03" dur="5.67">library so they looked at it added a bit</text><text start="3343.7" dur="5.97">of again sake we can generalize this to</text><text start="3346.7" dur="4.889">any GUI and they came up with that</text><text start="3349.67" dur="4.649">version is called gather which is</text><text start="3351.589" dur="5.851">shipped by in several different versions</text><text start="3354.319" dur="6.211">by actually several libraries these days</text><text start="3357.44" dur="8.1">and basically what it says it&amp;#39;ll make a</text><text start="3360.53" dur="7.5">pair of the elements from before the</text><text start="3365.54" dur="4.59">insertion point the after the certain</text><text start="3368.03" dur="4.829">point and I must admit I can never</text><text start="3370.13" dur="4.29">remember what stable partition does for</text><text start="3372.859" dur="3.811">more than a few minutes because that&amp;#39;s</text><text start="3374.42" dur="4.409">not my field of specialization of my</text><text start="3376.67" dur="4.11">area but people will write this kind of</text><text start="3378.829" dur="4.53">code of course get used to it and you</text><text start="3380.78" dur="5.88">can look it up so it is shorter it is</text><text start="3383.359" dur="6.121">simpler it is faster it is usable and</text><text start="3386.66" dur="4.59">far many areas and there&amp;#39;s no loops and</text><text start="3389.48" dur="4.94">tests once you have convinced yourself</text><text start="3391.25" dur="6.18">that this is correct it&amp;#39;ll stay correct</text><text start="3394.42" dur="5.29">it takes a little bit reading of manual</text><text start="3397.43" dur="4.08">as opposed to hacking code and there are</text><text start="3399.71" dur="4.92">some people who strongly prefer to hack</text><text start="3401.51" dur="6.96">the code but this is the kind of thing</text><text start="3404.63" dur="6.93">so I&amp;#39;m trying to recommend that to a</text><text start="3408.47" dur="5.849">large extent move away from from random</text><text start="3411.56" dur="6.66">code code with loops and tests and try</text><text start="3414.319" dur="6.391">and think in terms of algorithms and how</text><text start="3418.22" dur="4.44">to generalize things this this would be</text><text start="3420.71" dur="5.399">a culture change because a lot of</text><text start="3422.66" dur="5.609">programmers are a trained at</text><text start="3426.109" dur="5.791">hacking random code and was very proud</text><text start="3428.269" dur="7.651">of of complicated control structures but</text><text start="3431.9" dur="8.55">I when I see complicated code I get</text><text start="3435.92" dur="7.679">worried and we know where bugs hide</text><text start="3440.45" dur="5.569">they-they-they one of the obvious places</text><text start="3443.599" dur="4.98">is hide isn&amp;#39;t in big chunks of code</text><text start="3446.019" dur="8.141">especially big chunk of code with a lot</text><text start="3448.579" dur="8.04">of loops and and and tests in it the</text><text start="3454.16" dur="3.929">other weights can hide is is an enormous</text><text start="3456.619" dur="4.14">number of function codes to get work</text><text start="3458.089" dur="7.22">done but anyway we try to simplify code</text><text start="3460.759" dur="10.5">and try to make it better document it as</text><text start="3465.309" dur="9.431">as as formal algorithms and so finally</text><text start="3471.259" dur="5.82">to get any of this we have to stay high</text><text start="3474.74" dur="4.23">level whenever we can and I&amp;#39;m trying to</text><text start="3477.079" dur="4.68">encourage you to believe that you can</text><text start="3478.97" dur="6.569">stay high level more often than you</text><text start="3481.759" dur="7.201">think high level there is 14,000 feet</text><text start="3485.539" dur="6.111">it&amp;#39;s taken from the top of Mauna Kea</text><text start="3488.96" dur="6.059">looking at Mountain Aloha</text><text start="3491.65" dur="6.399">anyway so people are really convinced</text><text start="3495.019" dur="4.711">that low-level code is efficient they</text><text start="3498.049" dur="4.32">actually think that low-level</text><text start="3499.73" dur="4.5">messy code is more or less definition of</text><text start="3502.369" dur="4.2">efficiency and a lot of people don&amp;#39;t</text><text start="3504.23" dur="4.98">even bother measuring because they know</text><text start="3506.569" dur="5.51">that low level is more efficient than</text><text start="3509.21" dur="6.659">high level this is complete rubbish but</text><text start="3512.079" dur="7.78">people think that way so I&amp;#39;ve been doing</text><text start="3515.869" dur="6.331">experiments with levels here here we</text><text start="3519.859" dur="6.48">have two examples a fairly classical</text><text start="3522.2" dur="6.869">loop that that sums the elements of a</text><text start="3526.339" dur="6.571">vector and then the same using the foil</text><text start="3529.069" dur="6.181">rhythm with a lambda that represented</text><text start="3532.91" dur="5.449">the second is definitely higher level</text><text start="3535.25" dur="7.829">for each from the beginning to the end</text><text start="3538.359" dur="9.16">increment the sum and I find on several</text><text start="3543.079" dur="6.331">systems with several compilers basically</text><text start="3547.519" dur="5.28">the code generated for those two cases</text><text start="3549.41" dur="6.899">identical it&amp;#39;s you you you you choose</text><text start="3552.799" dur="6.481">based on the style you like not based on</text><text start="3556.309" dur="5.421">efficiency concerns now for a</text><text start="3559.28" dur="5.94">and this Psalm is a very simple</text><text start="3561.73" dur="6.33">algorithm but if I was saying what were</text><text start="3565.22" dur="5.13">for breadth-first search versus</text><text start="3568.06" dur="4.15">depth-first search the one can be</text><text start="3570.35" dur="3.57">written like a symbol loop and the other</text><text start="3572.21" dur="4.83">one it really is an algorithm and you</text><text start="3573.92" dur="5.87">have to stick to the algorithms so try</text><text start="3577.04" dur="4.74">to do the thing that&amp;#39;s of course</text><text start="3579.79" dur="5.77">accumulators you just call the standard</text><text start="3581.78" dur="6.96">accumulate anyway but this is just an</text><text start="3585.56" dur="5.79">example of code where you might think</text><text start="3588.74" dur="4.47">there was some overhead somewhere and I</text><text start="3591.35" dur="3.57">couldn&amp;#39;t find it</text><text start="3593.21" dur="4.53">with several compilers and several</text><text start="3594.92" dur="4.77">systems here&amp;#39;s another example that have</text><text start="3597.74" dur="6.02">been doing for ages this is Q sort</text><text start="3599.69" dur="8.04">versus sort sort of course is planar</text><text start="3603.76" dur="7.3">more general and easier to use than Q</text><text start="3607.73" dur="7.23">sort and for that reason widely believes</text><text start="3611.06" dur="10.14">that has to be slower it isn&amp;#39;t for</text><text start="3614.96" dur="9">examples like sorting any reasonable</text><text start="3621.2" dur="4.68">sized container say you know I think</text><text start="3623.96" dur="6.15">this numbers for ten thousand or hundred</text><text start="3625.88" dur="7.26">thousand elements thought was two and a</text><text start="3630.11" dur="6.24">half times faster than queues or for the</text><text start="3633.14" dur="7.56">reasons there are type safety used by</text><text start="3636.35" dur="6">the optimizers better in lining you</text><text start="3640.7" dur="5.7">don&amp;#39;t have to have those indirect</text><text start="3642.35" dur="8.94">function calls it&amp;#39;s it&amp;#39;s just cleaner</text><text start="3646.4" dur="7.32">and therefore runs much faster so if you</text><text start="3651.29" dur="5.07">do a performance of C style and</text><text start="3653.72" dur="6.54">object-oriented code it&amp;#39;s it&amp;#39;s roughly</text><text start="3656.36" dur="5.82">equal but once you start using type safe</text><text start="3660.26" dur="4.77">high-level code you start getting</text><text start="3662.18" dur="5.04">performance advantages to sort being the</text><text start="3665.03" dur="4.38">standard example anything in the</text><text start="3667.22" dur="5.61">standard library you can get performance</text><text start="3669.41" dur="6.48">just by using it so low level does not</text><text start="3672.83" dur="6.36">mean efficient and don&amp;#39;t lower your</text><text start="3675.89" dur="5.88">abstraction level before you absolutely</text><text start="3679.19" dur="4.41">know you have to so this is a different</text><text start="3681.77" dur="6.54">version of the old saying that don&amp;#39;t</text><text start="3683.6" dur="8.37">don&amp;#39;t do premature optimization or John</text><text start="3688.31" dur="6.45">Bentley&amp;#39;s version don&amp;#39;t optimize yet</text><text start="3691.97" dur="5.97">and you repeat that a few times but stay</text><text start="3694.76" dur="4.74">high level as you can now you may have</text><text start="3697.94" dur="4.71">noticed that I have not said anything</text><text start="3699.5" dur="5.01">about inheritance this is partly because</text><text start="3702.65" dur="8.24">I assume you know everything about it</text><text start="3704.51" dur="8.96">and I had to cut out something secondly</text><text start="3710.89" dur="4.51">inheritance is wonderful if your</text><text start="3713.47" dur="4.72">application domain really is</text><text start="3715.4" dur="5.31">hierarchical but people seem to be</text><text start="3718.19" dur="5.64">forcing all kinds of strange things into</text><text start="3720.71" dur="5.61">hierarchies and having hierarchies just</text><text start="3723.83" dur="4.8">for the sake of hierarchies I mean you</text><text start="3726.32" dur="4.08">have a lot of programmers who think that</text><text start="3728.63" dur="5.46">object-oriented means never use a</text><text start="3730.4" dur="5.52">free-standing function and that&amp;#39;s just</text><text start="3734.09" dur="4.5">silly because most of the things we do</text><text start="3735.92" dur="4.949">does not fit into hierarchies and so</text><text start="3738.59" dur="5.279">another reason for not emphasizing</text><text start="3740.869" dur="6.691">inheritance here apart from I assume you</text><text start="3743.869" dur="6.321">know it is that it has been seriously or</text><text start="3747.56" dur="4.77">used for a last couple of decades</text><text start="3750.19" dur="3.669">object-oriented programming using</text><text start="3752.33" dur="4.74">hierarchies is a wonderful way of</text><text start="3753.859" dur="5.581">writing some code it is an awful way of</text><text start="3757.07" dur="5.36">writing all code and by the way I could</text><text start="3759.44" dur="7.77">say that of Japan just about any sort of</text><text start="3762.43" dur="7.27">general solution it doesn&amp;#39;t fit in in</text><text start="3767.21" dur="5.76">all possible cases we have to find a</text><text start="3769.7" dur="5.97">blend of things based on high-level type</text><text start="3772.97" dur="4.08">safety and things like that so I have to</text><text start="3775.67" dur="5.429">say a little bit about concurrency</text><text start="3777.05" dur="9.15">there&amp;#39;s many kinds of concurrency C++ 11</text><text start="3781.099" dur="6.601">supports types typesafe type rich</text><text start="3786.2" dur="3.75">programming at the threads and locks</text><text start="3787.7" dur="4.23">level I would like to be at a higher</text><text start="3789.95" dur="4.86">level of abstraction and threads and</text><text start="3791.93" dur="4.89">locks but we have to do systems level</text><text start="3794.81" dur="3.779">work we have to interact with the</text><text start="3796.82" dur="3.6">operating system whatever it is and</text><text start="3798.589" dur="5.131">that&amp;#39;s the level where the operating</text><text start="3800.42" dur="7.14">system is so this you can think of as a</text><text start="3803.72" dur="7.02">foundation on top of which you can build</text><text start="3807.56" dur="7.71">all the things and if that&amp;#39;s too high</text><text start="3810.74" dur="6.81">level for you you can also to do lock</text><text start="3815.27" dur="4.579">free programming on that but anyway I&amp;#39;m</text><text start="3817.55" dur="5.7">not going into details here that&amp;#39;s</text><text start="3819.849" dur="4.751">that&amp;#39;s hence perms next talk that&amp;#39;s on</text><text start="3823.25" dur="3.18">the memory</text><text start="3824.6" dur="3.9">model and a little bit about concurrency</text><text start="3826.43" dur="5.01">I believe but here is how you can write</text><text start="3828.5" dur="4.92">threading in in modern C++ I have a</text><text start="3831.44" dur="4.86">function I have a function object and</text><text start="3833.42" dur="7.77">then down there make t1 which is the</text><text start="3836.3" dur="8.04">thread that will execute F on BEC on on</text><text start="3841.19" dur="5.64">Vic 1 on a separate thread and we have</text><text start="3844.34" dur="4.95">teach you that will execute the function</text><text start="3846.83" dur="4.98">object initialized with a two on a</text><text start="3849.29" dur="6.24">separate thread and of course we then</text><text start="3851.81" dur="6.15">have to join the the threads later and</text><text start="3855.53" dur="5.46">we can start using the results very</text><text start="3857.96" dur="5.58">simple example the point here is not</text><text start="3860.99" dur="5.49">that this is new we&amp;#39;ve been writing code</text><text start="3863.54" dur="5.88">like this for 2 3 decades</text><text start="3866.48" dur="6.66">the point is that we don&amp;#39;t have to do</text><text start="3869.42" dur="5.31">any missing with void star stars or</text><text start="3873.14" dur="3.81">anything else like this</text><text start="3874.73" dur="4.86">we have gotten type safety and we&amp;#39;ve</text><text start="3876.95" dur="4.98">gotten stand-up things this will work on</text><text start="3879.59" dur="3.78">all the systems that&amp;#39;s nice and I&amp;#39;d like</text><text start="3881.93" dur="6.6">to just show that you can go a little</text><text start="3883.37" dur="10.37">bit further by passing results so here I</text><text start="3888.53" dur="8.43">make a thread T 1 that calculate F 1 and</text><text start="3893.74" dur="8.02">puts the result in the rest and we do it</text><text start="3896.96" dur="7.65">again and we join so we get the the</text><text start="3901.76" dur="6.48">standard functional style and we use</text><text start="3904.61" dur="7.56">lambda is to pass them along and finally</text><text start="3908.24" dur="6.48">we can simplify this even further by not</text><text start="3912.17" dur="5.52">talking about threads and blocks and</text><text start="3914.72" dur="5.91">joins we&amp;#39;re talking about tasks to be</text><text start="3917.69" dur="6.06">executed asynchronously a task is just</text><text start="3920.63" dur="6.81">some work to be done and here I&amp;#39;m saying</text><text start="3923.75" dur="6.6">out asynchronously like if to be called</text><text start="3927.44" dur="6.99">on some big and I would like a synchrony</text><text start="3930.35" dur="6.27">G to be called on some thick you may</text><text start="3934.43" dur="4.23">worry that I&amp;#39;m here starting to an</text><text start="3936.62" dur="4.53">asynchronous threads on the same vector</text><text start="3938.66" dur="4.89">but it&amp;#39;s Const and constants</text><text start="3941.15" dur="4.2">immutability is great in concurrent</text><text start="3943.55" dur="2.52">systems so I&amp;#39;m not actually shooting</text><text start="3945.35" dur="3.99">myself in the foot</text><text start="3946.07" dur="6.78">now async which is a standard function</text><text start="3949.34" dur="6.06">will return something that you can get</text><text start="3952.85" dur="5.58">the results from that something is</text><text start="3955.4" dur="7.98">called the future and basically</text><text start="3958.43" dur="10.08">kind of a handle to go to the threads</text><text start="3963.38" dur="7.409">result mechanism and so you get rest one</text><text start="3968.51" dur="4.859">get rest to notice there to find that&amp;#39;s</text><text start="3970.789" dur="6.151">also so I didn&amp;#39;t have to be specific</text><text start="3973.369" dur="7.531">about it also is the mechanism in C++ 11</text><text start="3976.94" dur="7.679">that says pick your type from your</text><text start="3980.9" dur="5.879">initializer so I didn&amp;#39;t have to talk</text><text start="3984.619" dur="4.41">about futures here at all I&amp;#39;m just</text><text start="3986.779" dur="5.221">saying a synchro still run F a</text><text start="3989.029" dur="5.131">synchronous to run G get the results</text><text start="3992" dur="3.5">from the first computation get the</text><text start="3994.16" dur="3">result from the second you know</text><text start="3995.5" dur="6.76">computation and we&amp;#39;re home</text><text start="3997.16" dur="7.35">so that&amp;#39;s much more elegant and I often</text><text start="4002.26" dur="5.13">faster because you would not really want</text><text start="4004.51" dur="5.01">to spawn more than one thread here the</text><text start="4007.39" dur="4.77">other one could run on the original so</text><text start="4009.52" dur="5.579">basically here&amp;#39;s a summary practiced</text><text start="4012.16" dur="5.48">hyperedge programming has said integrate</text><text start="4015.099" dur="5.48">error handling and resource handling</text><text start="4017.64" dur="5.56">focus on compact data structures and</text><text start="4020.579" dur="5.111">prefer algorithm so random code and</text><text start="4023.2" dur="6.119">build and use libraries a lot of what</text><text start="4025.69" dur="6.95">c++ is for is writing libraries you</text><text start="4029.319" dur="6.631">don&amp;#39;t have to write on the raw language</text><text start="4032.64" dur="5.02">just like we use the type system so we</text><text start="4035.95" dur="4.919">don&amp;#39;t have to write on the raw machine</text><text start="4037.66" dur="5.82">and so the first stage in most problems</text><text start="4040.869" dur="6.781">is to build a library that supports your</text><text start="4043.48" dur="6.839">application domain and you can do it the</text><text start="4047.65" dur="4.679">type safe concurrency and you have the</text><text start="4050.319" dur="5.911">standard library to get started with</text><text start="4052.329" dur="5.911">I wish we had many more area specific</text><text start="4056.23" dur="3.75">libraries that will stand up but we</text><text start="4058.24" dur="5.7">don&amp;#39;t at least there are some of them</text><text start="4059.98" dur="8.22">and so here I can I can take take</text><text start="4063.94" dur="6.54">questions I I think we have a system for</text><text start="4068.2" dur="4.859">taking questions and I think we need</text><text start="4070.48" dur="8.309">microphones so that everybody can can</text><text start="4073.059" dur="11.911">hear the questions yes this is somebody</text><text start="4078.789" dur="33.001">handing microphones around any questions</text><text start="4084.97" dur="28.5">that&amp;#39;s a question there that kind of to</text><text start="4111.79" dur="2.96">me we lose a little bit of abstraction</text><text start="4113.47" dur="4.16">when you start thinking like that</text><text start="4114.75" dur="5.65">because when you were picking the list</text><text start="4117.63" dur="5.23">versus the vector you are really</text><text start="4120.4" dur="6.3">thinking about how that was implemented</text><text start="4122.86" dur="8.1">even down to the issue of memory caching</text><text start="4126.7" dur="10.11">and stuff like that so that to me kind</text><text start="4130.96" dur="7.8">of betrays how should I say it betrays</text><text start="4136.81" dur="3.72">maybe we want to design list and vector</text><text start="4138.76" dur="4.53">in a different way because when I think</text><text start="4140.53" dur="5.84">of list I&amp;#39;m thinking of something that I</text><text start="4143.29" dur="7.14">attach to a lot or I walk through or I</text><text start="4146.37" dur="6.04">don&amp;#39;t access randomly and when I think</text><text start="4150.43" dur="4.53">vector I&amp;#39;m thinking of something that I</text><text start="4152.41" dur="4.44">need access randomly and I shouldn&amp;#39;t</text><text start="4154.96" dur="3.78">really have to think about how its</text><text start="4156.85" dur="5.67">implemented I should be able to just</text><text start="4158.74" dur="6.12">presume that if I pick a list it&amp;#39;s the</text><text start="4162.52" dur="4.71">best implementation of that fundamental</text><text start="4164.86" dur="4.14">concept right I think I understand what</text><text start="4167.23" dur="7.59">you&amp;#39;re saying and I think you happen to</text><text start="4169" dur="8.6">be wrong what we should say is that we</text><text start="4174.82" dur="5.91">need a sequence of elements and the</text><text start="4177.6" dur="7.93">default sequence of elements in C++ is a</text><text start="4180.73" dur="9.12">vector now because that is compact and</text><text start="4185.53" dur="7.92">efficient implementation mapping to</text><text start="4189.85" dur="7.94">hardware matters now if you want to</text><text start="4193.45" dur="7.85">optimize for insertion and deletion you</text><text start="4197.79" dur="6.76">say well I don&amp;#39;t want the default</text><text start="4201.3" dur="6.75">version author of a sequence</text><text start="4204.55" dur="7.77">I want the specialized one which is a</text><text start="4208.05" dur="7.39">list and if you do that you should know</text><text start="4212.32" dur="6.3">enough to say I&amp;#39;m accepting some costs</text><text start="4215.44" dur="6.75">and some problems like slow Traverse</text><text start="4218.62" dur="5.7">and more memory usage and I think too</text><text start="4222.19" dur="5.3">many people are not thinking at all</text><text start="4224.32" dur="8.55">about these things and writing bloatware</text><text start="4227.49" dur="7.24">so think about vector as a default</text><text start="4232.87" dur="4.41">container of element the default</text><text start="4234.73" dur="5.48">sequence and you parked apart from that</text><text start="4237.28" dur="6.71">only when you&amp;#39;re trying to optimize</text><text start="4240.21" dur="6.46">think about a linked list as a</text><text start="4243.99" dur="6.06">specialization as an optimization and we</text><text start="4246.67" dur="5.85">can&amp;#39;t do that up automatically for you</text><text start="4250.05" dur="6.01">people have not figured out how to pick</text><text start="4252.52" dur="7.23">data structures optimally relative to</text><text start="4256.06" dur="7.47">their use in a program and so we start</text><text start="4259.75" dur="6.84">with vector we can go to lists sometimes</text><text start="4263.53" dur="6.03">we go to map a lot we goes to unordered</text><text start="4266.59" dur="5.76">maps hash tables a lot of sets but we</text><text start="4269.56" dur="5.48">have to have a reason for doing so and I</text><text start="4272.35" dur="7.38">don&amp;#39;t think I&amp;#39;m lowering the level of</text><text start="4275.04" dur="6.88">abstraction at all in so there&amp;#39;s a</text><text start="4279.73" dur="5.25">question here I think coming out of</text><text start="4281.92" dur="5.22">Twitter it&amp;#39;s a shipping writing move</text><text start="4284.98" dur="2.99">code for a decade how did you go about</text><text start="4287.14" dur="6.87">doing it</text><text start="4287.97" dur="9.21">okay there is a version that can be</text><text start="4294.01" dur="7.26">found on the web of my favorite solution</text><text start="4297.18" dur="7.81">I I wrote a course and a book for</text><text start="4301.27" dur="5.88">novices called the programming practice</text><text start="4304.99" dur="6.03">and principle principles and practice</text><text start="4307.15" dur="7.14">using C++ and on my web pages you can</text><text start="4311.02" dur="4.77">find a support page for that and for the</text><text start="4314.29" dur="5.39">support page from that there are some</text><text start="4315.79" dur="6.9">code and in particular there is a little</text><text start="4319.68" dur="9.48">matrix library that shows how to do it</text><text start="4322.69" dur="12.57">the basic trick is that inside the</text><text start="4329.16" dur="10.06">matrix is a copy constructor and a bit</text><text start="4335.26" dur="8.73">that says whether you copy a move and so</text><text start="4339.22" dur="8.85">if I say nothing it&amp;#39;s a move if I say X</text><text start="4343.99" dur="6.96">for transfer the next copy operation</text><text start="4348.07" dur="5.88">turns into a move</text><text start="4350.95" dur="5.22">it&amp;#39;s a hack it works beautifully in the</text><text start="4353.95" dur="5.21">hands of a library implementer and the</text><text start="4356.17" dur="5.64">users don&amp;#39;t have to know about it</text><text start="4359.16" dur="6.21">anything that can be done can can be</text><text start="4361.81" dur="8.43">done and somebody has done it but today</text><text start="4365.37" dur="7.39">in C++ 11 you don&amp;#39;t have to know that</text><text start="4370.24" dur="4.8">hack and you don&amp;#39;t have to do it and the</text><text start="4372.76" dur="7.19">major compilers ship will move semantics</text><text start="4375.04" dur="4.91">in them so it is not science fiction</text><text start="4390.75" dur="4.66">thank you having a standard interface to</text><text start="4393.07" dur="4.32">your collection such as an iterator you</text><text start="4395.41" dur="4.02">can completely optimize later by</text><text start="4397.39" dur="3.45">determining at the declaration what type</text><text start="4399.43" dur="3.6">of collection whether it&amp;#39;s a vector or a</text><text start="4400.84" dur="3.9">list or a hash table or whatnot and you</text><text start="4403.03" dur="4.02">don&amp;#39;t have to change any code that is</text><text start="4404.74" dur="4.2">relying on the implementation of that</text><text start="4407.05" dur="4.95">and then second of all I have a question</text><text start="4408.94" dur="5.13">which is to do with C++ 11 I&amp;#39;ve spent a</text><text start="4412" dur="4.38">lot of time in my career over the past</text><text start="4414.07" dur="5.7">25 years writing protected data members</text><text start="4416.38" dur="5.34">with getters and setters for these with</text><text start="4419.77" dur="4.26">the presumption that later at some point</text><text start="4421.72" dur="4.68">I&amp;#39;m gonna change the logic and the rules</text><text start="4424.03" dur="4.5">about accessing those I found that</text><text start="4426.4" dur="3.33">almost never I&amp;#39;ve had to use that and</text><text start="4428.53" dur="3.72">I&amp;#39;m now starting to look at going back</text><text start="4429.73" dur="3.78">to having public data members and I&amp;#39;ve</text><text start="4432.25" dur="3.57">also tried to come up with an</text><text start="4433.51" dur="3.81">abstraction to declare a property so</text><text start="4435.82" dur="3.12">that it has getters and setters that</text><text start="4437.32" dur="3.21">could be intercepted by the class that</text><text start="4438.94" dur="3.54">owns it and I&amp;#39;m just wondering if any</text><text start="4440.53" dur="4.65">thought has been put to that let C++ 11</text><text start="4442.48" dur="4.47">or if that is a problem that we can find</text><text start="4445.18" dur="5.22">an easier way for declaring properties</text><text start="4446.95" dur="6.78">in C++ see the the notion of properties</text><text start="4450.4" dur="6.39">have crept up again and again I think</text><text start="4453.73" dur="5.7">that protected data is a pretty hopeless</text><text start="4456.79" dur="5.64">idea it got in sounded like a good idea</text><text start="4459.43" dur="6.29">and it turned out not to be so I prefer</text><text start="4462.43" dur="9.68">my data to either be public or private</text><text start="4465.72" dur="9.13">I can manage those two things properties</text><text start="4472.11" dur="5.38">with getters and setters the two things</text><text start="4474.85" dur="5.43">are very common in certain systems I&amp;#39;m</text><text start="4477.49" dur="5.49">not sure that they should be but they</text><text start="4480.28" dur="3.549">are and you can write a library that</text><text start="4482.98" dur="5.139">does</text><text start="4483.829" dur="9.54">very nice property facilities nobody has</text><text start="4488.119" dur="8.431">made that standard it was almost done</text><text start="4493.369" dur="5.49">for the previous standard and there are</text><text start="4496.55" dur="7.619">aa little work has been done in the C++</text><text start="4498.859" dur="9.421">11 timeframe for that I don&amp;#39;t know if</text><text start="4504.169" dur="7.41">that going to crop up again if it does</text><text start="4508.28" dur="6.839">it&amp;#39;ll take some time so if that really</text><text start="4511.579" dur="7.201">is a major part of your programming life</text><text start="4515.119" dur="6.83">and it is for some people think about</text><text start="4518.78" dur="7.169">how to write a little property library</text><text start="4521.949" dur="6.7">where you have a property type that</text><text start="4525.949" dur="5.91">takes as a parameter that the real type</text><text start="4528.649" dur="6.68">and you can then start overwriting the</text><text start="4531.859" dur="11.671">the getter and setter mechanisms it&amp;#39;s</text><text start="4535.329" dur="13.44">it&amp;#39;s it&amp;#39;s half a page of code I can&amp;#39;t</text><text start="4543.53" dur="5.239">hear you I can&amp;#39;t hear you</text><text start="4549.03" dur="6">wait for the mic for the parent class to</text><text start="4552.78" dur="4.259">actually intercept the get or set of</text><text start="4555.03" dur="3.589">that property and that that property</text><text start="4557.039" dur="4.5">abstraction basically got in the way of</text><text start="4558.619" dur="4.361">many times because you had to explicitly</text><text start="4561.539" dur="3.231">use the get or set to get the actual</text><text start="4562.98" dur="4.469">type to see the members of the actual</text><text start="4564.77" dur="5.829">object so our would you recommend that</text><text start="4567.449" dur="5.13">we we start to use public data and not</text><text start="4570.599" dur="3.661">worry about that and occasionally change</text><text start="4572.579" dur="2.671">the code that accesses it when a rule</text><text start="4574.26" dur="4.319">comes into place</text><text start="4575.25" dur="7.05">i I I can&amp;#39;t answer that without knowing</text><text start="4578.579" dur="6.06">the application domain similarly some</text><text start="4582.3" dur="4.799">people have found the get on the the the</text><text start="4584.639" dur="4.71">property library is sufficient others</text><text start="4587.099" dur="4.29">are found insufficient it seems to</text><text start="4589.349" dur="5.161">depend critically on what you are doing</text><text start="4591.389" dur="5.04">and you should talk to people who who</text><text start="4594.51" dur="2.93">know your application area better than I</text><text start="4596.429" dur="5.091">do</text><text start="4597.44" dur="4.08">great we got a question right back there</text><text start="4602.789" dur="6.81">there are Joint Strike Fighter C++</text><text start="4606.539" dur="5.52">mm-hmm coding guidelines and as you were</text><text start="4609.599" dur="5.881">part of developing those and you made a</text><text start="4612.059" dur="8.491">comment that those did not include</text><text start="4615.48" dur="7.65">exceptions because ii did not have have</text><text start="4620.55" dur="5.069">enough support to use exceptions in</text><text start="4623.13" dur="5.94">mission-critical applications and that</text><text start="4625.619" dur="6">was in 2005 so i was just wondering if</text><text start="4629.07" dur="4.649">the tools finally caught up and what</text><text start="4631.619" dur="4.801">were their problems that exceptions good</text><text start="4633.719" dur="6.21">reveals so what what he&amp;#39;s talking about</text><text start="4636.42" dur="5.61">is the guidelines for writing the flight</text><text start="4639.929" dur="4.23">controller software for the next</text><text start="4642.03" dur="11.1">generation strike fighter</text><text start="4644.159" dur="12.44">the f-35 one thing that you have to take</text><text start="4653.13" dur="7.56">into account when you write work</text><text start="4656.599" dur="7.96">software for that is that a small</text><text start="4660.69" dur="8.549">mistake in the code can lose you a very</text><text start="4664.559" dur="6.511">expensive plane and possibly a pilot the</text><text start="4669.239" dur="4.23">rules were written with a safety officer</text><text start="4671.07" dur="5.16">sitting at the end of the table and</text><text start="4673.469" dur="6.5">every half hour piping up saying but is</text><text start="4676.23" dur="5.81">it safe we&amp;#39;re safe is defined as</text><text start="4679.969" dur="5.371">somebody might die</text><text start="4682.04" dur="5.07">if it isn&amp;#39;t now this is sort of slightly</text><text start="4685.34" dur="7.95">ironic when you&amp;#39;re talking about a</text><text start="4687.11" dur="8.81">fighter plane but so the concern here is</text><text start="4693.29" dur="6.41">about reliability but also performance</text><text start="4695.92" dur="7.42">in particular it is a hard real-time</text><text start="4699.7" dur="6.58">problem so one of the rules for hard</text><text start="4703.34" dur="8.19">real-time is that every operation has to</text><text start="4706.28" dur="7.8">be predictable and in C++ actually every</text><text start="4711.53" dur="6.27">operation is predictable with the</text><text start="4714.08" dur="9.51">exception of new and delete so you can&amp;#39;t</text><text start="4717.8" dur="8.64">use those and throw and dynamic cast we</text><text start="4723.59" dur="4.68">actually found this developed a constant</text><text start="4726.44" dur="3.45">time dynamic cost I don&amp;#39;t know if it&amp;#39;s</text><text start="4728.27" dur="4.77">actually used if you know of my</text><text start="4729.89" dur="5.85">publication record we actually developed</text><text start="4733.04" dur="6.17">a fast dynamic cost but getting back to</text><text start="4735.74" dur="7.02">the exceptions if you throw an exception</text><text start="4739.21" dur="7.09">you want a guarantee that if hand gets</text><text start="4742.76" dur="8.07">to a handler within a very small number</text><text start="4746.3" dur="6.81">of milliseconds there&amp;#39;s no guarantee in</text><text start="4750.83" dur="5.01">the language for that to happen there&amp;#39;s</text><text start="4753.11" dur="5.73">no guarantee that a throw from a given</text><text start="4755.84" dur="4.86">point comes from the same source so it</text><text start="4758.84" dur="4.77">may take different times this is not</text><text start="4760.7" dur="5.61">predictable therefore it&amp;#39;s not useful it</text><text start="4763.61" dur="6.38">would become useful the minute you had a</text><text start="4766.31" dur="7.94">tool that analyzed all the throw paths</text><text start="4769.99" dur="8.86">so the handlers and gave you back a</text><text start="4774.25" dur="7.48">reliable upper bound on the time that</text><text start="4778.85" dur="6.3">you took to get there that tool does not</text><text start="4781.73" dur="7.62">exist I don&amp;#39;t think the tool could exist</text><text start="4785.15" dur="6.12">in general for all code however messy I</text><text start="4789.35" dur="6.59">think you would hit the haunting problem</text><text start="4791.27" dur="8.67">but you could say you could build a tool</text><text start="4795.94" dur="6.94">that gave you that bound or said it</text><text start="4799.94" dur="5.73">couldn&amp;#39;t do it in which case if the</text><text start="4802.88" dur="4.41">bound was was small enough you&amp;#39;d be</text><text start="4805.67" dur="4.56">allowed to use exception handling and</text><text start="4807.29" dur="6">your code would get get cleaner and I</text><text start="4810.23" dur="4.739">think more more reliable but we don&amp;#39;t</text><text start="4813.29" dur="4.579">have that tour today either</text><text start="4814.969" dur="6.84">I had expected to have it today but</text><text start="4817.869" dur="7.301">other things came in the way I don&amp;#39;t</text><text start="4821.809" dur="6.451">know if the if the airplane guys have it</text><text start="4825.17" dur="6.75">I just I don&amp;#39;t know all right we got</text><text start="4828.26" dur="5.549">another question there so you talked</text><text start="4831.92" dur="5.279">about you think stack allocation and</text><text start="4833.809" dur="4.801">using just having objects be declared on</text><text start="4837.199" dur="3">the stack where we&amp;#39;re possible and</text><text start="4838.61" dur="4.799">that&amp;#39;s something I try to do as much as</text><text start="4840.199" dur="5.46">I can but it&amp;#39;s not always clear that the</text><text start="4843.409" dur="6.181">stack has enough room for large objects</text><text start="4845.659" dur="6.931">and in those situations if I happen to</text><text start="4849.59" dur="3.899">be the unlucky stack frame right after a</text><text start="4852.59" dur="3.21">big allocation</text><text start="4853.489" dur="5.041">I sometimes crash and I find that there</text><text start="4855.8" dur="7.02">is no standard compliant way for me to</text><text start="4858.53" dur="7.649">deal with that do you know of this being</text><text start="4862.82" dur="4.949">a larger problem and you know if there</text><text start="4866.179" dur="4.98">is a good way to ensure that you don&amp;#39;t</text><text start="4867.769" dur="6.72">run out of stack space there&amp;#39;s no</text><text start="4871.159" dur="6.84">standard way of reporting that you&amp;#39;ve</text><text start="4874.489" dur="6.21">run out of stack that&amp;#39;s unfortunate and</text><text start="4877.999" dur="4.77">it&amp;#39;s a problem especially in embedded</text><text start="4880.699" dur="5.55">systems where there&amp;#39;s not as much stack</text><text start="4882.769" dur="5.671">as we might be the used to and the only</text><text start="4886.249" dur="4.89">thing I can recommend is not to put</text><text start="4888.44" dur="5.159">really large objects on the stack in</text><text start="4891.139" dur="5.011">large large numbers because usually</text><text start="4893.599" dur="5.821">there&amp;#39;s these days quite a lot of sex</text><text start="4896.15" dur="5.849">base and you saw the objects I was</text><text start="4899.42" dur="5.639">dealing with by and large for handles</text><text start="4901.999" dur="6.151">and and the victor 4 million elements</text><text start="4905.059" dur="5.67">takes up three words on the stack so</text><text start="4908.15" dur="5.279">that&amp;#39;s not not the problem and and</text><text start="4910.729" dur="5.821">that&amp;#39;s that alleviates the problem in in</text><text start="4913.429" dur="5.641">many many areas so I can&amp;#39;t solve the</text><text start="4916.55" dur="4.049">general thing it&amp;#39;s it&amp;#39;s something to do</text><text start="4919.07" dur="4.89">with the interaction the hardware and</text><text start="4920.599" dur="7.08">non non predictable ways for stack</text><text start="4923.96" dur="5.13">overflow but use smaller objects and get</text><text start="4927.679" dur="8.34">them as handles</text><text start="4929.09" dur="9.089">that&amp;#39;s the only thing I can do so so so</text><text start="4936.019" dur="4.08">it seems that your slide about</text><text start="4938.179" dur="4.05">inheritance and how it&amp;#39;s been overused</text><text start="4940.099" dur="4.951">and forcing objects into hierarchies</text><text start="4942.229" dur="5.461">that aren&amp;#39;t necessarily really required</text><text start="4945.05" dur="3.54">it seems to me that part of the reason</text><text start="4947.69" dur="4.799">that people do</text><text start="4948.59" dur="7.049">that is to build some sort of interface</text><text start="4952.489" dur="4.681">for that code that they can you know</text><text start="4955.639" dur="3.951">pass objects that would have those</text><text start="4957.17" dur="4.44">curricular methods called method calls</text><text start="4959.59" dur="5.17">obviously one solution to that is to</text><text start="4961.61" dur="5.19">instead use the template system and you</text><text start="4964.76" dur="3.839">know to get the generosity involved in</text><text start="4966.8" dur="3.6">that but as soon as you start throwing</text><text start="4968.599" dur="4.08">templates at people some people gets</text><text start="4970.4" dur="4.77">icky about that and decide that they</text><text start="4972.679" dur="4.621">would rather do the object inheriting</text><text start="4975.17" dur="4.38">object-oriented inheritance is there any</text><text start="4977.3" dur="7.169">you have any comments or suggestions</text><text start="4979.55" dur="7.68">about how to fix that yeah that slide is</text><text start="4984.469" dur="8.46">really a talk that&amp;#39;s longer than this</text><text start="4987.23" dur="7.56">talk sometimes I and noticed that a</text><text start="4992.929" dur="6.06">having sample op that said I didn&amp;#39;t want</text><text start="4994.79" dur="6.24">an object to be my my base class my</text><text start="4998.989" dur="5.701">interface because that&amp;#39;s a meaningless</text><text start="5001.03" dur="6.87">interface but I suggest the shape might</text><text start="5004.69" dur="8.19">be a good interface abstraction which is</text><text start="5007.9" dur="7.529">a base class furthermore a widget might</text><text start="5012.88" dur="5.64">be another one the the graphics domain</text><text start="5015.429" dur="5.79">is right with the useful abstractions</text><text start="5018.52" dur="5.55">that are hierarchical and so that&amp;#39;s fine</text><text start="5021.219" dur="6.75">and you can even parameterize them</text><text start="5024.07" dur="6.27">things like vectors of shape pointers is</text><text start="5027.969" dur="5.821">a good example of where you get a</text><text start="5030.34" dur="8.16">mixture of generics and an</text><text start="5033.79" dur="9.69">object-oriented code I&amp;#39;m not saying</text><text start="5038.5" dur="6.869">everything should be templates I just</text><text start="5043.48" dur="4.44">didn&amp;#39;t have it enough time to discuss</text><text start="5045.369" dur="4.531">where the trade-offs lie not everything</text><text start="5047.92" dur="5.1">should be a hierarchy not everything</text><text start="5049.9" dur="9.81">should be a template great and a</text><text start="5053.02" dur="11.81">question so C++ is becoming like a huge</text><text start="5059.71" dur="9">Swiss Army knife is there some thought</text><text start="5064.83" dur="6.159">being put into creating sort of like a</text><text start="5068.71" dur="8.73">strict mode which would be like a</text><text start="5070.989" dur="10.09">guideline for compilers to try to</text><text start="5077.44" dur="5.5">sort of forbade some obsolete features</text><text start="5081.079" dur="6.42">or features which could be dangerous</text><text start="5082.94" dur="12.409">like protected or maybe friend maybe go</text><text start="5087.499" dur="10.171">to C++ is large but it&amp;#39;s not</text><text start="5095.349" dur="6.551">particularly larger than then other</text><text start="5097.67" dur="7.65">languages people are using it is really</text><text start="5101.9" dur="7.319">hard to team in general what is</text><text start="5105.32" dur="9.41">dangerous or what is inefficient or what</text><text start="5109.219" dur="5.511">is useless or whatever criteria is my</text><text start="5114.849" dur="7.181">impression is that everything that&amp;#39;s in</text><text start="5117.26" dur="7.109">C++ is essential to some user community</text><text start="5122.03" dur="5.25">of maybe a couple of hundred thousand</text><text start="5124.369" dur="5.37">people and so in take away anything</text><text start="5127.28" dur="4.919">major and you heard a couple of hundred</text><text start="5129.739" dur="4.771">thousand people well basically you can&amp;#39;t</text><text start="5132.199" dur="4.201">because they&amp;#39;ll just use it they use it</text><text start="5134.51" dur="4.589">anyway and ignore you take away</text><text start="5136.4" dur="4.969">something minor and it&amp;#39;s ridiculous</text><text start="5139.099" dur="4.411">because you don&amp;#39;t have any effect and</text><text start="5141.369" dur="4.391">whenever you take something mine and you</text><text start="5143.51" dur="5.04">still break some old code and people</text><text start="5145.76" dur="5.97">really hate you breaking their code for</text><text start="5148.55" dur="5.879">any reason whatsoever because it hurt</text><text start="5151.73" dur="6.179">them now so he has been a lot of</text><text start="5154.429" dur="5.88">thoughts about subsetting C++ we we</text><text start="5157.909" dur="5.371">don&amp;#39;t really know how to do it because</text><text start="5160.309" dur="4.921">some of the most dangerous features in</text><text start="5163.28" dur="3.93">terms of what you can do with them are</text><text start="5165.23" dur="3.57">essential for efficient implementation</text><text start="5167.21" dur="9.619">of the higher level abstractions that we</text><text start="5168.8" dur="10.14">really want so a subset would have to</text><text start="5176.829" dur="5.64">tell the difference between an</text><text start="5178.94" dur="6.77">abstraction we like like vector and</text><text start="5182.469" dur="8.201">feature we consider dangerous like</text><text start="5185.71" dur="7.9">pointers into arrays and and accept the</text><text start="5190.67" dur="5.13">latter only behind the interfaces this</text><text start="5193.61" dur="4.35">is this is quite hard but sort of the</text><text start="5195.8" dur="5.43">first attempts to create a safe subset</text><text start="5197.96" dur="6.389">of C++ must be almost thirty years ago</text><text start="5201.23" dur="5.55">long before those core C++ and we again</text><text start="5204.349" dur="4.23">and again find the people&amp;#39;s criteria for</text><text start="5206.78" dur="4.83">what they want and don&amp;#39;t want very</text><text start="5208.579" dur="4.83">dramatically and it&amp;#39;s context in</text><text start="5211.61" dur="4.14">the distinction between inside and</text><text start="5213.409" dur="4.141">outside and abstraction has to be part</text><text start="5215.75" dur="3.659">of the answer and nobody has actually</text><text start="5217.55" dur="4.35">done something really useful for that</text><text start="5219.409" dur="5.04">and what you get instead is coding</text><text start="5221.9" dur="5.58">guidelines and actually verifiers</text><text start="5224.449" dur="4.861">against coding guidelines that do know</text><text start="5227.48" dur="4.34">the difference between the set of</text><text start="5229.31" dur="5.099">abstractions for a particular domain</text><text start="5231.82" dur="5.56">that you can do but doing it in general</text><text start="5234.409" dur="4.71">I don&amp;#39;t know how to because for any</text><text start="5237.38" dur="2.9">major feature that&amp;#39;s a community that</text><text start="5239.119" dur="3.6">relies on it</text><text start="5240.28" dur="12.339">okay you got time for one more question</text><text start="5242.719" dur="11.551">oh you know what there is a panel at the</text><text start="5252.619" dur="3.21">end of the day so your questions in your</text><text start="5254.27" dur="3.75">head and yeah we&amp;#39;ll get out later yeah</text><text start="5255.829" dur="4.711">that&amp;#39;s that&amp;#39;s a way of asking questions</text><text start="5258.02" dur="4.98">at the end of today and they at the end</text><text start="5260.54" dur="4.74">of tomorrow and that may even be better</text><text start="5263" dur="4.619">because I won&amp;#39;t be the only one</text><text start="5265.28" dur="4.26">answering the questions and you may get</text><text start="5267.619" dur="5.73">more than one answer anyways ask</text><text start="5269.54" dur="5.429">question just hang on okay yeah find</text><text start="5273.349" dur="3.87">questions about move constructors yeah</text><text start="5274.969" dur="3.541">um so first I want to say that they&amp;#39;re</text><text start="5277.219" dur="4.351">definitely gonna make our code faster</text><text start="5278.51" dur="6.18">it&amp;#39;s fantastic that they&amp;#39;re at it but in</text><text start="5281.57" dur="4.859">our experience with programmers is they</text><text start="5284.69" dur="3.659">really are lazy and they don&amp;#39;t like</text><text start="5286.429" dur="4.23">writing default constructors copy</text><text start="5288.349" dur="4.35">constructors operator equals and now I&amp;#39;m</text><text start="5290.659" dur="4.23">seeing with move constructors like a 66%</text><text start="5292.699" dur="5.551">increase in things they&amp;#39;re gonna be lazy</text><text start="5294.889" dur="5.371">about so do you have any suggestions or</text><text start="5298.25" dur="3.119">guidelines on or maybe you should be</text><text start="5300.26" dur="3.569">like I don&amp;#39;t I&amp;#39;ll are warning and the</text><text start="5301.369" dur="5.491">compiler can see something on things we</text><text start="5303.829" dur="5.1">can do to improve that there&amp;#39;s a set of</text><text start="5306.86" dur="9.319">rules for what defaults you get and</text><text start="5308.929" dur="12.391">don&amp;#39;t get and basically if you don&amp;#39;t</text><text start="5316.179" dur="6.67">write at this doctor you probably don&amp;#39;t</text><text start="5321.32" dur="3.33">have any need for move and copy</text><text start="5322.849" dur="3.211">constructors you get the defaults</text><text start="5324.65" dur="3.569">that&amp;#39;ll work they don&amp;#39;t have to do it</text><text start="5326.06" dur="3.21">and I really think people should stick</text><text start="5328.219" dur="2.701">to the defaults</text><text start="5329.27" dur="4.079">rather than trying to write them</text><text start="5330.92" dur="4.199">themselves there if you if you want the</text><text start="5333.349" dur="4.951">default semantics you should not write</text><text start="5335.119" dur="5.19">your own constructors move or copy if</text><text start="5338.3" dur="5.7">you want special semantics yes you</text><text start="5340.309" dur="4.651">wanted and you do it and there is ways</text><text start="5344" dur="6.69">of saying if you</text><text start="5344.96" dur="7.77">to say copy constructor you want the</text><text start="5350.69" dur="3.93">default but the move constructor you</text><text start="5352.73" dur="4.95">want to write yourself you can simply</text><text start="5354.62" dur="4.77">say the the carbon constructor equals d4</text><text start="5357.68" dur="3.96">you get the default and then write your</text><text start="5359.39" dur="5.01">own move constructor so there&amp;#39;s a set of</text><text start="5361.64" dur="4.98">defaults and a way of getting them by</text><text start="5364.4" dur="5.52">default and a way of saying you want the</text><text start="5366.62" dur="7.14">default that that addresses that problem</text><text start="5369.92" dur="6.93">and I think it&amp;#39;ll at least be</text><text start="5373.76" dur="8.99">significantly improved if not totally</text><text start="5376.85" dur="5.9">eliminated and thank you thank you</text><text start="5387.33" dur="2.06">you</text></transcript>