├── .gitignore ├── CppCon2014 └── CppCon 2014 Herb Sutter - Essentials of Modern C++ Style.ass ├── CppCon2015 ├── CppCon 2015 Bjarne Stroustrup - Writing Good C++14.ass └── CppCon 2015 Bjarne Stroustrup - Writing Good C++14.chs.ass ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | install_manifest.txt 6 | -------------------------------------------------------------------------------- /CppCon2014/CppCon 2014 Herb Sutter - Essentials of Modern C++ Style.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.1.3 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: TV.601 9 | Last Style Storage: Default 10 | Aegisub Scroll Position: 184 11 | Aegisub Active Line: 206 12 | Aegisub Video Zoom Percent: 1.000000 13 | Audio URI: ../../../Videos/CppCon2014/CPPBasicsSutter_high.mp4 14 | PlayResX: 1280 15 | PlayResY: 720 16 | Video File: ../../../Videos/CppCon2014/CPPBasicsSutter_high.mp4 17 | Aegisub Video Aspect Ratio: c1.777778 18 | Aegisub Video Position: 30079 19 | 20 | [V4+ Styles] 21 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 22 | Style: Default,Arial,55,&H00FF00FF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,3,3,2,10,10,20,1 23 | Style: 居中标题,文泉驿正黑,150,&H0097108D,&H000000FF,&H00000000,&H00F7A350,0,0,0,0,100,100,0,0,1,3,6,8,10,10,10,1 24 | 25 | [Events] 26 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 27 | Dialogue: 0,0:00:00.00,0:00:05.00,居中标题,,0,0,0,,avplayer.org\n社区出品 28 | Dialogue: 0,0:00:00.50,0:00:04.57,Default,,0,0,0,,Hey, Have you enjouy the week so far? 29 | Dialogue: 0,0:00:06.88,0:00:12.70,Default,,0,0,0,,I am not sure if both my ears are working right, this half of room, have you enjoy CppCon so far? 30 | Dialogue: 0,0:00:17.20,0:00:18.55,Default,,0,0,0,,you guys, what do you think? 31 | Dialogue: 0,0:00:21.58,0:00:24.05,Default,,0,0,0,,I don't know they might have a next reduciable. 32 | Dialogue: 0,0:00:24.08,0:00:25.60,Default,,0,0,0,,lets hear all of you one more time~~~ 33 | Dialogue: 0,0:00:29.06,0:00:29.75,Default,,0,0,0,,Thank you 34 | Dialogue: 0,0:00:29.75,0:00:35.38,Default,,0,0,0,,This has been such an awsome week for c++ and also really feasible atmosphere here. 35 | Dialogue: 0,0:00:35.38,0:00:40.48,Default,,0,0,0,,we want to thank you all very much for coming. and its been a blast. 36 | Dialogue: 0,0:00:40.88,0:00:43.20,Default,,0,0,0,,we are now at our final plenary session 37 | Dialogue: 0,0:00:43.20,0:00:49.49,Default,,0,0,0,,so I like to intruduce a speaker whose name happens to also be Herb. 38 | Dialogue: 0,0:01:00.70,0:01:02.36,Default,,0,0,0,,Hi, my name is Herb. 39 | Dialogue: 0,0:01:06.03,0:01:08.67,Default,,0,0,0,,You supose to say hi Herb. 40 | Dialogue: 0,0:01:10.44,0:01:16.45,Default,,0,0,0,,It is been one year three months and 18 days since my last template metaprogram 41 | Dialogue: 0,0:01:18.33,0:01:21.74,Default,,0,0,0,,Today I want to talk about the importance of resisting complexity. 42 | Dialogue: 0,0:01:21.74,0:01:23.68,Default,,0,0,0,,I never thought it would happend to me. 43 | Dialogue: 0,0:01:24.05,0:01:28.88,Default,,0,0,0,,I was intruduced to complexity by a friend, at least I thought he was a friend 44 | Dialogue: 0,0:01:28.95,0:01:36.88,Default,,0,0,0,,He showed me a cool programming trick on his computer at home in private, and it really worked on his compiler. 45 | Dialogue: 0,0:01:38.54,0:01:43.36,Default,,0,0,0,,So I started using a little complexity but just a little, not only at home 46 | Dialogue: 0,0:01:44.23,0:01:49.46,Default,,0,0,0,,but after a while as I got used to using complexity, something strange happend to me. 47 | Dialogue: 0,0:01:49.50,0:01:53.02,Default,,0,0,0,,the thrill sort of faded didn't seem as complex anymore 48 | Dialogue: 0,0:01:53.23,0:01:57.52,Default,,0,0,0,,It seems simple - even no other people around me told me that was still too complex. 49 | Dialogue: 0,0:01:57.78,0:02:02.05,Default,,0,0,0,,So I started hanging out with people after work for social complexity 50 | Dialogue: 0,0:02:02.19,0:02:03.42,Default,,0,0,0,,on bar napkins. 51 | Dialogue: 0,0:02:03.70,0:02:09.03,Default,,0,0,0,,but then I started eating at work time, we started bringing it into office, checking it in. 52 | Dialogue: 0,0:02:11.49,0:02:16.22,Default,,0,0,0,,some of you were at the template meta programming hacker fun last night. here's the picture 53 | Dialogue: 0,0:02:19.21,0:02:22.53,Default,,0,0,0,,seriously the reason that I want to talk about complexity is 54 | Dialogue: 0,0:02:22.52,0:02:28.74,Default,,0,0,0,,people under the influence of the complexity often think that they are thinking more loosely 55 | Dialogue: 0,0:02:28.92,0:02:31.64,Default,,0,0,0,,and really that's not true. 56 | Dialogue: 0,0:02:31.64,0:02:38.68,Default,,0,0,0,,but we get so used to complexity that we should remember that it's fine in moderation 57 | Dialogue: 0,0:02:40.41,0:02:47.19,Default,,0,0,0,,once you know a lot about anything including c++ it's really hard to forget that you're an expert 58 | Dialogue: 0,0:02:47.50,0:02:49.14,Default,,0,0,0,,so there's roughly give a take 59 | Dialogue: 0,0:02:49.14,0:02:50.44,Default,,0,0,0,,it's hard to get a number 60 | Dialogue: 0,0:02:50.60,0:02:53.40,Default,,0,0,0,,people who include use c++ on their daily jobs 61 | Dialogue: 0,0:02:53.40,0:02:56.17,Default,,0,0,0,,is roughly around 3 millon for sometime. 62 | Dialogue: 0,0:02:56.46,0:03:01.67,Default,,0,0,0,,and it's gradually little pretty flat in 2000s it's increasing a bit now. 63 | Dialogue: 0,0:03:02.02,0:03:04.74,Default,,0,0,0,,but compare that to many of the experts that you've heard of 64 | Dialogue: 0,0:03:05.06,0:03:07.92,Default,,0,0,0,,how many of you uses GNU GCC ? 65 | Dialogue: 0,0:03:09.44,0:03:10.45,Default,,0,0,0,,lots! great! 66 | Dialogue: 0,0:03:10.77,0:03:14.59,Default,,0,0,0,,so you're using the standrad implementation libstdc++ 67 | Dialogue: 0,0:03:14.47,0:03:16.13,Default,,0,0,0,,which has been around for quiet a while. 68 | Dialogue: 0,0:03:16.26,0:03:19.52,Default,,0,0,0,,and just over the last almost 20 years, I ask some of the maintainers: 69 | Dialogue: 0,0:03:19.65,0:03:33.23,Default,,0,0,0,,"you know, how many people have contributed to the well-know open-source project everybody knows that everybody contributes to opensource project? how many people really have contributed to it? say more than just a few lines, like contributed something significant to it?" 70 | Dialogue: 0,0:03:34.02,0:03:35.48,Default,,0,0,0,,answer seam to be about 30 :( 71 | Dialogue: 0,0:03:36.55,0:03:38.93,Default,,0,0,0,,gnu world in the last roughly 20 years 72 | Dialogue: 0,0:03:40.02,0:03:41.38,Default,,0,0,0,,How many of you use clang? 73 | Dialogue: 0,0:03:42.62,0:03:45.65,Default,,0,0,0,, if you're using XCode, that's also clang, so put up your hand 74 | Dialogue: 0,0:03:46.42,0:03:47.09,Default,,0,0,0,,ok 75 | Dialogue: 0,0:03:48.51,0:03:54.21,Default,,0,0,0,,you know how many people are developers of the standard c++ library that shipes with clang - libc++ 76 | Dialogue: 0,0:03:54.82,0:03:56.70,Default,,0,0,0,,the answer till 20 month ago is two. 77 | Dialogue: 0,0:03:58.09,0:03:59.82,Default,,0,0,0,,they are both here at this week 78 | Dialogue: 0,0:03:59.82,0:04:02.58,Default,,0,0,0,,one is now getting on a plane, the others still here in the audience 79 | Dialogue: 0,0:04:02.58,0:04:05.33,Default,,0,0,0,,the answer is now about 5-7 that contributed more than just few lines 80 | Dialogue: 0,0:04:05.33,0:04:08.56,Default,,0,0,0,,you contribute something more significant 81 | Dialogue: 0,0:04:08.75,0:04:11.32,Default,,0,0,0,,I was not able to get the number of boost developers 82 | Dialogue: 0,0:04:11.85,0:04:14.60,Default,,0,0,0,,that's been going on for almost 20 years now 83 | Dialogue: 0,0:04:14.98,0:04:19.52,Default,,0,0,0,,I figure some where in the order of 300 people, maybe that's high, I don't know. 84 | Dialogue: 0,0:04:19.52,0:04:20.74,Default,,0,0,0,,but must be generous 85 | Dialogue: 0,0:04:20.74,0:04:23.66,Default,,0,0,0,,and ISO WG21 meeting attenders? 86 | Dialogue: 0,0:04:24.14,0:04:30.68,Default,,0,0,0,,who like ever attended more than one c++ meeting, I didn't actually go through all minutes and count, but I'd be surpurized there's more than 300 people. 87 | Dialogue: 0,0:04:31.50,0:04:33.02,Default,,0,0,0,,so here is a diagram 88 | Dialogue: 0,0:04:33.02,0:04:35.16,Default,,0,0,0,,all the c++ developers in the world 89 | Dialogue: 0,0:04:35.16,0:04:43.80,Default,,0,0,0,,and the smaller cycle is all of the libc++ developers, libstdc++ developers, boost developers, and anyone has attended more than one iso c++ meeting 90 | Dialogue: 0,0:04:44.22,0:04:49.71,Default,,0,0,0,,and if I had put a border allying around the cycle you couldn't see the smaller cycle 91 | Dialogue: 0,0:04:50.37,0:04:54.43,Default,,0,0,0,,actually I had to turn off the line around the cycle otherwise you couldn't see the smaller one 92 | Dialogue: 0,0:04:54.57,0:04:57.44,Default,,0,0,0,,btw, can you see it? 93 | Dialogue: 0,0:04:58.22,0:05:02.82,Default,,0,0,0,,we need to give good guidence to the big cycles. 94 | Dialogue: 0,0:05:03.48,0:05:11.01,Default,,0,0,0,,while still teaching the advanced tools for people who need advanced code including very advanced code 95 | Dialogue: 0,0:05:11.62,0:05:14.28,Default,,0,0,0,,but, a, not everyone need to know all of it 96 | Dialogue: 0,0:05:14.52,0:05:18.04,Default,,0,0,0,,and not everyone who knows it needs to use it all the time 97 | Dialogue: 0,0:05:18.46,0:05:20.81,Default,,0,0,0,,so that's the theme of this talk 98 | Dialogue: 0,0:05:20.88,0:05:25.49,Default,,0,0,0,,in fact, if you go back to Bjarne Stroustrup's wonderful keynote on Tuesday 99 | Dialogue: 0,0:05:25.98,0:05:27.34,Default,,0,0,0,,interesting factory 100 | Dialogue: 0,0:05:27.52,0:05:33.15,Default,,0,0,0,,if you go through the slides, know how many "&&" presents rvalue references are in his entire talk 101 | Dialogue: 0,0:05:34.05,0:05:35.14,Default,,0,0,0,,nice round number 102 | Dialogue: 0,0:05:35.50,0:05:39.88,Default,,0,0,0,,so the value of simple usable defaults is really priceless 103 | Dialogue: 0,0:05:40.95,0:05:41.68,Default,,0,0,0,,btw 104 | Dialogue: 0,0:05:41.96,0:05:43.92,Default,,0,0,0,,I mention this some handle on monday night 105 | Dialogue: 0,0:05:43.92,0:05:51.82,Default,,0,0,0,,the most important c++ book you should go out and buy it on bootstore now is {\i1}a tour of c++{\i0} by Bjarne Stroustrup 106 | Dialogue: 0,0:05:51.92,0:05:57.64,Default,,0,0,0,,we have lot... so much thunder so... 107 | Dialogue: 0,0:05:52.90,0:05:57.17,Default,,0,0,0,,I know it was sold out! I know! 108 | Dialogue: 0,0:05:58.93,0:06:03.60,Default,,0,0,0,,but the good news is that you can still order it on the book store and they will order and ship it to you, as they have free shipping 109 | Dialogue: 0,0:06:03.60,0:06:06.54,Default,,0,0,0,,so go to the book store anyway or amazon or anywhere 110 | Dialogue: 0,0:06:06.54,0:06:07.79,Default,,0,0,0,,in paticular 111 | Dialogue: 0,0:06:08.24,0:06:16.01,Default,,0,0,0,,this book is important because it encapsulated in one place what every c++ programers should be expected to know 112 | Dialogue: 0,0:06:16.97,0:06:18.49,Default,,0,0,0,,that's really important 113 | Dialogue: 0,0:06:19.24,0:06:25.39,Default,,0,0,0,,somebody is coming new to c++ or they are learnning modern c++ after having knew c++98 114 | Dialogue: 0,0:06:26.17,0:06:29.69,Default,,0,0,0,,they often ask, ok where? what's all the stuff we need to know 115 | Dialogue: 0,0:06:29.69,0:06:36.61,Default,,0,0,0,,well, look over here on stackoverflow and Sculter got book bot and Stroustrup's stuff is longer, there's chapters there you ought to know 116 | Dialogue: 0,0:06:36.64,0:06:44.02,Default,,0,0,0,,here is a 180 pages that some of you will have your time read on your plane home this weekend from cover to cover 117 | Dialogue: 0,0:06:44.19,0:06:47.93,Default,,0,0,0,,that tells you the stuff that everyone needs to know about c++ 118 | Dialogue: 0,0:06:47.93,0:06:49.63,Default,,0,0,0,,I recomment this book 119 | Dialogue: 0,0:06:49.87,0:06:50.98,Default,,0,0,0,,LET PEOPLE KNOW! 120 | Dialogue: 0,0:06:51.03,0:06:52.15,Default,,0,0,0,,help get the world out 121 | Dialogue: 0,0:06:52.22,0:06:55.94,Default,,0,0,0,,it's really important and I'm very glad that Bjarne has made that avaliable 122 | Dialogue: 0,0:06:56.52,0:06:58.42,Default,,0,0,0,,in this talk I want to focus on 123 | Dialogue: 0,0:06:58.42,0:07:00.82,Default,,0,0,0,,defaults, basic styles and idioms 124 | Dialogue: 0,0:07:00.84,0:07:01.26,Default,,0,0,0,,now 125 | Dialogue: 0,0:07:02.47,0:07:04.83,Default,,0,0,0,,some experts have push back me on this 126 | Dialogue: 0,0:07:05.04,0:07:09.86,Default,,0,0,0,,when I say the word "default" some experts treated it as bad word 127 | Dialogue: 0,0:07:09.86,0:07:12.41,Default,,0,0,0,,they say you are damping down the language, no, not. 128 | Dialogue: 0,0:07:13.39,0:07:15.36,Default,,0,0,0,,a default does not damping down. 129 | Dialogue: 0,0:07:15.65,0:07:17.92,Default,,0,0,0,,especially a default does not mean 130 | Dialogue: 0,0:07:17.92,0:07:20.16,Default,,0,0,0,,"Oh~~ just do this blindly and donot think about it" 131 | Dialogue: 0,0:07:20.16,0:07:21.41,Default,,0,0,0,,That's not what it is about 132 | Dialogue: 0,0:07:21.84,0:07:24.98,Default,,0,0,0,,you should know your other options too. 133 | Dialogue: 0,0:07:25.00,0:07:27.09,Default,,0,0,0,,but, a default is about 134 | Dialogue: 0,0:07:27.09,0:07:31.85,Default,,0,0,0,,unless you have a good reasons to do something else (which does involve thinking) don't over thinking 135 | Dialogue: 0,0:07:32.05,0:07:35.76,Default,,0,0,0,,Just do this unless you have reasons to do something more complex. 136 | Dialogue: 0,0:07:35.88,0:07:49.71,Default,,0,0,0,,In paticular, this goes right in line with general good advice including these three idoms at the bottom of the screen which was the titles of 3 of the first 8/9 idoms in c++ coding standart not coincidentally. 137 | Dialogue: 0,0:07:49.82,0:07:53.84,Default,,0,0,0,,write for clarity and correctness first\Navoid premature optimization 138 | Dialogue: 0,0:07:53.84,0:07:57.69,Default,,0,0,0,,in patirular, prefer clear code over optimal code 139 | Dialogue: 0,0:07:57.76,0:08:00.69,Default,,0,0,0,,and that's almost a swear in c++ audience. 140 | Dialogue: 0,0:08:01.07,0:08:05.34,Default,,0,0,0,,like, "we should be optimal by default". no you should not. you should have good performance by default. 141 | Dialogue: 0,0:08:05.92,0:08:11.21,Default,,0,0,0,,and if anyone tries to tell you that C++ has been about writting optimal code by default 142 | Dialogue: 0,0:08:11.21,0:08:13.63,Default,,0,0,0,,correct them gentally, because it has not. 143 | Dialogue: 0,0:08:13.73,0:08:23.32,Default,,0,0,0,,c++ has always been about writting efficient code {\i1} not perfectly efficient or optimally efficient but good efficient code {\i0} by default. 144 | Dialogue: 0,0:08:23.38,0:08:26.39,Default,,0,0,0,,and always been able to open the hood to take control 145 | Dialogue: 0,0:08:26.58,0:08:32.98,Default,,0,0,0,,over memory layout, over the actual ... {\i1}even down to the instructions (level) that get down {\i0} {\b1}when you need to.{\b0} 146 | Dialogue: 0,0:08:33.27,0:08:34.93,Default,,0,0,0,,YOU DON'T ALWAYS NEED TO OPEN THE HOOD! 147 | Dialogue: 0,0:08:34.93,0:08:38.45,Default,,0,0,0,,so, this talk is not about - don't think. 148 | Dialogue: 0,0:08:38.66,0:08:41.01,Default,,0,0,0,,it's about, let's not over think 149 | Dialogue: 0,0:08:41.06,0:08:43.79,Default,,0,0,0,,because it isn't a true we revel in complexity. 150 | Dialogue: 0,0:08:43.92,0:08:54.91,Default,,0,0,0,,how many of you -- we're not gona put a camera on you, so non of your friends can tell you -- how many of you would say, ya, revel in complexity has discreeted me at least some point in my coding career. 151 | Dialogue: 0,0:08:55.39,0:08:58.59,Default,,0,0,0,,I see all the speakers have their hands up, that's good. 152 | Dialogue: 0,0:08:59.08,0:09:07.11,Default,,0,0,0,,so, this is good, we're acknowledging our problem then we can start to deal with it. we overcome denial, step one. 153 | Dialogue: 0,0:09:08.40,0:09:10.88,Default,,0,0,0,,let's talk about range-for based loops. 154 | Dialogue: 0,0:09:10.88,0:09:14.40,Default,,0,0,0,,you know, we can overthink range-for based loops. 155 | Dialogue: 0,0:09:14.79,0:09:21.44,Default,,0,0,0,,I think that everything I want to say about range based for loops pretty much fits on one simple slide, and here it is. 156 | Dialogue: 0,0:09:21.76,0:09:25.72,Default,,0,0,0,,WHY DO THIS WHEN YOU CAN DO THIS? 157 | Dialogue: 0,0:09:26.91,0:09:28.68,Default,,0,0,0,,Any questions? 158 | Dialogue: 0,0:09:29.23,0:09:34.77,Default,,0,0,0,, Now, some of you maybe saying, shouldn't I be writting "auto &&" there ? Maybe, but ... 159 | Dialogue: 0,0:09:35.22,0:09:39.06,Default,,0,0,0,,wait-for, we'll talk more about "auto&&" at the end. 160 | Dialogue: 0,0:09:39.17,0:09:56.69,Default,,0,0,0,,but, this is perfectly good, in fact, no matter whether "C" is a const or not, these code does the right thing because "auto&" also go through the iterators, if you get const iterator back that dereferenced to const T, it'll be deduced to the right thing so it'll be read-only for read-only collection. This is simple code! 161 | Dialogue: 0,0:09:56.77,0:10:02.58,Default,,0,0,0,,if you are traversing every element of a collection, prefer to write range-for. 162 | Dialogue: 0,0:10:02.64,0:10:12.98,Default,,0,0,0,,if you need early break, range-for does not support that yet. but the ranges proposal comming form the november meeting that I think will address that, even enable that. 163 | Dialogue: 0,0:10:13.03,0:10:23.68,Default,,0,0,0,,Certenly if you're writting a for loop that reaches every element of the collection, just write range-for with auto& unless you want to modify in place. 164 | Dialogue: 0,0:10:24.00,0:10:32.06,Default,,0,0,0,,soon, thanks to Stephan Lavavej, Stephan are you here? Wave if you're here. "喵~" 165 | Dialogue: 0,0:10:32.66,0:10:38.53,Default,,0,0,0,,if I see one more solid coding examples checked in with kity, I will scream. 166 | Dialogue: 0,0:10:40.48,0:10:45.35,Default,,0,0,0,,for ( e : c ) is going to be a short hand, that the standard commitee is seriously considering 167 | Dialogue: 0,0:10:45.40,0:10:54.13,Default,,0,0,0,,and there are for some compilers once the commitee, will beless it hopefuly at the next meeting for c++17. are already start implementing it so you don't have to wait 3-years to start using this. 168 | Dialogue: 0,0:10:54.14,0:11:01.56,Default,,0,0,0,,that basically sayes, you know what, we are gonna declare variable "e" for you and it will be of type deduced what ever, so the constness will flow though. 169 | Dialogue: 0,0:11:01.57,0:11:08.25,Default,,0,0,0,,and the nice thing about it, the first thing you might thinking is, how can c++ doing that? isn't that a breaking change? 170 | Dialogue: 0,0:11:08.81,0:11:15.64,Default,,0,0,0,,haven't you suspect that the last line maybe a breaking change can change the meaning of existng c++14 code today? 171 | Dialogue: 0,0:11:17.37,0:11:18.96,Default,,0,0,0,,Oh, you're scared. 172 | Dialogue: 0,0:11:19.81,0:11:27.67,Default,,0,0,0,,I thought it was. and then Stephan kept reminding me, "no, no. you can't actually write that today, you can't use existing variable you have to declare new one" 173 | Dialogue: 0,0:11:28.21,0:11:29.33,Default,,0,0,0,,so we distract the type. 174 | Dialogue: 0,0:11:29.37,0:11:38.25,Default,,0,0,0,,the default, the sensible default, will be essentially the same as before, auto && or auto&, which will do the right thing. 175 | Dialogue: 0,0:11:38.40,0:11:50.35,Default,,0,0,0,,this desn't mean that you cann't lift the hood and write yourself if you want a certain type, or even write the naked iterator-based for loop if you want to do something more, like break, part-way thought or skip elements, that's all fine! 176 | Dialogue: 0,0:11:50.35,0:11:52.35,Default,,0,0,0,,But defaults matter! 177 | Dialogue: 0,0:11:52.64,0:12:02.88,Default,,0,0,0,,you are offen influences of people in your companies, of people who ask questions on stackoverflow, who participate in community. 178 | Dialogue: 0,0:12:03.30,0:12:08.47,Default,,0,0,0,,so, please, you teach starting from the bottom of the screen up, not the other way around. 179 | Dialogue: 0,0:12:09.61,0:12:12.02,Default,,0,0,0,,now let's talk about smart pointers! 180 | Dialogue: 0,0:12:12.74,0:12:14.55,Default,,0,0,0,,use smart pointers effectively! 181 | Dialogue: 0,0:12:14.74,0:12:21.54,Default,,0,0,0,,But I still want you to use lots and lots and lots of raw pointers and references, they're great! 182 | Dialogue: 0,0:12:22.85,0:12:24.66,Default,,0,0,0,,yeah, stern silence. 183 | Dialogue: 0,0:12:25.28,0:12:37.01,Default,,0,0,0,,so, we hate pointers and references as raw pointers ... why do we recommend those? Those should be your default parameter types and return types still! let's talk about that. 184 | Dialogue: 0,0:12:37.76,0:12:49.73,Default,,0,0,0,,now, clearly, the code on the left hand side of the screen, was perfectly good code in books some time ago. but we tell people DON'T WRITE THAT ANY MORE! 185 | Dialogue: 0,0:12:49.73,0:12:54.18,Default,,0,0,0,,in fact basically all the red stuff shouldn't pass checking anymore, in new code. 186 | Dialogue: 0,0:12:54.77,0:13:00.22,Default,,0,0,0,,so, don't use owning pointers, don't use explicit new, don't use delete. 187 | Dialogue: 0,0:13:00.97,0:13:07.74,Default,,0,0,0,,except, if you have real performance need and encapsulated down deep inside some low-level data structure maybe. 188 | Dialogue: 0,0:13:07.76,0:13:15.71,Default,,0,0,0,,but FYI, I beleve even the entire STL can be implemented with no lost of performance using unique_ptr and no using new and delete. 189 | Dialogue: 0,0:13:16.18,0:13:17.72,Default,,0,0,0,,we're about to try that! 190 | Dialogue: 0,0:13:17.88,0:13:18.80,Default,,0,0,0,,and so 191 | Dialogue: 0,0:13:19.65,0:13:24.67,Default,,0,0,0,,that "exception" might be even smaller than that you might think. 192 | Dialogue: 0,0:13:25.46,0:13:30.18,Default,,0,0,0,,'cause unique_ptr is roughly free... is very thin overhead 193 | Dialogue: 0,0:13:30.45,0:13:32.66,Default,,0,0,0,,often non at all over raw pointer. 194 | Dialogue: 0,0:13:33.08,0:13:38.96,Default,,0,0,0,,modern c++ says: use unique_ptr, use a share_ptr, use make_unique 195 | Dialogue: 0,0:13:39.26,0:13:43.96,Default,,0,0,0,,so, if you want to write new to allocate new object, use make_unique by default 196 | Dialogue: 0,0:13:44.06,0:13:50.86,Default,,0,0,0,,if you know -- again, it's a default -- if you know this object is going to be shared, definitally use make_shared by default 197 | Dialogue: 0,0:13:51.32,0:14:00.29,Default,,0,0,0,,if you don't know you are creating an object, hanging it out, you don't know it's gonna be shared stuff, use make_unique. cause you can always move that into shared_ptr 198 | Dialogue: 0,0:14:00.61,0:14:03.15,Default,,0,0,0,,but if you know it's going to be shared, use make_shared 199 | Dialogue: 0,0:14:03.92,0:14:06.28,Default,,0,0,0,,for delete, don't write anything 200 | Dialogue: 0,0:14:06.00,0:14:07.85,Default,,0,0,0,,this is advice giving to people 201 | Dialogue: 0,0:14:08.13,0:14:12.50,Default,,0,0,0,,how many of you follow that advice already in your codebase today? at least to your new code ? 202 | Dialogue: 0,0:14:13.36,0:14:15.62,Default,,0,0,0,,looks like about half~~~ ok ~~~ 203 | Dialogue: 0,0:14:16.13,0:14:24.65,Default,,0,0,0,,how many of you try to follow this advice and found ... still found some dangling pointers problems with reference counted smart pointers ? 204 | Dialogue: 0,0:14:24.66,0:14:26.42,Default,,0,0,0,,a few ! I have a slide for you! 205 | Dialogue: 0,0:14:26.42,0:14:28.85,Default,,0,0,0,,I know the problem is, there is a cure.\ 206 | Dialogue: 0,0:14:29.17,0:14:30.79,Default,,0,0,0,,wait a few slides. 207 | Dialogue: 0,0:14:31.52,0:14:39.33,Default,,0,0,0,,a very important qulifier on this: this slide says, don't use {\b1}ownning{\b0} raw pointers and references. 208 | Dialogue: 0,0:14:42.05,0:14:43.14,Default,,0,0,0,,what does that mean? 209 | Dialogue: 0,0:14:43.49,0:14:47.76,Default,,0,0,0,,really a pointer you should be calling delete on it at some point 210 | Dialogue: 0,0:14:48.01,0:14:56.10,Default,,0,0,0,,Non-Owning pointers/references are awesome! keep writting them ! especially for parameters and return values 211 | Dialogue: 0,0:14:56.26,0:15:12.77,Default,,0,0,0,,when you talk about structure lifetimes, where one function calls another funcion and that callee executes entirely within the scope of the caller because then you return/resume the caller, anything a calling function is keeping alive stay alive for as long as the caller function 212 | Dialogue: 0,0:15:12.77,0:15:15.01,Default,,0,0,0,,now there is a reentrance case we'll talk about that. 213 | Dialogue: 0,0:15:15.06,0:15:20.25,Default,,0,0,0,,but gentally this is nice as rushed all the way down where the lifetime nasted perfectly 214 | Dialogue: 0,0:15:20.34,0:15:23.81,Default,,0,0,0,,you don't need owner ship transfer down the call stack. \ 215 | Dialogue: 0,0:15:24.13,0:15:26.73,Default,,0,0,0,,unless you're gonna take something out of the call stack 216 | Dialogue: 0,0:15:26.73,0:15:28.73,Default,,0,0,0,,you don't need to care about the owner ship 217 | Dialogue: 0,0:15:28.88,0:15:39.50,Default,,0,0,0,,so in c++98 class we could say, hey if you need to look at the widget and say it's aquired parameter (ignoring const, we'll come to that later), pass by reference! 218 | Dialogue: 0,0:15:39.70,0:15:41.75,Default,,0,0,0,,or, if it's optional, pass by pointer. 219 | Dialogue: 0,0:15:42.11,0:15:44.55,Default,,0,0,0,,are you ready for the modern c++ advice ? 220 | Dialogue: 0,0:15:45.89,0:15:47.62,Default,,0,0,0,,IT'S THE SAME ! 221 | Dialogue: 0,0:15:45.87,0:15:47.62,Default,,0,0,0,,{\pos(275,483)}IT'S THE SAME ! 222 | Dialogue: 0,0:15:48.25,0:15:49.81,Default,,0,0,0,,it's the same advice 223 | Dialogue: 0,0:15:49.86,0:15:59.97,Default,,0,0,0,,now if you have a unique_ptr, a shared_ptr, then you want to dereference it, or call ".get()" to pass & or * 224 | Dialogue: 0,0:16:00.28,0:16:03.62,Default,,0,0,0,,but raw & and raw* for the win! 225 | Dialogue: 0,0:16:03.61,0:16:06.66,Default,,0,0,0,,they still are the prefered parameter type. 226 | Dialogue: 0,0:16:06.65,0:16:11.68,Default,,0,0,0,,think about this way, if you are not convinced about that, if you feel uncomfortable, think about this way: 227 | Dialogue: 0,0:16:11.70,0:16:19.31,Default,,0,0,0,,unless you're talking about ownership transfering , in which case is perfectly valid to pass smart pointers, and I'll show that in just a second 228 | Dialogue: 0,0:16:19.74,0:16:24.56,Default,,0,0,0,,unless the caller function is going to participate the ownership somehow. 229 | Dialogue: 0,0:16:25.49,0:16:27.21,Default,,0,0,0,,if you just once look at the widget, why 230 | Dialogue: 0,0:16:27.21,0:16:27.20,Default,,0,0,0,,why on earth as the callee care if they 231 | Dialogue: 0,0:16:27.21,0:16:38.45,Default,,0,0,0,,why on earth does the callee care if you managing that lifetime by unique_ptr by shared_ptr by ... whether it's global whether it's global, he should be ignorant to that and this is how to write that. 232 | Dialogue: 0,0:16:38.96,0:16:43.62,Default,,0,0,0,,very simple and the classic advice is still true. 233 | Dialogue: 0,0:16:43.62,0:16:45.62,Default,,0,0,0,, 234 | -------------------------------------------------------------------------------- /CppCon2015/CppCon 2015 Bjarne Stroustrup - Writing Good C++14.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.1.3 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: TV.601 9 | Last Style Storage: Default 10 | Aegisub Scroll Position: 62 11 | Aegisub Active Line: 65 12 | Aegisub Video Zoom Percent: 1.000000 13 | PlayResX: 1920 14 | PlayResY: 1080 15 | Audio URI: ../../../Videos/CppCon2015/BjarneStroustrupWritingGoodC++14.mp4 16 | Video File: ../../../Videos/CppCon2015/BjarneStroustrupWritingGoodC++14.mp4 17 | Aegisub Video Aspect Ratio: c1.777778 18 | Aegisub Video Position: 11153 19 | 20 | [V4+ Styles] 21 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 22 | Style: Default,Courier New,55,&H00FF00FF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,3,3,2,10,10,20,1 23 | Style: 居中标题,文泉驿正黑,150,&H0097108D,&H000000FF,&H00000000,&H00F7A350,0,0,0,0,100,100,0,0,1,3,6,8,10,10,10,1 24 | Style: 观众提问,Arial,55,&H00FFFF00,&H000000FF,&H0000FFFF,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 25 | Style: 演讲回答,Arial,55,&H000000FF,&H00000000,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1 26 | 27 | [Events] 28 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 29 | Dialogue: 0,0:00:00.00,0:00:07.10,居中标题,,0,0,0,,avplayer.org\n社区出品 30 | Comment: 0,0:00:05.00,0:00:07.00,Default,,0,0,0,,视频文件请到 http://pan.baidu.com/s/1pJquXBl 下载,提取码 2in6 31 | Dialogue: 0,0:00:00.00,0:00:02.04,Default,,0,0,0,,Yes, Now we can go 32 | Dialogue: 0,0:00:05.41,0:00:10.45,Default,,0,0,0,,Welcome~\n\nIt's very nice and a little bit scary to see you all again 33 | Dialogue: 0,0:00:10.75,0:00:19.76,Default,,0,0,0,,And especially happy to see a lot of old friends and also a lot of people that are new here 34 | Dialogue: 0,0:00:20.19,0:00:27.90,Default,,0,0,0,,Anyway, I'm going to talk about how to write code 35 | Dialogue: 0,0:00:28.23,0:00:39.16,Default,,0,0,0,,and in particular \n-- a question has been boggle for a while, and I know it has boggle for a lot of new people -- is \n "What is good modern C++" ? 36 | Dialogue: 0,0:00:39.45,0:00:46.18,Default,,0,0,0,,We've done lots to the the languages over the last five years 37 | Dialogue: 0,0:00:46.37,0:00:52.47,Default,,0,0,0,,And lot of people have ideas about what it is to write good c++ 38 | Dialogue: 0,0:00:52.74,0:00:55.74,Default,,0,0,0,,and , lots of people ask about it. 39 | Dialogue: 0,0:00:55.74,0:01:04.02,Default,,0,0,0,,so, this spring, I started a project trying to make some guidelines to how to write this 40 | Dialogue: 0,0:01:04.05,0:01:09.46,Default,,0,0,0,,turned out that other people were on the same kind of idea. 41 | Dialogue: 0,0:01:09.61,0:01:13.79,Default,,0,0,0,,so some of us try to provide some useful answer. 42 | Dialogue: 0,0:01:14.04,0:01:22.28,Default,,0,0,0,,and one of the things that is important here, is that we would like to help many people 43 | Dialogue: 0,0:01:22.61,0:01:27.32,Default,,0,0,0,,thers is more that 4million c++ programers. 44 | Dialogue: 0,0:01:27.57,0:01:34.16,Default,,0,0,0,,and if we come up with a solution that can (only) be handled by 200 language experts, we failed. 45 | Dialogue: 0,0:01:34.47,0:01:42.20,Default,,0,0,0,,so , this is an attempt to be able to help a lot of people. 46 | Dialogue: 0,0:01:42.57,0:01:46.56,Default,,0,0,0,,and a lot of we've seen it, we have a great language now. 47 | Dialogue: 0,0:01:46.65,0:01:52.74,Default,,0,0,0,,it's a modern language, it can do really nice things that we couldn't do 10-20 years ago. 48 | Dialogue: 0,0:01:52.79,0:01:59.63,Default,,0,0,0,,c++11 is good. c++14 is better. both are in wide-spread production use. 49 | Dialogue: 0,0:01:59.63,0:02:02.09,Default,,0,0,0,,These are not toy languages. 50 | Dialogue: 0,0:02:02.24,0:02:08.61,Default,,0,0,0,,And from I see in the standards commitee, c++17 is even better. 51 | Dialogue: 0,0:02:08.85,0:02:22.51,Default,,0,0,0,,There is technical specifications like filesystem and concepts and such that are rolling out. Things are happening. 52 | Dialogue: 0,0:02:22.51,0:02:44.95,Default,,0,0,0,,So, I know from experience, from wide experience from industrial experience, that c++1* is easier to write, easier to maintain, runs faster and can express more that older c++ styles with less code 53 | Dialogue: 0,0:02:45.54,0:02:47.11,Default,,0,0,0,,This is a fact 54 | Dialogue: 0,0:02:47.52,0:02:51.40,Default,,0,0,0,,It's also a fact that very few people do it! 55 | Dialogue: 0,0:02:53.67,0:02:57.47,Default,,0,0,0,,Maybe you know a thousand people that write such modern code. 56 | Dialogue: 0,0:02:57.74,0:03:02.86,Default,,0,0,0,,Maybe you know 10 thousand people, but that's only very tiny small fraction of the community. 57 | Dialogue: 0,0:03:02.86,0:03:04.35,Default,,0,0,0,,We have to do something better. 58 | Dialogue: 0,0:03:04.35,0:03:10.78,Default,,0,0,0,,People are writting c++ in really archaic and foreign styles 59 | Dialogue: 0,0:03:11.23,0:03:16.20,Default,,0,0,0,,Also you going to web and you'll see every little so-and-so trying to be language expert. 60 | Dialogue: 0,0:03:16.20,0:03:20.40,Default,,0,0,0,,And discussing the sanitates of rvalue references. 61 | Dialogue: 0,0:03:20.40,0:03:27.65,Default,,0,0,0,,Which does actually matter in most code unless you are writting a high performence library for use of others. 62 | Dialogue: 0,0:03:27.65,0:03:34.68,Default,,0,0,0,,So, they are all trying to be language lawyers and getting lost in technical details. 63 | Dialogue: 0,0:03:35.11,0:03:43.55,Default,,0,0,0,,so basicly idea is "Doctor, docker, it hurts when I hit myself on the head with a hammer". The obvious answer is "so don't do it!" 64 | Dialogue: 0,0:03:43.81,0:03:45.81,Default,,0,0,0,,And that's what we are trying to do. 65 | Dialogue: 0,0:03:46.93,0:03:49.05,Default,,0,0,0,,There is a quote by me -- 66 | Dialogue: 0,0:03:52.45,0:03:56.77,Default,,0,0,0,,Within c++ language there is a smaller simplier safer language struggling to get out. 67 | Dialogue: 0,0:03:56.77,0:04:02.50,Default,,0,0,0,,I think I said that in 94, 92... It a long time ago. 68 | Dialogue: 0,0:04:02.75,0:04:05.78,Default,,0,0,0,,it is even more true today that was there. 69 | Dialogue: 0,0:04:05.93,0:04:12.63,Default,,0,0,0,,You can simplify the code\n you can maintain the efficiency\nand we don't limit what you can say. 70 | Dialogue: 0,0:04:12.63,0:04:14.24,Default,,0,0,0,,these are important things. 71 | Dialogue: 0,0:04:14.24,0:04:16.24,Default,,0,0,0,,This is C++! 72 | Dialogue: 0,0:04:16.24,0:04:21.11,Default,,0,0,0,,It's not a so specialize language for a paticular application. 73 | Dialogue: 0,0:04:21.73,0:04:25.34,Default,,0,0,0,,So, lets get it out! lets get it out now! 74 | Dialogue: 0,0:04:25.57,0:04:30.84,Default,,0,0,0,,Lot of people solution to getting things better and simpler it to invent new languages. 75 | Dialogue: 0,0:04:30.84,0:04:32.84,Default,,0,0,0,,but that not now. 76 | Dialogue: 0,0:04:32.84,0:04:42.18,Default,,0,0,0,,If you invent a really good new language now, large number of people will be able to use it, in 10 years, if you succeed. 77 | Dialogue: 0,0:04:42.36,0:04:48.97,Default,,0,0,0,,The succee rate for new languages especially general purpose programming languages is very close to zero. 78 | Dialogue: 0,0:04:48.97,0:04:50.97,Default,,0,0,0,,so, lets do it now! 79 | Dialogue: 0,0:04:51.20,0:04:53.91,Default,,0,0,0,,And I want to use those compilers. 80 | Dialogue: 0,0:04:53.91,0:04:59.92,Default,,0,0,0,,I mean, have you seen what compilers can do with your code interms of optimizing it? 81 | Dialogue: 0,0:04:59.92,0:05:08.69,Default,,0,0,0,,doesn't matter which compiler you are using for a modern compiler and sort of standard hardware. it's amazing. 82 | Dialogue: 0,0:05:08.90,0:05:15.69,Default,,0,0,0,,I mean, I am not sure what I could have done it if I had 10 years. but they did. this is going on for a long time. 83 | Dialogue: 0,0:05:15.69,0:05:23.70,Default,,0,0,0,,this doesn't just happen for a new language unless you can hijack the c++ code generation phase. which is a fair gain. 84 | Dialogue: 0,0:05:23.94,0:05:32.82,Default,,0,0,0,,So, I'm going to look for coding guidelines, provide guidence to people who wants to write modern c++ what ever that means. 85 | Dialogue: 0,0:05:33.01,0:05:40.04,Default,,0,0,0,,And, I know that just telling people what to do doesn't quite work. 86 | Dialogue: 0,0:05:40.04,0:05:43.04,Default,,0,0,0,,so you need support by tools and libraries. 87 | Dialogue: 0,0:05:43.18,0:05:50.25,Default,,0,0,0,,and again, we want generality, we want performence, we want simple code, and we want portibility. 88 | Dialogue: 0,0:05:50.25,0:05:54.77,Default,,0,0,0,,I dont want to be tight down by paticular hardware, paticular operation system. 89 | Dialogue: 0,0:05:55.05,0:05:56.52,Default,,0,0,0,,those all the gameness. 90 | Dialogue: 0,0:05:56.52,0:06:02.78,Default,,0,0,0,,I think we can do it. And I think we can do it, I know that I can't do it alone. 91 | Dialogue: 0,0:06:02.78,0:06:06.50,Default,,0,0,0,,I know that well that might be a genius somewhere. 92 | Dialogue: 0,0:06:06.50,0:06:08.99,Default,,0,0,0,,But I think I know that no individual can do it. 93 | Dialogue: 0,0:06:09.14,0:06:11.97,Default,,0,0,0,,And, no single company can 94 | Dialogue: 0,0:06:12.11,0:06:17.39,Default,,0,0,0,,It will be captured for what that company was particular interested in 95 | Dialogue: 0,0:06:17.39,0:06:19.15,Default,,0,0,0,,and you couldn't trust it all time. 96 | Dialogue: 0,0:06:19.15,0:06:27.14,Default,,0,0,0,,people explained that to me a long time ago to ensure that I took part in the (c++) standardization, so please help. 97 | Dialogue: 0,0:06:27.14,0:06:33.16,Default,,0,0,0,,I'm going to say a little bit about what help we would like and who we are and things like that. 98 | Dialogue: 0,0:06:33.16,0:06:36.05,Default,,0,0,0,,so the initial work started 99 | Dialogue: 0,0:06:36.05,0:06:39.39,Default,,0,0,0,,there was a project out of microsoft by Herb Sutter and friends 100 | Dialogue: 0,0:06:39.39,0:06:42.01,Default,,0,0,0,,I started something at Morgan Stanley 101 | Dialogue: 0,0:06:42.01,0:06:45.98,Default,,0,0,0,,CERN has joined and contributed. 102 | Dialogue: 0,0:06:45.98,0:06:47.98,Default,,0,0,0,,And things are available. 103 | Dialogue: 0,0:06:47.98,0:06:49.98,Default,,0,0,0,,its there. 104 | Dialogue: 0,0:06:49.98,0:06:55.06,Default,,0,0,0,,you can find it on github, give you the urls towards the end. 105 | Dialogue: 0,0:06:55.06,0:06:58.29,Default,,0,0,0,,there is guide lines. a lot of them. 106 | Dialogue: 0,0:06:58.49,0:07:00.64,Default,,0,0,0,,there is little support library. 107 | Dialogue: 0,0:07:00.64,0:07:11.48,Default,,0,0,0,,which is some very simple classes that mostly mapping into standard library stuff if not map straightly into portable c++. 108 | Dialogue: 0,0:07:11.48,0:07:16.44,Default,,0,0,0,,portable meaning microsoft, gcc, clang; Windows, Linux, Mac 109 | Dialogue: 0,0:07:16.53,0:07:17.64,Default,,0,0,0,,and mac yeah. 110 | Dialogue: 0,0:07:17.97,0:07:25.52,Default,,0,0,0,,there is analyze tool that will be ship by the guy at microsoft that wrote it next month 111 | Dialogue: 0,0:07:25.53,0:07:38.24,Default,,0,0,0,,and we hope to have port available later. maybe November? I don't know. I mean, you know, software project some time suffer delays. 112 | Dialogue: 0,0:07:38.42,0:07:41.09,Default,,0,0,0,,but we are planning for it. 113 | Dialogue: 0,0:07:43.13,0:07:46.58,Default,,0,0,0,,it exists. so I am saying anything in this talk that are science fictions. 114 | Dialogue: 0,0:07:46.93,0:07:50.52,Default,,0,0,0,,and its MIT licensed, so its open and free. 115 | Dialogue: 0,0:07:50.52,0:07:51.44,Default,,0,0,0,,so you can get it. 116 | Dialogue: 0,0:07:51.88,0:07:54.10,Default,,0,0,0,,and there's more talk about this. 117 | Dialogue: 0,0:07:55.02,0:08:01.92,Default,,0,0,0,,I am going to explain what we are trying to do with higher level terms with some examples 118 | Dialogue: 0,0:08:02.17,0:08:04.88,Default,,0,0,0,,Herb Sutter is going to talk more about it. 119 | Dialogue: 0,0:08:05.23,0:08:13.32,Default,,0,0,0,,Gabriel Dos Reis are going to talk how, er, ties into some of the work been done in the standard commitee for writting better code. 120 | Dialogue: 0,0:08:13.32,0:08:21.84,Default,,0,0,0,,Neil Macintosh who wrote the tool that we work with, are going to talk about static analysis and some of the classes. 121 | Dialogue: 0,0:08:21.95,0:08:23.12,Default,,0,0,0,,This is all this weak. 122 | Dialogue: 0,0:08:23.83,0:08:29.08,Default,,0,0,0,,This is a problem with coding rules, with guide lines. 123 | Dialogue: 0,0:08:29.33,0:08:30.44,Default,,0,0,0,,which is... 124 | Dialogue: 0,0:08:30.45,0:08:32.65,Default,,0,0,0,,have you even seen one you really liked? 125 | Dialogue: 0,0:08:32.92,0:08:37.18,Default,,0,0,0,,that might be necessary. but it's like medicine, doesn't taste good. 126 | Dialogue: 0,0:08:37.77,0:08:39.63,Default,,0,0,0,,we all hate coding rules. 127 | Dialogue: 0,0:08:39.79,0:08:44.83,Default,,0,0,0,,Usual caveats and thanks to the people who was made the less usual and paticular cases. 128 | Dialogue: 0,0:08:44.92,0:08:46.31,Default,,0,0,0,,but basicly we don't like it. 129 | Dialogue: 0,0:08:46.60,0:08:48.76,Default,,0,0,0,,and one of the reasons is that 130 | Dialogue: 0,0:08:48.97,0:08:53.48,Default,,0,0,0,,coding guidelines tend to be written to prevent accident 131 | Dialogue: 0,0:08:53.77,0:08:59.96,Default,,0,0,0,,so to keep novices that are not as smart as us from doing stupid things 132 | Dialogue: 0,0:09:00.01,0:09:02.87,Default,,0,0,0,,so it's long lists of don't do this and don't do that. 133 | Dialogue: 0,0:09:02.96,0:09:03.49,Default,,0,0,0,,and 134 | Dialogue: 0,0:09:03.68,0:09:07.03,Default,,0,0,0,,I don't like such lists and I know most of you don't like neither. 135 | Dialogue: 0,0:09:07.18,0:09:12.34,Default,,0,0,0,,and it's very often written at the start of an organization 136 | Dialogue: 0,0:09:12.40,0:09:18.41,Default,,0,0,0,,when people is little bit uncertain about what they want to do and they want to avoid problems. 137 | Dialogue: 0,0:09:18.41,0:09:21.54,Default,,0,0,0,,and rules tend to focus on low-level things 138 | Dialogue: 0,0:09:21.54,0:09:22.99,Default,,0,0,0,,I mean, eh 139 | Dialogue: 0,0:09:23.07,0:09:25.20,Default,,0,0,0,,do use camel case underscores 140 | Dialogue: 0,0:09:25.20,0:09:27.90,Default,,0,0,0,,how many yea spaces to use to indent 141 | Dialogue: 0,0:09:28.24,0:09:32.08,Default,,0,0,0,,these are all very interesting, could be in the essential for our organization 142 | Dialogue: 0,0:09:32.15,0:09:37.34,Default,,0,0,0,,but it has nothing much to do with how you get quality software at the higher level. 143 | Dialogue: 0,0:09:37.41,0:09:41.36,Default,,0,0,0,,how do you actually recognize a good piece of code when you came to see it? 144 | Dialogue: 0,0:09:41.76,0:09:46.23,Default,,0,0,0,,a lot of them simply sets restrictions. 145 | Dialogue: 0,0:09:47.44,0:09:55.96,Default,,0,0,0,,don't use overloading; don't use exceptions; don't use multiple-inheritance; don't use casts.... all kinds of rules like that 146 | Dialogue: 0,0:09:56.11,0:10:04.36,Default,,0,0,0,,some are good. some are bad. some are good in some paticular environment. some are not.\nAnd really, there is lot of bad advice out there. 147 | Dialogue: 0,0:10:04.61,0:10:09.77,Default,,0,0,0,,there are guidelines that tell you that you really should trying write java. 148 | Dialogue: 0,0:10:09.84,0:10:12.90,Default,,0,0,0,,when if you want to write java and you how to do which? 149 | Dialogue: 0,0:10:12.90,0:10:18.36,Default,,0,0,0,,don't try to stop c++ programmer from writting good c++. 150 | Dialogue: 0,0:10:18.36,0:10:22.91,Default,,0,0,0,,And "C with classes"? It was really cool in 1986 151 | Dialogue: 0,0:10:23.04,0:10:25.84,Default,,0,0,0,,that a long time ago. a lot of you weren't born then. 152 | Dialogue: 0,0:10:25.84,0:10:36.41,Default,,0,0,0,,and there are people think that really the world came to an end in 1978 when K&R came out. 153 | Dialogue: 0,0:10:36.41,0:10:42.09,Default,,0,0,0,,and they might accept a few things they got from c++ like function prototype and const 154 | Dialogue: 0,0:10:42.09,0:10:46.50,Default,,0,0,0,,but basically you really should write code as if we do it in C. 155 | Dialogue: 0,0:10:46.80,0:10:50.35,Default,,0,0,0,,really dumb idea in my opinion, but we'll get to that. 156 | Dialogue: 0,0:10:50.35,0:10:53.87,Default,,0,0,0,,also, coding rules get outdated. 157 | Dialogue: 0,0:10:53.87,0:11:08.32,Default,,0,0,0,,I saw a recent year recommendation to use a coding guideline , a really good guidelines, it describe how to write good code in about 198s. it hasn't been updated, that's a long time ago. 158 | Dialogue: 0,0:11:08.45,0:11:10.78,Default,,0,0,0,,and so they became a drag. 159 | Dialogue: 0,0:11:10.78,0:11:23.66,Default,,0,0,0,,a lot of code are specialized for particular application areas like I helped to write a set of guidelines for hard-realtime softwares or flight controlls 160 | Dialogue: 0,0:11:24.02,0:11:27.25,Default,,0,0,0,,these are very nice guidelines for that. 161 | Dialogue: 0,0:11:27.25,0:11:30.21,Default,,0,0,0,,but then people try use it in some other areas. 162 | Dialogue: 0,0:11:30.21,0:11:38.90,Default,,0,0,0,,and you know, one of the guide rules for flight is that you don't use "new" after you take off. 163 | Dialogue: 0,0:11:38.90,0:11:41.04,Default,,0,0,0,,and you never use "delete" 164 | Dialogue: 0,0:11:41.30,0:11:45.94,Default,,0,0,0,,maybe these are not the most appropriate guidelines elsewhere. 165 | Dialogue: 0,0:11:46.19,0:11:51.40,Default,,0,0,0,,other guidelines have similar kind of bias and constraint, and people tend to forget them. 166 | Dialogue: 0,0:11:51.78,0:11:55.37,Default,,0,0,0,,and a lot of them are very long winded. 167 | Dialogue: 0,0:11:55.37,0:11:59.73,Default,,0,0,0,,you really need to be a language lawyer to understand them. 168 | Dialogue: 0,0:11:59.73,0:12:04.41,Default,,0,0,0,,I looked at the rules for how to use pointers in c++ 169 | Dialogue: 0,0:12:04.41,0:12:10.36,Default,,0,0,0,,I mean, I was miserable, I couldn't understand all those rules. 170 | Dialogue: 0,0:12:10.66,0:12:13.00,Default,,0,0,0,,and you can't follow them, really. 171 | Dialogue: 0,0:12:13.00,0:12:18.81,Default,,0,0,0,,and a lot of guidelines don't have very good tools 172 | Dialogue: 0,0:12:19.15,0:12:21.38,Default,,0,0,0,,and they have platform dependencies 173 | Dialogue: 0,0:12:21.38,0:12:21.63,Default,,0,0,0,,{\pos(357,499)}da 174 | Dialogue: 0,0:12:21.63,0:12:21.81,Default,,0,0,0,,{\pos(276,477)}da 175 | Dialogue: 0,0:12:21.80,0:12:21.93,Default,,0,0,0,,{\pos(483,425)}da 176 | Dialogue: 0,0:12:21.93,0:12:22.05,Default,,0,0,0,,{\pos(301,424)}da 177 | Dialogue: 0,0:12:22.07,0:12:22.59,Default,,0,0,0,,{\pos(373,400)}da~ 178 | Dialogue: 0,0:12:22.77,0:12:24.50,Default,,0,0,0,,and the don't produce guidance. 179 | Dialogue: 0,0:12:24.70,0:12:33.68,Default,,0,0,0,,I really like to emphasize that telling people what not to do is less helpfull than telling what to do. 180 | Dialogue: 0,0:12:33.79,0:12:36.30,Default,,0,0,0,,so let's do those good guidelines 181 | Dialogue: 0,0:12:36.30,0:12:40.49,Default,,0,0,0,,comprehensive, browserable, for modern c++, for the moment 182 | Dialogue: 0,0:12:40.49,0:12:53.04,Default,,0,0,0,,first of all, let's ignore legacy code, let's ignore old stuff. let's write the rules for what we would like our code to look like in 5 to 10 years 183 | Dialogue: 0,0:12:53.20,0:12:59.06,Default,,0,0,0,,and then we'll deal with how to do the transition, how to do with in compatibility when we have to. 184 | Dialogue: 0,0:13:00.36,0:13:03.16,Default,,0,0,0,,gradual adaption is essential. 185 | Dialogue: 0,0:13:03.41,0:13:05.26,Default,,0,0,0,,prescriptive teachable 186 | Dialogue: 0,0:13:05.29,0:13:11.46,Default,,0,0,0,,one of the things that hold c++ back is that there are really a lot of bad teaching materials out there. 187 | Dialogue: 0,0:13:11.46,0:13:14.22,Default,,0,0,0,,some of it is very old, some of it is backwards-looking 188 | Dialogue: 0,0:13:14.29,0:13:19.57,Default,,0,0,0,,some of it try to maximize the pill by domain it down 189 | Dialogue: 0,0:13:19.57,0:13:21.03,Default,,0,0,0,,and things like that. 190 | Dialogue: 0,0:13:21.18,0:13:26.34,Default,,0,0,0,,so a setup guidelines can also guide teachers to how to teaching. 191 | Dialogue: 0,0:13:26.54,0:13:29.47,Default,,0,0,0,,Flexiable of course. Because the huge community. 192 | Dialogue: 0,0:13:29.64,0:13:30.08,Default,,0,0,0,,I mean 193 | Dialogue: 0,0:13:30.19,0:13:33.98,Default,,0,0,0,,we recover just about everything that's been done on computing 194 | Dialogue: 0,0:13:34.12,0:13:36.07,Default,,0,0,0,,And of course Non-proprietary. 195 | Dialogue: 0,0:13:36.07,0:13:39.68,Default,,0,0,0,,We couldn't possibly do this with limits. 196 | Dialogue: 0,0:13:43.28,0:13:46.51,Default,,0,0,0,,There are some high level rules and there are some low-level rules. 197 | Dialogue: 0,0:13:46.59,0:13:50.57,Default,,0,0,0,,the high-level rules are there to provide a conceptual framework for everything 198 | Dialogue: 0,0:13:50.68,0:13:53.48,Default,,0,0,0,,that sort of philosophical on nature. 199 | Dialogue: 0,0:13:53.60,0:13:54.79,Default,,0,0,0,,and they are very useful. 200 | Dialogue: 0,0:13:54.79,0:14:00.43,Default,,0,0,0,,like, you have to expre4ss ideas in code - compilers don't read the comments. 201 | Dialogue: 0,0:14:00.52,0:14:08.12,Default,,0,0,0,,and you use ISO standard c++, yes there are reasons to use extensions as such 202 | Dialogue: 0,0:14:08.12,0:14:13.54,Default,,0,0,0,,but we are not going to deal with that, that will be for paticular restrictions 203 | Dialogue: 0,0:14:13.72,0:14:16.36,Default,,0,0,0,,And we want static type safety 204 | Dialogue: 0,0:14:17.10,0:14:18.14,Default,,0,0,0,,etc.etc 205 | Dialogue: 0,0:14:18.32,0:14:21.17,Default,,0,0,0,,so there a philosophical framework here 206 | Dialogue: 0,0:14:21.31,0:14:26.70,Default,,0,0,0,,the problem is that again compilers and programmers don't really get philosophy. 207 | Dialogue: 0,0:14:26.90,0:14:35.84,Default,,0,0,0,, it means that you have to transfer into something that can be understood in detail in context of a piece of program and use. 208 | Dialogue: 0,0:14:35.84,0:14:38.54,Default,,0,0,0,,so for that reason there is a whole bunch of low-level rules. 209 | Dialogue: 0,0:14:38.79,0:14:43.65,Default,,0,0,0,,that basically you guys should threw the massive alternatives and features 210 | Dialogue: 0,0:14:46.26,0:14:52.70,Default,,0,0,0,,the low-level rules, things like, use T* to designate a single object, not array. 211 | Dialogue: 0,0:14:52.90,0:14:57.58,Default,,0,0,0,,and prefer initialization to assignment in constructors 212 | Dialogue: 0,0:14:57.71,0:15:01.08,Default,,0,0,0,,these are easily checkable. 213 | Dialogue: 0,0:15:01.08,0:15:04.18,Default,,0,0,0,,we have a tool that tells you when you violate it. 214 | Dialogue: 0,0:15:04.24,0:15:06.00,Default,,0,0,0,,Always initialize an object 215 | Dialogue: 0,0:15:06.04,0:15:11.96,Default,,0,0,0,,compilers these days do. but it's a good rule and we can do even better with external tools that we have them. 216 | Dialogue: 0,0:15:12.01,0:15:15.29,Default,,0,0,0,,so basically that sort of shows the way through the world dominance 217 | Dialogue: 0,0:15:15.66,0:15:22.27,Default,,0,0,0,,and the tools provide feedback for programers, it also helps unify styles. 218 | Dialogue: 0,0:15:22.58,0:15:27.34,Default,,0,0,0,,if I look at a piece of code and I see a string, 219 | Dialogue: 0,0:15:27.34,0:15:30.20,Default,,0,0,0,,if I know it's std::string, I know a lot. 220 | Dialogue: 0,0:15:30.37,0:15:34.28,Default,,0,0,0,,and it helped me, and I don't have to go back and read the manual again. 221 | Dialogue: 0,0:15:35.51,0:15:47.51,Default,,0,0,0,,so a more unify style helps getting code written quickly, helps me read the code, understand the code 222 | Dialogue: 0,0:15:47.70,0:15:53.94,Default,,0,0,0,,and one thing you should understand is that the rules and not mean to be minimal or orthogonal. 223 | Dialogue: 0,0:15:54.23,0:16:01.74,Default,,0,0,0,,text book writters spend a lot of time trying to make sure that fix minimal amount of paper. 224 | Dialogue: 0,0:16:02.54,0:16:03.79,Default,,0,0,0,,this is not we are up to 225 | Dialogue: 0,0:16:04.06,0:16:12.33,Default,,0,0,0,,we try to have the most helpful, and have a large set tool to tell you when you fall over the edge. 226 | Dialogue: 0,0:16:12.88,0:16:16.58,Default,,0,0,0,,so the structure of a rule is simple and structured. 227 | Dialogue: 0,0:16:18.24,0:16:21.46,Default,,0,0,0,,"No naked new" for instance, it's a rule. 228 | Dialogue: 0,0:16:21.46,0:16:24.65,Default,,0,0,0,,and Reference numbers - people love reference numbers 229 | Dialogue: 0,0:16:24.65,0:16:27.15,Default,,0,0,0,,It also means that you can search for them. 230 | Dialogue: 0,0:16:27.26,0:16:31.62,Default,,0,0,0,,I mean you can refer to them in error messages. things like that. 231 | Dialogue: 0,0:16:32.01,0:16:38.49,Default,,0,0,0,,and NEVER NEVER tell people what not to do without giving a reason or what to do without giving a reason 232 | Dialogue: 0,0:16:38.53,0:16:44.15,Default,,0,0,0,,so every rule with the first thing that comes up with the rule itself is that rational a reason. 233 | Dialogue: 0,0:16:44.50,0:16:46.32,Default,,0,0,0,,and then it comes with an example. 234 | Dialogue: 0,0:16:46.40,0:16:53.05,Default,,0,0,0,,because by and large we don't understand abstract text, we need a concrete example or more 235 | Dialogue: 0,0:16:53.38,0:16:57.70,Default,,0,0,0,,if it's a "don't do this" rule, there should be alternatives. 236 | Dialogue: 0,0:16:57.81,0:17:01.12,Default,,0,0,0,,never tell people what not to do unless you give them alternatives. 237 | Dialogue: 0,0:17:01.84,0:17:03.54,Default,,0,0,0,,fairly simple to say. 238 | Dialogue: 0,0:17:03.79,0:17:05.64,Default,,0,0,0,,little bit hard to do sometimes. 239 | Dialogue: 0,0:17:05.70,0:17:10.83,Default,,0,0,0,,these rules are variable and value for a long time. 240 | Dialogue: 0,0:17:11.23,0:17:13.55,Default,,0,0,0,,There's references to other things. 241 | Dialogue: 0,0:17:13.55,0:17:18.34,Default,,0,0,0,,There's notes, things that we just felt was useful to say 242 | Dialogue: 0,0:17:18.44,0:17:26.99,Default,,0,0,0,,and then, there suppose to be long discussion at the end where you discuss a set of rules, set of reasons as such. 243 | Dialogue: 0,0:17:27.12,0:17:28.84,Default,,0,0,0,,it's bit weak just now. 244 | Dialogue: 0,0:17:28.91,0:17:30.62,Default,,0,0,0,,but that's the idea. 245 | Dialogue: 0,0:17:30.73,0:17:40.05,Default,,0,0,0,,some time you need more. as an explanation, that what fits on above this many lines, fit right on your screen when you look at them. 246 | Dialogue: 0,0:17:40.30,0:17:42.53,Default,,0,0,0,,so that's structure. 247 | Dialogue: 0,0:17:42.87,0:17:52.28,Default,,0,0,0,,the general idea is that people who have tryed to subset language have by and large failed. 248 | Dialogue: 0,0:17:52.81,0:18:02.73,Default,,0,0,0,,the thing that you really want to get rid of, like bad uses of pointers, bad interactions between inheritance and arrays and things like that 249 | Dialogue: 0,0:18:02.73,0:18:08.96,Default,,0,0,0,,if you just ban everything to get rid of problems, you can't write decent code anymore 250 | Dialogue: 0,0:18:08.96,0:18:11.77,Default,,0,0,0,,Yes! I want to write high-level code! 251 | Dialogue: 0,0:18:11.95,0:18:19.79,Default,,0,0,0,,But how do I do that? I do that by having libraries that allow me to write high-level code, and they implemented it using low-level code. 252 | Dialogue: 0,0:18:19.79,0:18:24.22,Default,,0,0,0,,because otherwise you can't get the efficiency and portability out of that. 253 | Dialogue: 0,0:18:24.22,0:18:27.55,Default,,0,0,0,,So, the general idea is not just the subset. 254 | Dialogue: 0,0:18:27.55,0:18:30.20,Default,,0,0,0,,First, we provide a superset. 255 | Dialogue: 0,0:18:30.20,0:18:33.52,Default,,0,0,0,,we have ISO standard C++ 256 | Dialogue: 0,0:18:33.60,0:18:38.99,Default,,0,0,0,,we have parts of the standard library that we recommend and that's you can use when you want to. 257 | Dialogue: 0,0:18:39.18,0:18:52.81,Default,,0,0,0,,and we have something called the guidelines support libraries which is small set - small as less than 2 dozen little classes and really that smaill - that's added. 258 | Dialogue: 0,0:18:53.04,0:18:54.76,Default,,0,0,0,,And that way, we can say: 259 | Dialogue: 0,0:18:54.76,0:18:57.52,Default,,0,0,0,,the messy dangerous bits, don't use them. 260 | Dialogue: 0,0:18:57.71,0:19:08.54,Default,,0,0,0,,we have provided abstractions that are elegent and efficient to allow you to not go there most of the time, for most people, all of the time. 261 | Dialogue: 0,0:19:08.54,0:19:13.36,Default,,0,0,0,,once you build that superset - the language + libraries. 262 | Dialogue: 0,0:19:13.52,0:19:17.04,Default,,0,0,0,,the you subset, and you can get rid of a lot of the crack. 263 | Dialogue: 0,0:19:17.18,0:19:24.43,Default,,0,0,0,,this is not a brand new idea I wrote a paper about it sometime more than ten years ago. 264 | Dialogue: 0,0:19:24.60,0:19:32.12,Default,,0,0,0,,so, really what we want is not neutered subset of c++ which is a lot of people that tryed. 265 | Dialogue: 0,0:19:32.12,0:19:35.16,Default,,0,0,0,,we want c++ on steroids on the other hand. 266 | Dialogue: 0,0:19:35.16,0:19:36.97,Default,,0,0,0,,so more of a good stuff. 267 | Dialogue: 0,0:19:37.21,0:19:40.78,Default,,0,0,0,,so the rules rely on the libraries. 268 | Dialogue: 0,0:19:40.88,0:19:43.52,Default,,0,0,0,,you can use any standard libraries of course. 269 | Dialogue: 0,0:19:43.69,0:19:46.91,Default,,0,0,0,,but once we rely on it, things like 270 | Dialogue: 0,0:19:46.91,0:19:50.84,Default,,0,0,0,,standart library class like vector or unique_ptr 271 | Dialogue: 0,0:19:50.84,0:19:59.13,Default,,0,0,0,,and some guideline things array_view - this is when you have a begining of a sequence and end 272 | Dialogue: 0,0:20:01.08,0:20:05.42,Default,,0,0,0,,not_null - you can say that a pointer shouldn't be null 273 | Dialogue: 0,0:20:05.42,0:20:06.36,Default,,0,0,0,,now get back to that 274 | Dialogue: 0,0:20:06.49,0:20:10.64,Default,,0,0,0,,so there's rules for using the GSL 275 | Dialogue: 0,0:20:10.64,0:20:13.53,Default,,0,0,0,,Never transfer ownership by raw pointer 276 | Dialogue: 0,0:20:14.06,0:20:18.11,Default,,0,0,0,,the idea is if you see a T*, it points to an element. 277 | Dialogue: 0,0:20:18.32,0:20:23.80,Default,,0,0,0,,you are not suppose to delete it, because it just points to an element, somebody ownes it. that's it. 278 | Dialogue: 0,0:20:23.90,0:20:33.00,Default,,0,0,0,,and if you want to have something that can not ever be null and you still want a pointer, you can use not_null of that pointer type. 279 | Dialogue: 0,0:20:33.00,0:20:36.94,Default,,0,0,0,,now, there's rules that encourage you to use higher level abstractions 280 | Dialogue: 0,0:20:37.05,0:20:46.00,Default,,0,0,0,,but these here are choose to show how you can deal with traditional old style code and improve it : don't pass an array as a ingle pointer. 281 | Dialogue: 0,0:20:46.22,0:20:51.29,Default,,0,0,0,,so basically, guess what this could do' 282 | Dialogue: 0,0:20:51.69,0:20:58.28,Default,,0,0,0,,I don't actually think that we can do less than can say double our productivity 283 | Dialogue: 0,0:20:58.28,0:21:03.82,Default,,0,0,0,,this is big claim but I think it can be done 284 | Dialogue: 0,0:21:03.85,0:21:16.11,Default,,0,0,0,,look at a good programmer working on a modern codebase and looking at same programmer working on a 20year old codebase or 10 year old codebase 285 | Dialogue: 0,0:21:16.27,0:21:22.56,Default,,0,0,0,,also look at a median kind of programmer 286 | Dialogue: 0,0:21:22.56,0:21:25.32,Default,,0,0,0,,and see what it taks to become a greate programmer. 287 | Dialogue: 0,0:21:25.37,0:21:27.23,Default,,0,0,0,,you need support you need time 288 | Dialogue: 0,0:21:27.23,0:21:28.59,Default,,0,0,0,,we can lower that time 289 | Dialogue: 0,0:21:28.84,0:21:37.87,Default,,0,0,0,,so, I think we can imitate experienced programers form rule sets that we trying to enforce. 290 | Dialogue: 0,0:21:38.09,0:21:42.38,Default,,0,0,0,,and so we can eliminate huge classes of errors. 291 | Dialogue: 0,0:21:42.38,0:21:45.08,Default,,0,0,0,,so simplification is important 292 | Dialogue: 0,0:21:45.21,0:21:48.22,Default,,0,0,0,,if we can have simpler code, maintance improves. 293 | Dialogue: 0,0:21:48.22,0:21:50.88,Default,,0,0,0,,consistent style speed up learning 294 | Dialogue: 0,0:21:50.99,0:21:57.52,Default,,0,0,0,,and guide people away from the deep dark corners of the law so much 295 | Dialogue: 0,0:21:58.88,0:22:06.70,Default,,0,0,0,,so much programers spend so much of their time looking on the most complicated code and the most complicated rules of the standard 296 | Dialogue: 0,0:22:06.96,0:22:10.30,Default,,0,0,0,,I'm shaking my head, I mean, this hurts! 297 | Dialogue: 0,0:22:10.49,0:22:11.96,Default,,0,0,0,,why do you do it ?! 298 | Dialogue: 0,0:22:12.46,0:22:19.29,Default,,0,0,0,,so I'm emphasis on avoiding waste, that can improve importance 299 | Dialogue: 0,0:22:19.42,0:22:30.12,Default,,0,0,0,,My guess is every large organization/community that's doing this will need to have some special rules for what they are doing 300 | Dialogue: 0,0:22:30.27,0:22:33.13,Default,,0,0,0,,so I'm talking about what I called the "core guidelines" 301 | Dialogue: 0,0:22:33.13,0:22:35.52,Default,,0,0,0,,things that pretentiously help everybody 302 | Dialogue: 0,0:22:35.52,0:22:39.96,Default,,0,0,0,,And I think most of you will want extensions in places. 303 | Dialogue: 0,0:22:40.09,0:22:53.04,Default,,0,0,0,,and some of you will want restructuring tool because there is some one recommended us that it doesn't quite fit in your world or maybe doesn't fit there for the next couple of years till you upgrade your codebase. 304 | Dialogue: 0,0:22:53.04,0:22:55.31,Default,,0,0,0,,and don't compromise performance 305 | Dialogue: 0,0:22:55.31,0:22:58.00,Default,,0,0,0,,performance is a really important aspect 306 | Dialogue: 0,0:22:58.00,0:23:00.06,Default,,0,0,0,,so I don't think I've gone mad 307 | Dialogue: 0,0:23:00.16,0:23:05.56,Default,,0,0,0,,I think we are actually attacking what we known to be the common most serious sources of errors 308 | Dialogue: 0,0:23:05.56,0:23:09.02,Default,,0,0,0,,and get rid of errors 309 | Dialogue: 0,0:23:10.25,0:23:15.44,Default,,0,0,0,,no resource leaks! that's good, we know how to do that! 310 | Dialogue: 0,0:23:15.48,0:23:21.61,Default,,0,0,0,,eliminate dangling pointer - that suppose to be very hard. I'll show you how to do that 311 | Dialogue: 0,0:23:21.90,0:23:28.48,Default,,0,0,0,,eliminate out-of-range access - that can not be done without a few runtime checks 312 | Dialogue: 0,0:23:28.91,0:23:32.12,Default,,0,0,0,,a few!! if you just check everything you are deracinate 313 | Dialogue: 0,0:23:32.12,0:23:37.53,Default,,0,0,0,,but a few can be done and we have some suggestions about that 314 | Dialogue: 0,0:23:37.79,0:23:39.96,Default,,0,0,0,,and Tool support is essential 315 | Dialogue: 0,0:23:39.96,0:23:43.88,Default,,0,0,0,,a lot of this, humans are not very actually good at it 316 | Dialogue: 0,0:23:46.67,0:23:49.23,Default,,0,0,0,,you look at a million lines of code and your eyes glares over. 317 | Dialogue: 0,0:23:49.45,0:23:57.36,Default,,0,0,0,,you check for a paticular kind of error and mistake in a million lines of code, 100 lines of code 10000 lines of code 318 | Dialogue: 0,0:23:57.42,0:24:00.30,Default,,0,0,0,,you get very tired and your concentration wavers. 319 | Dialogue: 0,0:24:00.38,0:24:01.40,Default,,0,0,0,,we neeeed tools 320 | Dialogue: 0,0:24:02.14,0:24:05.71,Default,,0,0,0,,the support library helps by simplify the rules 321 | Dialogue: 0,0:24:05.72,0:24:09.47,Default,,0,0,0,,and a lot of it has to do is reinforcing the type system. 322 | Dialogue: 0,0:24:09.52,0:24:16.73,Default,,0,0,0,,we can do better than we did it in 1978 and 1985 323 | Dialogue: 0,0:24:16.73,0:24:19.76,Default,,0,0,0,,so let's look at the core, the core rules. 324 | Dialogue: 0,0:24:21.10,0:24:29.00,Default,,0,0,0,,we have to start somewhere, so gradual adaption will be the way most of us will go on. 325 | Dialogue: 0,0:24:29.00,0:24:36.76,Default,,0,0,0,,if we write some brand new code from scratch, not using anybody else's libraries. then you can probably follow all the rules today. 326 | Dialogue: 0,0:24:37.08,0:24:39.32,Default,,0,0,0,,that doesn't happen very often. 327 | Dialogue: 0,0:24:39.52,0:24:42.46,Default,,0,0,0,,so I see gradual adaption be necessary. 328 | Dialogue: 0,0:24:42.91,0:24:47.05,Default,,0,0,0,,and therefore core of the core rules 329 | Dialogue: 0,0:24:47.08,0:24:52.09,Default,,0,0,0,,No leaks, No dangling pointers, No type violations through pointers at all! 330 | Dialogue: 0,0:24:52.46,0:24:55.72,Default,,0,0,0,,we know how to avoid leaks. 331 | Dialogue: 0,0:24:55.88,0:25:00.99,Default,,0,0,0,,we just root every object in a scope 332 | Dialogue: 0,0:25:00.99,0:25:04.48,Default,,0,0,0,,RAII kind of standard containers 333 | Dialogue: 0,0:25:04.48,0:25:09.60,Default,,0,0,0,,new and delete disappear into the abstractions 334 | Dialogue: 0,0:25:09.60,0:25:14.49,Default,,0,0,0,,this is nice. when I see "delete" in application code, there must be bugs somewhere. 335 | Dialogue: 0,0:25:15.04,0:25:15.69,Default,,0,0,0,,why? 336 | Dialogue: 0,0:25:15.69,0:25:19.96,Default,,0,0,0,,because if there is one delete, there probably should be more. 337 | Dialogue: 0,0:25:19.96,0:25:23.58,Default,,0,0,0,,and there are probably been too many. 338 | Dialogue: 0,0:25:23.58,0:25:29.42,Default,,0,0,0,,so new/delete disappear into classes 339 | Dialogue: 0,0:25:29.95,0:25:35.74,Default,,0,0,0,,when you see a "new" in application code, you think there must be a problem here. 340 | Dialogue: 0,0:25:35.88,0:25:41.76,Default,,0,0,0,,because if there's a new there should be a delete somewhere, and if there's delete somewhere and we know from experience we made mistakes. 341 | Dialogue: 0,0:25:42.11,0:25:44.48,Default,,0,0,0,,so we don't do that. 342 | Dialogue: 0,0:25:44.62,0:25:48.76,Default,,0,0,0,,this leads us to what I think is a worse nightmare problem. 343 | Dialogue: 0,0:25:49.60,0:25:50.99,Default,,0,0,0,,dangling pointers 344 | Dialogue: 0,0:25:51.13,0:25:52.80,Default,,0,0,0,,and this are so easy to get to. 345 | Dialogue: 0,0:25:52.86,0:25:58.73,Default,,0,0,0,,here we have a function "f" that you give it a pointer and it deletes. 346 | Dialogue: 0,0:25:58.94,0:26:00.81,Default,,0,0,0,,so you deleted that pointer. 347 | Dialogue: 0,0:26:02.04,0:26:04.24,Default,,0,0,0,,that might be right or might be wrong. 348 | Dialogue: 0,0:26:04.51,0:26:08.76,Default,,0,0,0,,my rulers on it, it's very suspect because it is deleting application code. 349 | Dialogue: 0,0:26:09.18,0:26:12.46,Default,,0,0,0,,here is "g" makes an object, calls f. 350 | Dialogue: 0,0:26:12.76,0:26:20.62,Default,,0,0,0,,and then it uses q which happens to be the pointing the the object that was deleted in f. 351 | Dialogue: 0,0:26:20.80,0:26:23.23,Default,,0,0,0,,this is how you scram your memory 352 | Dialogue: 0,0:26:23.44,0:26:26.78,Default,,0,0,0,,the rules will make sure that you don't do this. 353 | Dialogue: 0,0:26:26.88,0:26:31.65,Default,,0,0,0,,and it'll take care of some of the most shroud and difficult find bugs 354 | Dialogue: 0,0:26:32.18,0:26:39.16,Default,,0,0,0,,and we have to do this because if we don't we can damage type safety. 355 | Dialogue: 0,0:26:39.33,0:26:41.54,Default,,0,0,0,,I say this object is an integer 356 | Dialogue: 0,0:26:42.29,0:26:44.16,Default,,0,0,0,,you do this example 357 | Dialogue: 0,0:26:44.29,0:26:49.33,Default,,0,0,0,,and the object might integer are laies at place where your object wasn't, you scramble it. 358 | Dialogue: 0,0:26:49.76,0:26:52.14,Default,,0,0,0,,Memory safety of course. 359 | Dialogue: 0,0:26:52.15,0:26:55.14,Default,,0,0,0,,because we are not using memory as if it is clear 360 | Dialogue: 0,0:26:55.36,0:27:03.35,Default,,0,0,0,,and Resource safety is compromise because you can destory things that are laying around there. 361 | Dialogue: 0,0:27:03.94,0:27:06.48,Default,,0,0,0,,double delete and no deletes 362 | Dialogue: 0,0:27:06.54,0:27:13.33,Default,,0,0,0,,we have to solve this problem to get type safety to get resource safety. 363 | Dialogue: 0,0:27:13.78,0:27:18.88,Default,,0,0,0,,we're going to eliminate this by combination of rules 364 | Dialogue: 0,0:27:19.01,0:27:20.04,Default,,0,0,0,,I mean eliminated 365 | Dialogue: 0,0:27:20.08,0:27:20.92,Default,,0,0,0,,get rid of it 366 | Dialogue: 0,0:27:21.05,0:27:22.40,Default,,0,0,0,, 367 | Dialogue: 0,0:27:22.87,0:27:26.26,Default,,0,0,0,,we distinguish owners from non-owners 368 | Dialogue: 0,0:27:26.27,0:27:30.78,Default,,0,0,0,,if I have a pointer, am I suppose to delete it or not? NO! 369 | Dialogue: 0,0:27:31.30,0:27:34.27,Default,,0,0,0,,asure raw pointers to be non-owners! 370 | Dialogue: 0,0:27:34.27,0:27:45.28,Default,,0,0,0,,we have many pointers in our programs, far too many, but let's asure they are all innocent, they just point to an object, they are not suppose to be a ownership 371 | Dialogue: 0,0:27:45.60,0:27:55.60,Default,,0,0,0,,Catch all attempts for a pointer to "escape" into a scope that is outside a scope of what it points to. 372 | Dialogue: 0,0:27:55.62,0:27:57.13,Default,,0,0,0,,fairly simple 373 | Dialogue: 0,0:27:57.39,0:28:01.32,Default,,0,0,0,,anything that holds an owner is consider an owner 374 | Dialogue: 0,0:28:01.42,0:28:03.53,Default,,0,0,0,,so all of this works recursively 375 | Dialogue: 0,0:28:03.69,0:28:05.89,Default,,0,0,0,,so this is simple rule. 376 | Dialogue: 0,0:28:05.98,0:28:09.24,Default,,0,0,0,,we have some pointers, they point to an object 377 | Dialogue: 0,0:28:10.32,0:28:13.36,Default,,0,0,0,,that object is held alive by an owner 378 | Dialogue: 0,0:28:13.83,0:28:15.30,Default,,0,0,0,,this works recursively 379 | Dialogue: 0,0:28:15.30,0:28:18.32,Default,,0,0,0,,the object happens to have an owner pointer inside it 380 | Dialogue: 0,0:28:18.54,0:28:24.38,Default,,0,0,0,,thus we have constructors and distructors. constructors to construct, distructors to clean up. 381 | Dialogue: 0,0:28:24.61,0:28:37.43,Default,,0,0,0,,what we really have to avoid is that pointer there. that has been passed below the object owner in the stack so when we delete the owner the object is not there and people are still refering to it. 382 | Dialogue: 0,0:28:37.52,0:28:44.90,Default,,0,0,0,,this must never happen so we can asure that. so long long way to eliminate (dangling) pointers. 383 | Dialogue: 0,0:28:45.03,0:28:46.42,Default,,0,0,0,,this is not new rule 384 | Dialogue: 0,0:28:46.63,0:28:50.85,Default,,0,0,0,,if you look at the standard it suggest you should not do that because it's undefined behavior 385 | Dialogue: 0,0:28:51.07,0:28:53.35,Default,,0,0,0,,the point is how do we actully get there. 386 | Dialogue: 0,0:28:53.90,0:28:58.41,Default,,0,0,0,,so here is dangling pointers thing again 387 | Dialogue: 0,0:28:58.99,0:29:01.83,Default,,0,0,0,,first of all the rule will catch the delete p. 388 | Dialogue: 0,0:29:02.12,0:29:10.42,Default,,0,0,0,,you had a innocent looking pointer X* that is not an owner. so the rules will tell you not to do that. 389 | Dialogue: 0,0:29:10.88,0:29:14.45,Default,,0,0,0,,tools that enforce the rules will tell you that is bad 390 | Dialogue: 0,0:29:14.71,0:29:17.26,Default,,0,0,0,,you go back to the "g" 391 | Dialogue: 0,0:29:17.58,0:29:22.35,Default,,0,0,0,,it says, well, "new X" obviously produces an owner. 392 | Dialogue: 0,0:29:22.44,0:29:29.14,Default,,0,0,0,,so assigning it to a plain old pointer is going to be wrong. 393 | Dialogue: 0,0:29:29.14,0:29:32.09,Default,,0,0,0,,because this could lead to a leak 394 | Dialogue: 0,0:29:32.31,0:29:39.62,Default,,0,0,0,,if fact it is also .. if do that will lead you to problems with exceptions, is another matter. 395 | Dialogue: 0,0:29:39.78,0:29:48.57,Default,,0,0,0,,we'll never get down to the problem because you are already been traped by those simple rules twice. 396 | Dialogue: 0,0:29:49.64,0:29:56.73,Default,,0,0,0,,so we can look at how we represent the ownership. 397 | Dialogue: 0,0:29:57.12,0:30:05.50,Default,,0,0,0,,you can mark every owning pointer as owner 398 | Dialogue: 0,0:30:05.92,0:30:09.15,Default,,0,0,0,,for a long time I think we need a bit to do that 399 | Dialogue: 0,0:30:09.52,0:30:16.06,Default,,0,0,0,,that sort of dynamic module that took every pointer and mark it if owner or not. 400 | Dialogue: 0,0:30:16.45,0:30:22.78,Default,,0,0,0,,I had modules like that before I put and saying whether it's a const or not , things like that 401 | Dialogue: 0,0:30:22.88,0:30:24.64,Default,,0,0,0,,the point is it's useless! 402 | Dialogue: 0,0:30:24.76,0:30:30.41,Default,,0,0,0,,It is very good for thinking about problems but it is useless for actually doing it 403 | Dialogue: 0,0:30:30.41,0:30:36.89,Default,,0,0,0,,because, well, it cost time|space to have that extra bit, or time&space. 404 | Dialogue: 0,0:30:37.07,0:30:47.47,Default,,0,0,0,,It means that the code that uses such smart pointers flat pointers as such are no longer ABI compatible with the existing code. 405 | Dialogue: 0,0:30:47.66,0:30:52.16,Default,,0,0,0,,it runs slower than ordinary C or C++. 406 | Dialogue: 0,0:30:52.28,0:30:53.64,Default,,0,0,0,,that's not acceptable 407 | Dialogue: 0,0:30:53.96,0:30:56.50,Default,,0,0,0,,and we have to rewrite our own code for it 408 | Dialogue: 0,0:30:56.53,0:31:10.50,Default,,0,0,0,,so the idea is that you just have a type system owner that static analysis tools can use. 409 | Dialogue: 0,0:31:10.59,0:31:15.20,Default,,0,0,0,,when I talk about pointers I mean anything that can point to an object. 410 | Dialogue: 0,0:31:15.25,0:31:23.52,Default,,0,0,0,,if we can handle it for pointers, we can handle it for everything, references, containers, smart pointers and things like that. 411 | Dialogue: 0,0:31:27.39,0:31:30.26,Default,,0,0,0,,we are going to eliminate all dangling pointers. 412 | Dialogue: 0,0:31:34.32,0:31:37.35,Default,,0,0,0,,oh yeah, down on the broader you can see the definition of an owner. 413 | Dialogue: 0,0:31:37.39,0:31:40.06,Default,,0,0,0,,just as alien, we mark it as an owner 414 | Dialogue: 0,0:31:40.43,0:31:44.00,Default,,0,0,0,,humans can read it, tools can read it 415 | Dialogue: 0,0:31:44.45,0:31:46.06,Default,,0,0,0,,but your linker doesn't care. 416 | Dialogue: 0,0:31:46.19,0:31:49.28,Default,,0,0,0,,so everything is working as before. 417 | Dialogue: 0,0:31:49.39,0:31:51.00,Default,,0,0,0,,so here is how we can use it. 418 | Dialogue: 0,0:31:51.00,0:32:02.10,Default,,0,0,0,,we can use an owner to improve our implementations of higher level abstractions, we want to use high level abstractions like vector and static array. 419 | Dialogue: 0,0:32:02.22,0:32:12.55,Default,,0,0,0,,and we just mark that, in paticuler cases one of the 3 pointers inside the implementation of the vector is an ower and the other two aren't. 420 | Dialogue: 0,0:32:12.80,0:32:16.76,Default,,0,0,0,,that's the owner, keep it alive, the others just pointing to it 421 | Dialogue: 0,0:32:16.82,0:32:19.63,Default,,0,0,0,,that sort of the general you should see a lot. 422 | Dialogue: 0,0:32:19.85,0:32:26.45,Default,,0,0,0,,and only if we are dealing with pointers directly do we use owners 423 | Dialogue: 0,0:32:26.46,0:32:45.31,Default,,0,0,0,,so there's "f()" that taks an owner, and then trying to call it. I call it with an owner, that'll transfer ownership; I call it with non-owner,that's bad. I delete one of the owners, that's good; delete something that's not an owner, that't bad, we can catch. 424 | Dialogue: 0,0:32:45.56,0:32:54.34,Default,,0,0,0,,and this is just marking, the static analysis tool will tell you when you did something that wasn't good. 425 | Dialogue: 0,0:32:54.34,0:32:58.59,Default,,0,0,0,,an owner has to transfer to someone else or delete it. 426 | Dialogue: 0,0:32:59.69,0:33:04.03,Default,,0,0,0,,the code will check whether you do it (or not) that's it. 427 | Dialogue: 0,0:33:04.82,0:33:06.73,Default,,0,0,0,,and owners are low-leve mechanism. 428 | Dialogue: 0,0:33:06.73,0:33:09.40,Default,,0,0,0,,you don't want to feddle with that all the time. 429 | Dialogue: 0,0:33:09.56,0:33:12.22,Default,,0,0,0,,but having owner allows you to do two things 430 | Dialogue: 0,0:33:12.30,0:33:19.29,Default,,0,0,0,,it provides the support for the implemention of high level abstrastions 431 | Dialogue: 0,0:33:12.30,0:33:19.29,Default,,0,0,0,,it allows you to implement high level abstrastions 432 | Dialogue: 0,0:33:19.29,0:33:25.47,Default,,0,0,0,,c++ are a language where you can design your own container, you can design your own smart pointers, etc 433 | Dialogue: 0,0:33:25.70,0:33:30.33,Default,,0,0,0,,now you get a little bit support in how to express this. 434 | Dialogue: 0,0:33:30.33,0:33:32.70,Default,,0,0,0,,and not make so many mistakes when you do it. 435 | Dialogue: 0,0:33:32.83,0:33:35.53,Default,,0,0,0,,and further more as ABIs 436 | Dialogue: 0,0:33:35.56,0:33:44.88,Default,,0,0,0,,somebody really says that they want any *, er, you don't have to give up all your checking to be able to use that ABI. 437 | Dialogue: 0,0:33:49.41,0:33:51.60,Default,,0,0,0,,What else do we have to do? 438 | Dialogue: 0,0:33:51.61,0:33:54.90,Default,,0,0,0,,we can handle owner ship now we have to handle dangling 439 | Dialogue: 0,0:34:00.49,0:34:05.50,Default,,0,0,0,,Don't transfer to pointer to a local to where it could be accessed by a caller. 440 | Dialogue: 0,0:34:07.31,0:34:09.42,Default,,0,0,0,,ok, let's look at the example there. 441 | Dialogue: 0,0:34:09.54,0:34:12.24,Default,,0,0,0,,I am returning something. 442 | Dialogue: 0,0:34:12.28,0:34:14.78,Default,,0,0,0,,I neither return a pointer to a local. 443 | Dialogue: 0,0:34:14.99,0:34:17.25,Default,,0,0,0,,not a good idea, we all know that. 444 | Dialogue: 0,0:34:17.25,0:34:22.74,Default,,0,0,0,,compiler are able to catch it more or less consistently for the last 20 years. 445 | Dialogue: 0,0:34:23.01,0:34:28.98,Default,,0,0,0,,then I'm returnning a pointer to something I just created on the free-store. 446 | Dialogue: 0,0:34:28.98,0:34:30.26,Default,,0,0,0,,that's fine. 447 | Dialogue: 0,0:34:30.26,0:34:33.46,Default,,0,0,0,,at least it's sortof fine becauseIt didn't mark it as owner. 448 | Dialogue: 0,0:34:33.47,0:34:37.41,Default,,0,0,0,,but as far as dangling pointers,it's not going to dangle. 449 | Dialogue: 0,0:34:37.41,0:34:41.41,Default,,0,0,0,,and finnaly, there's a pointer that is given to me 450 | Dialogue: 0,0:34:41.41,0:34:44.84,Default,,0,0,0,,then obviously I can give it back because it came from my caller. 451 | Dialogue: 0,0:34:45.14,0:34:48.89,Default,,0,0,0,,those are roughly only 3 cases we can handle that. 452 | Dialogue: 0,0:34:49.18,0:34:56.46,Default,,0,0,0,,we can stop pointers from escaping down to the bottom of the stack and out live the owner. 453 | Dialogue: 0,0:34:56.99,0:35:06.44,Default,,0,0,0,,so catches all kinds of the things , pointers references etc and that's so fine 454 | Dialogue: 0,0:35:06.49,0:35:13.69,Default,,0,0,0,,so, we need to classify acording to owner ship to work here. 455 | Dialogue: 0,0:35:13.76,0:35:17.21,Default,,0,0,0,,because, look at the f() there. 456 | Dialogue: 0,0:35:17.52,0:35:21.30,Default,,0,0,0,,it returns a vector of integers 457 | Dialogue: 0,0:35:21.53,0:35:35.44,Default,,0,0,0,,and inside that vector of integers we put something that's an owner, something that's a pointer to a local and something we got from our caller 458 | Dialogue: 0,0:35:35.92,0:35:41.82,Default,,0,0,0,,this... we can't handle the ownership, it just mixed. 459 | Dialogue: 0,0:35:42.44,0:35:45.02,Default,,0,0,0,,that's bad code. 460 | Dialogue: 0,0:35:45.08,0:35:46.88,Default,,0,0,0,,it's asking for touble. 461 | Dialogue: 0,0:35:46.97,0:35:49.30,Default,,0,0,0,,it'll be rejected for mixing it. 462 | Dialogue: 0,0:35:49.89,0:36:00.76,Default,,0,0,0,,in code we would have to try and deal with it and we can't 463 | Dialogue: 0,0:36:00.76,0:36:03.45,Default,,0,0,0,,because clearly the ownership became mixed. 464 | Dialogue: 0,0:36:03.54,0:36:07.60,Default,,0,0,0,,and when we passed it out, all the information about who shoud delete what has gone 465 | Dialogue: 0,0:36:07.64,0:36:29.17,Default,,0,0,0,,the only way of doing that is actually to hav something like big vector of (what) that should tell you which should be deleted or you can sort of hope you can change into unique_ptr so that preseve the ownership. 466 | Dialogue: 0,0:36:29.17,0:36:34.42,Default,,0,0,0,,don't mix ownership in containers! 467 | Dialogue: 0,0:36:34.52,0:36:38.70,Default,,0,0,0,,bacause in corrent code it doesn't work too well. 468 | Dialogue: 0,0:36:40.85,0:36:42.84,Default,,0,0,0,,in this code it'll be caught. 469 | Dialogue: 0,0:36:43.55,0:36:48.26,Default,,0,0,0,,so let's course many other ways of mis-using pointers and such. 470 | Dialogue: 0,0:36:48.26,0:36:51.38,Default,,0,0,0,,range errors, dereferencing nullptr 471 | Dialogue: 0,0:36:51.88,0:36:57.22,Default,,0,0,0,,I'm going to go little bit about that 472 | Dialogue: 0,0:36:57.57,0:37:03.37,Default,,0,0,0,,and I notice that there's a copy of printable here 473 | Dialogue: 0,0:37:03.48,0:37:07.24,Default,,0,0,0,,some of the rules are meanable to static analysis. 474 | Dialogue: 0,0:37:07.30,0:37:13.41,Default,,0,0,0,,some of them are meanable to sort of high G you can look at and give it as guidelines 475 | Dialogue: 0,0:37:13.52,0:37:16.57,Default,,0,0,0,,and some of them really accquire runtime checks. 476 | Dialogue: 0,0:37:16.76,0:37:20.11,Default,,0,0,0,,we want to minimize runtime checks because we want to run fast. 477 | Dialogue: 0,0:37:20.89,0:37:29.47,Default,,0,0,0,,so here is one of the tools that we are providing - it's similar to the proposals in standard committee. 478 | Dialogue: 0,0:37:29.49,0:37:39.12,Default,,0,0,0,,this one here, we'll do re-write, we have for some reason I don't understand at. the array view will be proposed in standard as read-only structure. 479 | Dialogue: 0,0:37:39.66,0:37:41.22,Default,,0,0,0,,but anyway, here. 480 | Dialogue: 0,0:37:41.32,0:37:42.88,Default,,0,0,0,,we have a common style 481 | Dialogue: 0,0:37:42.97,0:37:47.21,Default,,0,0,0,,we call with a pointer and a count 482 | Dialogue: 0,0:37:47.39,0:37:49.93,Default,,0,0,0,,this is my least favorite kind of interface 483 | Dialogue: 0,0:37:50.05,0:37:53.32,Default,,0,0,0,,least favorite, because it is so error prone. 484 | Dialogue: 0,0:37:53.32,0:37:56.20,Default,,0,0,0,,and least favorite because it is so common. 485 | Dialogue: 0,0:37:56.44,0:37:58.19,Default,,0,0,0,,so a lot of errors there. 486 | Dialogue: 0,0:37:58.27,0:38:01.25,Default,,0,0,0,,so I assign 9 to a[7]. 487 | Dialogue: 0,0:38:01.57,0:38:02.73,Default,,0,0,0,,it that ok? 488 | Dialogue: 0,0:38:02.99,0:38:04.56,Default,,0,0,0,,we have no ways of knowing! 489 | Dialogue: 0,0:38:04.56,0:38:06.56,Default,,0,0,0,,the information is not there 490 | Dialogue: 0,0:38:06.99,0:38:13.80,Default,,0,0,0,,and I can make a loop, let's hope a really was the count 491 | Dialogue: 0,0:38:13.96,0:38:16.49,Default,,0,0,0,,and we hope the count was right, that's fine. 492 | Dialogue: 0,0:38:16.73,0:38:19.96,Default,,0,0,0,,so instead, we provide you an abstraction that's array_view. 493 | Dialogue: 0,0:38:20.14,0:38:23.94,Default,,0,0,0,,a begining that can browse integers, doesn't matter 494 | Dialogue: 0,0:38:24.09,0:38:31.52,Default,,0,0,0,,there. you could check the runtime if you wanted to that a[7] is valid 495 | Dialogue: 0,0:38:31.77,0:38:35.32,Default,,0,0,0,,and if you don't want the checks. we can only have it on debug mode 496 | Dialogue: 0,0:38:35.50,0:38:41.64,Default,,0,0,0,,we can now write range-for loop that will work. 497 | Dialogue: 0,0:38:41.90,0:38:48.01,Default,,0,0,0,,notice that there is not int n to get wrong and the code get simplified and is become more checkable 498 | Dialogue: 0,0:38:48.01,0:38:50.97,Default,,0,0,0,,we are lifting the abstraction just a little bit. 499 | Dialogue: 0,0:38:51.15,0:38:54.28,Default,,0,0,0,,and so we can look at some calls there. 500 | Dialogue: 0,0:38:54.51,0:38:57.79,Default,,0,0,0,,I call it for a[100] 501 | Dialogue: 0,0:38:57.86,0:39:00.28,Default,,0,0,0,,I have to say a and 100. 502 | Dialogue: 0,0:39:00.28,0:39:05.30,Default,,0,0,0,,even though I have told there are 100 elements in a. 503 | Dialogue: 0,0:39:05.60,0:39:13.29,Default,,0,0,0,,and if I finger flipson the keyborad and I write a 1000, all kinds of bad things will happen 504 | Dialogue: 0,0:39:14.39,0:39:17.09,Default,,0,0,0,,if it's a variable it gets more interesting 505 | Dialogue: 0,0:39:17.19,0:39:18.84,Default,,0,0,0,,for array_view 506 | Dialogue: 0,0:39:20.02,0:39:20.64,Default,,0,0,0,,well 507 | Dialogue: 0,0:39:20.80,0:39:25.92,Default,,0,0,0,,you can just say it was an array_view or you can rely on the conversion of an array to an array_view 508 | Dialogue: 0,0:39:26.14,0:39:32.40,Default,,0,0,0,,it just socks on that array, makes it into array_view, having the size deduced 509 | Dialogue: 0,0:39:32.88,0:39:36.85,Default,,0,0,0,,if you are going to call it on a value. 510 | Dialogue: 0,0:39:37.12,0:39:45.99,Default,,0,0,0,,it's fairly easy to check agains the array of values there, if not you are on errors as often, 511 | Dialogue: 0,0:39:46.15,0:39:50.80,Default,,0,0,0,,so this follows the idea of make simple things simple 512 | Dialogue: 0,0:39:51.09,0:39:55.83,Default,,0,0,0,,and array_view is roughly the same as (int*p,int n); 513 | Dialogue: 0,0:39:56.13,0:39:59.91,Default,,0,0,0,,but we can use it easier and make few mistakes. 514 | Dialogue: 0,0:40:00.84,0:40:06.49,Default,,0,0,0,,nullptr. deal with it simply by saying what we mean. 515 | Dialogue: 0,0:40:06.61,0:40:09.78,Default,,0,0,0,,the problem is , today , we don't say what we mean. 516 | Dialogue: 0,0:40:09.85,0:40:12.21,Default,,0,0,0,,I have f(char*) 517 | Dialogue: 0,0:40:12.74,0:40:15.60,Default,,0,0,0,,is it alright to call it with nullptr ? 518 | Dialogue: 0,0:40:16.37,0:40:17.78,Default,,0,0,0,,where does it say so? 519 | Dialogue: 0,0:40:18.16,0:40:20.58,Default,,0,0,0,,in the documentation, OK. 520 | Dialogue: 0,0:40:20.84,0:40:26.05,Default,,0,0,0,,compiler don't read document and neither do I when I hear it 521 | Dialogue: 0,0:40:26.16,0:40:27.17,Default,,0,0,0,,not a good thing. 522 | Dialogue: 0,0:40:27.41,0:40:29.21,Default,,0,0,0,,when I implementing f(). 523 | Dialogue: 0,0:40:29.27,0:40:33.08,Default,,0,0,0,,should I turst my users (that they will) follow the rules or not? 524 | Dialogue: 0,0:40:33.69,0:40:34.95,Default,,0,0,0,,should I test (against parameter)? 525 | Dialogue: 0,0:40:36.65,0:40:38.04,Default,,0,0,0,,if I test, I test too much 526 | Dialogue: 0,0:40:38.04,0:40:40.51,Default,,0,0,0,,because that's a waste of resources. 527 | Dialogue: 0,0:40:40.52,0:40:42.39,Default,,0,0,0,,If I test too little, it'll crash. 528 | Dialogue: 0,0:40:42.49,0:40:45.09,Default,,0,0,0,,there're all kinds of things about that. 529 | Dialogue: 0,0:40:45.09,0:40:48.31,Default,,0,0,0,,so, one way to dealing with it is that we use not_null. 530 | Dialogue: 0,0:40:48.37,0:40:53.11,Default,,0,0,0,,currently that's a class that will test whether it's null or not. 531 | Dialogue: 0,0:40:53.25,0:40:57.01,Default,,0,0,0,,but a lot of it can be eliminated and can be debug only. 532 | Dialogue: 0,0:40:57.09,0:41:02.01,Default,,0,0,0,,so if nullptr is an error it toke f(not_null) 533 | Dialogue: 0,0:41:02.32,0:41:12.05,Default,,0,0,0,,and little bit saddle here. if you pass a variable that is not a pointer. that requires checking 534 | Dialogue: 0,0:41:12.31,0:41:17.68,Default,,0,0,0,,but now we write f() we don't need to do the checking 535 | Dialogue: 0,0:41:17.89,0:41:27.71,Default,,0,0,0,,so it's simplier and more class. it makes the code more explict, it detects a paticular specific well known problem. 536 | Dialogue: 0,0:41:28.07,0:41:32.00,Default,,0,0,0,,thers's many ways to the tagging most problem this is the one way we choose for those. 537 | Dialogue: 0,0:41:32.29,0:41:35.37,Default,,0,0,0,,so we go after bugs 538 | Dialogue: 0,0:41:35.43,0:41:37.97,Default,,0,0,0,,we provide type and resource safety 539 | Dialogue: 0,0:41:38.34,0:41:44.60,Default,,0,0,0,,now we can go after other problems 540 | Dialogue: 0,0:41:44.61,0:41:45.47,Default,,0,0,0,,logic errors 541 | Dialogue: 0,0:41:45.47,0:41:47.69,Default,,0,0,0,,performance bugs, maintenance hassles 542 | Dialogue: 0,0:41:47.69,0:41:49.57,Default,,0,0,0,,there are rules going there. 543 | Dialogue: 0,0:41:49.57,0:41:55.01,Default,,0,0,0,,but there are not as complete as things for extending the type-system. 544 | Dialogue: 0,0:41:55.22,0:42:03.21,Default,,0,0,0,,one thing we noticed is that there is a lot of over use of smart pointers. 545 | Dialogue: 0,0:42:03.21,0:42:10.16,Default,,0,0,0,,i noticed a lot of shared_ptr been used simply to return a value from a function 546 | Dialogue: 0,0:42:10.87,0:42:18.77,Default,,0,0,0,,so the use count goes from zero to 1 and 1 to 2 and 2 to 1 and to 0 547 | Dialogue: 0,0:42:18.77,0:42:28.40,Default,,0,0,0,,and all we did is to get something transferd simply because people didn't trust ordinary pointers 548 | Dialogue: 0,0:42:28.40,0:42:33.23,Default,,0,0,0,,quiet resonably so because all ordinary pointers might dangle 549 | Dialogue: 0,0:42:34.18,0:42:35.51,Default,,0,0,0,,wait a minite! 550 | Dialogue: 0,0:42:35.71,0:42:37.34,Default,,0,0,0,,we just solved that problem! 551 | Dialogue: 0,0:42:37.34,0:42:41.32,Default,,0,0,0,,so we have to re-think the way we're using smart pointers 552 | Dialogue: 0,0:42:41.32,0:42:43.08,Default,,0,0,0,,shared_ptr in paticular 553 | Dialogue: 0,0:42:43.31,0:42:45.65,Default,,0,0,0,,and my feeling is that they over used it. 554 | Dialogue: 0,0:42:45.80,0:42:51.20,Default,,0,0,0,,a lot of protection in shared_ptr when used int that way is just a overhead. 555 | Dialogue: 0,0:42:51.29,0:42:58.32,Default,,0,0,0,,because once the bugs have gone you don't have to have the use count anymore. 556 | Dialogue: 0,0:42:58.32,0:43:02.40,Default,,0,0,0,,but it sits there forever counting what ever you called and passed a smart pointer 557 | Dialogue: 0,0:43:02.85,0:43:05.22,Default,,0,0,0,,{\s1}with smart pointers{\s0} 558 | Dialogue: 0,0:43:05.50,0:43:12.40,Default,,0,0,0,,with dangling pointers eliminated by tools you don't need to do that. 559 | Dialogue: 0,0:43:12.53,0:43:15.40,Default,,0,0,0,,I'm going to show a little bit about it. 560 | Dialogue: 0,0:43:15.77,0:43:21.05,Default,,0,0,0,,so here are the alternatives, in the standard we can take a T* 561 | Dialogue: 0,0:43:22.69,0:43:24.95,Default,,0,0,0,,doesn't deal with ownership just a pointer 562 | Dialogue: 0,0:43:25.13,0:43:26.41,Default,,0,0,0,,just use the pointer 563 | Dialogue: 0,0:43:26.66,0:43:27.97,Default,,0,0,0,,with the rules here. 564 | Dialogue: 0,0:43:28.04,0:43:33.32,Default,,0,0,0,,we know that f(T*) will not delete T. 565 | Dialogue: 0,0:43:33.45,0:43:35.85,Default,,0,0,0,,the rules will stop that 566 | Dialogue: 0,0:43:36.04,0:43:38.03,Default,,0,0,0,,it just point to something 567 | Dialogue: 0,0:43:38.56,0:43:42.68,Default,,0,0,0,,if we want to transfer ownership we can use unique_ptr 568 | Dialogue: 0,0:43:42.85,0:43:44.95,Default,,0,0,0,,if we really want to share ownership 569 | Dialogue: 0,0:43:45.17,0:43:47.70,Default,,0,0,0,,we can use shared_ptr 570 | Dialogue: 0,0:43:48.06,0:43:55.05,Default,,0,0,0,,but if we look at the T* it is familer, it's very general. 571 | Dialogue: 0,0:43:55.47,0:44:00.29,Default,,0,0,0,,if I have shared_ptr, I can take the pointer out of it and give it to f(); 572 | Dialogue: 0,0:44:00.48,0:44:02.95,Default,,0,0,0,,I don't have to do anything fancy. 573 | Dialogue: 0,0:44:03.30,0:44:05.53,Default,,0,0,0,,no dangling pointers 574 | Dialogue: 0,0:44:05.79,0:44:13.32,Default,,0,0,0,,and think about pointers degenerate things and it works 575 | Dialogue: 0,0:44:13.64,0:44:15.69,Default,,0,0,0,,so here is an example 576 | Dialogue: 0,0:44:16.19,0:44:21.97,Default,,0,0,0,,if g() and h() has been written using different kinds of pointers 577 | Dialogue: 0,0:44:22.36,0:44:30.49,Default,,0,0,0,,if I make it, f(shared_ptr), if I make a shared_ptr with make_shared 578 | Dialogue: 0,0:44:30.78,0:44:35.78,Default,,0,0,0,,then to call f(), I have to get the pointer 579 | Dialogue: 0,0:44:35.88,0:44:43.10,Default,,0,0,0,,if I'm calling g(), we have the overhead of using pointers 580 | Dialogue: 0,0:44:43.21,0:44:54.73,Default,,0,0,0,,and the h() I really have to modify. because if I pass the ownership in, I have to pass it out again unless I want it to be destoryed in h() 581 | Dialogue: 0,0:44:54.81,0:44:57.22,Default,,0,0,0,,so we can keep things simpler now 582 | Dialogue: 0,0:44:57.44,0:45:02.19,Default,,0,0,0,,simply use f(X*) as we always did. 583 | Dialogue: 0,0:45:03.71,0:45:09.39,Default,,0,0,0,,one question I've had quiet resonably is would the rules be enforced by a compiler? 584 | Dialogue: 0,0:45:09.84,0:45:12.15,Default,,0,0,0,,some could, some can't 585 | Dialogue: 0,0:45:12.72,0:45:15.91,Default,,0,0,0,,on the other hand, I would like to use thiese rules now. 586 | Dialogue: 0,0:45:16.14,0:45:19.55,Default,,0,0,0,,And I would like to use for all of the compilers 587 | Dialogue: 0,0:45:19.69,0:45:28.61,Default,,0,0,0,,so, yes, it'll be nice if the compiler would use some of these rules 588 | Dialogue: 0,0:45:28.67,0:45:29.24,Default,,0,0,0,,but 589 | Dialogue: 0,0:45:29.76,0:45:32.62,Default,,0,0,0,,please be careful don't have false positives 590 | Dialogue: 0,0:45:32.62,0:45:34.07,Default,,0,0,0,,people hate false positives 591 | Dialogue: 0,0:45:34.07,0:45:35.91,Default,,0,0,0,,and that destoryes the whole system 592 | Dialogue: 0,0:45:36.43,0:45:38.64,Default,,0,0,0,,because people does surprising things 593 | Dialogue: 0,0:45:38.84,0:45:40.34,Default,,0,0,0,,and not worrying it 594 | Dialogue: 0,0:45:40.41,0:45:41.67,Default,,0,0,0,,and further more 595 | Dialogue: 0,0:45:41.78,0:45:48.00,Default,,0,0,0,,an external tool is not just useful accross the span of compilers 596 | Dialogue: 0,0:45:48.57,0:45:52.69,Default,,0,0,0,,it also can tolerate a few more false positives 597 | Dialogue: 0,0:45:53.07,0:45:59.46,Default,,0,0,0,,and it can handle changes more easily 598 | Dialogue: 0,0:46:00.60,0:46:05.76,Default,,0,0,0,,you can use a compiler that enforce rules or the compiler are using false rules. 599 | Dialogue: 0,0:46:06.20,0:46:07.69,Default,,0,0,0,,having an external tool helps 600 | Dialogue: 0,0:46:07.69,0:46:09.93,Default,,0,0,0,,so let's start with an external tool. 601 | Dialogue: 0,0:46:10.01,0:46:15.24,Default,,0,0,0,,and if the compiler writers get interested, that's so much better 602 | Dialogue: 0,0:46:15.67,0:46:18.48,Default,,0,0,0,,and the other things 603 | Dialogue: 0,0:46:18.65,0:46:22.82,Default,,0,0,0,,why didn't we just use the standard only? 604 | Dialogue: 0,0:46:23.20,0:46:31.47,Default,,0,0,0,,because the standard currently as a stand doesn't have all the rules that we want for the standard for the GSL(the guideline library) 605 | Dialogue: 0,0:46:31.59,0:46:33.88,Default,,0,0,0,,we want to use things now! 606 | Dialogue: 0,0:46:34.57,0:46:38.76,Default,,0,0,0,,It's tiny, portable C++11 607 | Dialogue: 0,0:46:39.16,0:46:41.57,Default,,0,0,0,,it doesn't depend on other libraries. free-standing. 608 | Dialogue: 0,0:46:41.57,0:46:45.38,Default,,0,0,0,,you don't have to include whole broad of things you don't need. 609 | Dialogue: 0,0:46:48.30,0:46:52.01,Default,,0,0,0,,it's a similar tool but not identical to boost:: and experimental:: components 610 | Dialogue: 0,0:46:52.10,0:46:55.98,Default,,0,0,0,,that's actually good chance that it will become in some form or other. 611 | Dialogue: 0,0:46:55.98,0:46:57.36,Default,,0,0,0,,but we are not going to wait 612 | Dialogue: 0,0:46:57.46,0:46:58.90,Default,,0,0,0,,this is too simple 613 | Dialogue: 0,0:46:58.96,0:47:01.35,Default,,0,0,0,,too easy, let's get going. 614 | Dialogue: 0,0:47:01.35,0:47:02.33,Default,,0,0,0,,it's on github. 615 | Dialogue: 0,0:47:02.33,0:47:05.88,Default,,0,0,0,,some of you've accessed yesterday or the day before. 616 | Dialogue: 0,0:47:06.22,0:47:08.93,Default,,0,0,0,,and we use standard library 617 | Dialogue: 0,0:47:09.52,0:47:21.63,Default,,0,0,0,,one of the things that you find with reasonably comprehensive or reasonably good old rules set is that there's too many rules. 618 | Dialogue: 0,0:47:22.02,0:47:27.64,Default,,0,0,0,,we need to help novices, experts, people with infrastructures, applicaions, 619 | Dialogue: 0,0:47:27.64,0:47:27.80,Default,,0,0,0,,{\pos(287,363)}da 620 | Dialogue: 0,0:47:27.80,0:47:28.01,Default,,0,0,0,,{\pos(273,367)}da 621 | Dialogue: 0,0:47:28.01,0:47:28.13,Default,,0,0,0,,{\pos(241,360)}da 622 | Dialogue: 0,0:47:28.13,0:47:28.33,Default,,0,0,0,,{\pos(215,349)}da 623 | Dialogue: 0,0:47:28.33,0:47:28.47,Default,,0,0,0,,{\pos(157,361)}da 624 | Dialogue: 0,0:47:28.47,0:47:28.84,Default,,0,0,0,,{\pos(128,374)}da 625 | Dialogue: 0,0:47:29.10,0:47:33.08,Default,,0,0,0,,there are no way you can remember all of those rules 626 | Dialogue: 0,0:47:33.26,0:47:34.60,Default,,0,0,0,,further more 627 | Dialogue: 0,0:47:34.91,0:47:38.78,Default,,0,0,0,,I think I have 350 by now for this and no at the end. 628 | Dialogue: 0,0:47:38.99,0:47:41.34,Default,,0,0,0,,these's too many and you won't even need to go and read them. 629 | Dialogue: 0,0:47:41.45,0:47:47.44,Default,,0,0,0,,and, or, more interstingly, you don't need all those rules 630 | Dialogue: 0,0:47:48.67,0:47:51.76,Default,,0,0,0,,Most of you do it anyway, we don't make that mistakes 631 | Dialogue: 0,0:47:51.87,0:47:53.52,Default,,0,0,0,,that we relearned that 10 years ago 632 | Dialogue: 0,0:47:53.52,0:47:55.15,Default,,0,0,0,,so that all exist 633 | Dialogue: 0,0:47:54.79,0:47:56.81,Default,,0,0,0,,every body knows it. 634 | Dialogue: 0,0:47:57.02,0:47:57.89,Default,,0,0,0,,on the other hand 635 | Dialogue: 0,0:47:57.89,0:48:00.97,Default,,0,0,0,,the rules are for the people that don't know it 636 | Dialogue: 0,0:48:01.05,0:48:10.91,Default,,0,0,0,,the novices, the people that are casual users, people that has fifteen years experience on a different kind of code base. things like that, that's what the rules for. 637 | Dialogue: 0,0:48:11.27,0:48:15.43,Default,,0,0,0,,and you can't sit wasting your time programming 638 | Dialogue: 0,0:48:15.63,0:48:18.11,Default,,0,0,0,,trying to remember the rules or looking them up. 639 | Dialogue: 0,0:48:18.11,0:48:19.32,Default,,0,0,0,,NO! 640 | Dialogue: 0,0:48:19.37,0:48:23.05,Default,,0,0,0,,further more, you won't get there because the rules are extensible. 641 | Dialogue: 0,0:48:23.05,0:48:25.15,Default,,0,0,0,,as we learned we add rules 642 | Dialogue: 0,0:48:25.34,0:48:28.19,Default,,0,0,0,,so if last month you wrote something, 643 | Dialogue: 0,0:48:28.38,0:48:31.72,Default,,0,0,0,,and you fulfill all the rules and this month you try again. 644 | Dialogue: 0,0:48:32.16,0:48:35.40,Default,,0,0,0,,we hope to catch you again with some new rules. 645 | Dialogue: 0,0:48:35.68,0:48:44.53,Default,,0,0,0,,that verified priciple, valided by experience will be helpful 646 | Dialogue: 0,0:48:44.81,0:48:49.36,Default,,0,0,0,,and you shouldn't know all the rules, the tool knows the rules. 647 | Dialogue: 0,0:48:49.52,0:48:56.35,Default,,0,0,0,,my idea is that you run the tool and it drop you right in there showing the rule on the screen. 648 | Dialogue: 0,0:48:57.24,0:48:59.28,Default,,0,0,0,,what was the rule that violated? 649 | Dialogue: 0,0:48:59.28,0:49:00.96,Default,,0,0,0,,where was it violated? 650 | Dialogue: 0,0:49:00.96,0:49:02.91,Default,,0,0,0,,what's the rational for the rule? 651 | Dialogue: 0,0:49:02.91,0:49:07.48,Default,,0,0,0,,what's the example of how bad it can get from problems like that? 652 | Dialogue: 0,0:49:07.54,0:49:09.31,Default,,0,0,0,,and here is what you should do instead. 653 | Dialogue: 0,0:49:09.39,0:49:10.93,Default,,0,0,0,,That's what I would like to see. 654 | Dialogue: 0,0:49:12.75,0:49:15.32,Default,,0,0,0,,so thers is too many rules that doesn't worry me. 655 | Dialogue: 0,0:49:15.40,0:49:16.96,Default,,0,0,0,,I want lots of rules. 656 | Dialogue: 0,0:49:17.47,0:49:21.45,Default,,0,0,0,,here is a set of classification 657 | Dialogue: 0,0:49:21.62,0:49:23.66,Default,,0,0,0,,there is philosophical rules 658 | Dialogue: 0,0:49:23.80,0:49:26.33,Default,,0,0,0,,basically the conceptual framework 659 | Dialogue: 0,0:49:26.59,0:49:28.66,Default,,0,0,0,,that cannot be validated 660 | Dialogue: 0,0:49:28.70,0:49:32.73,Default,,0,0,0,,but it's really good if you understood what been said there. 661 | Dialogue: 0,0:49:33.33,0:49:36.98,Default,,0,0,0,,if nothing else you'll know what we were thinking when we wrote them 662 | Dialogue: 0,0:49:37.61,0:49:43.04,Default,,0,0,0,,and then there's all kinds of things, interfaces, functions, classes, class hierarchies 663 | Dialogue: 0,0:49:43.04,0:49:43.19,Default,,0,0,0,,{\pos(48,248)}da 664 | Dialogue: 0,0:49:43.19,0:49:43.42,Default,,0,0,0,,{\pos(39,269)}da 665 | Dialogue: 0,0:49:43.42,0:49:43.55,Default,,0,0,0,,{\pos(66,314)}da 666 | Dialogue: 0,0:49:43.56,0:49:43.77,Default,,0,0,0,,{\pos(24,408)}da 667 | Dialogue: 0,0:49:43.75,0:49:43.90,Default,,0,0,0,,{\pos(69,423)}da 668 | Dialogue: 0,0:49:43.90,0:49:44.16,Default,,0,0,0,,{\pos(100,437)}da 669 | Dialogue: 0,0:49:45.27,0:49:48.50,Default,,0,0,0,, there's supporting sections, naming and layout 670 | Dialogue: 0,0:49:48.50,0:49:53.89,Default,,0,0,0,,that's where every body goes and they say they don't like the rules we wrote that's fine. 671 | Dialogue: 0,0:49:53.89,0:49:57.44,Default,,0,0,0,,never made anybody that the whole set of rules 672 | Dialogue: 0,0:49:57.56,0:49:59.66,Default,,0,0,0,,people say that they want camel case. 673 | Dialogue: 0,0:49:59.82,0:50:01.95,Default,,0,0,0,,sure, I hate camel case 674 | Dialogue: 0,0:50:02.07,0:50:03.17,Default,,0,0,0,,apart from that. 675 | Dialogue: 0,0:50:03.26,0:50:06.96,Default,,0,0,0,,what that c# camel case or java camel case ? 676 | Dialogue: 0,0:50:08.45,0:50:09.94,Default,,0,0,0,,there's just too much of it 677 | Dialogue: 0,0:50:09.99,0:50:11.68,Default,,0,0,0,,there's rules for performence. 678 | Dialogue: 0,0:50:11.68,0:50:13.68,Default,,0,0,0,,some people interested in performence 679 | Dialogue: 0,0:50:13.68,0:50:15.64,Default,,0,0,0,,there's different kinds of performence 680 | Dialogue: 0,0:50:15.73,0:50:23.22,Default,,0,0,0,,some of these rules, you can go up and look at today now. but some of the areas are weak. 681 | Dialogue: 0,0:50:23.29,0:50:25.76,Default,,0,0,0,,the guidence for standard library is weak 682 | Dialogue: 0,0:50:26.04,0:50:30.02,Default,,0,0,0,,the standard for concurrency is fairly weak 683 | Dialogue: 0,0:50:30.31,0:50:32.85,Default,,0,0,0,,because we hadn't have enough time 684 | Dialogue: 0,0:50:32.88,0:50:39.83,Default,,0,0,0,,this as a project that infact started in April and we are shipping now. 685 | Dialogue: 0,0:50:41.91,0:50:48.27,Default,,0,0,0,,This talk is trying to encourage you to help, to make it a community, a large community project 686 | Dialogue: 0,0:50:48.45,0:50:52.20,Default,,0,0,0,,it is not some kind of polished academic things we'd like to 687 | Dialogue: 0,0:50:52.20,0:50:56.02,Default,,0,0,0,,if we love to prove greate levels then this is the right thing 688 | Dialogue: 0,0:50:56.34,0:51:02.29,Default,,0,0,0,,no, this is an attempt to do something major and something interesting. 689 | Dialogue: 0,0:51:02.29,0:51:04.24,Default,,0,0,0,,this is not unambitious 690 | Dialogue: 0,0:51:04.65,0:51:16.52,Default,,0,0,0,,we're trying to scale to the 4+ million c++ programmers and a few billion lines of code while not break the zero-overhead principle. 691 | Dialogue: 0,0:51:17.25,0:51:19.35,Default,,0,0,0,,so the code will be better 692 | Dialogue: 0,0:51:20.11,0:51:25.96,Default,,0,0,0,,no type errors, no resource leaks, no dangling pointers 693 | Dialogue: 0,0:51:25.96,0:51:26.08,Default,,0,0,0,,{\pos(290,406)}da 694 | Dialogue: 0,0:51:26.08,0:51:26.27,Default,,0,0,0,,{\pos(301,402)}da 695 | Dialogue: 0,0:51:26.27,0:51:26.39,Default,,0,0,0,,{\pos(323,397)}da 696 | Dialogue: 0,0:51:26.40,0:51:26.71,Default,,0,0,0,,{\pos(319,407)}da 697 | Dialogue: 0,0:51:26.62,0:51:32.76,Default,,0,0,0,,we go after our least favorite bugs 698 | Dialogue: 0,0:51:34.44,0:51:38.85,Default,,0,0,0,,so it's a full speed ahead, and we expect some rough waters 699 | Dialogue: 0,0:51:39.30,0:51:44.18,Default,,0,0,0,,if you are thinking of a sailing ship you can actually sail faster if there is a storm going on 700 | Dialogue: 0,0:51:44.50,0:51:46.24,Default,,0,0,0,,what's what we're headding into. 701 | Dialogue: 0,0:51:46.61,0:51:51.03,Default,,0,0,0,,we actually aim to change the way we write code 702 | Dialogue: 0,0:51:51.52,0:51:53.52,Default,,0,0,0,,and that means {\b1}YOU{\b0}. 703 | Dialogue: 0,0:51:54.96,0:52:00.20,Default,,0,0,0,,what would you like your code to look like in 5 or 10 years? 704 | Dialogue: 0,0:52:01.30,0:52:07.01,Default,,0,0,0,,and really honestly if the answer is {\i1}just like what I wrote yesterday{\i0} 705 | Dialogue: 0,0:52:07.51,0:52:10.13,Default,,0,0,0,,there are some failling imagination here. 706 | Dialogue: 0,0:52:10.45,0:52:12.69,Default,,0,0,0,,we really want to make change 707 | Dialogue: 0,0:52:12.69,0:52:14.00,Default,,0,0,0,,that can be painful 708 | Dialogue: 0,0:52:14.53,0:52:21.01,Default,,0,0,0,,it's not easy to modernize code, it's not easy to modernize a large codebase, it is painful 709 | Dialogue: 0,0:52:21.57,0:52:27.11,Default,,0,0,0,,but, you know, if you don't do it. you have the same pain from your existing code 710 | Dialogue: 0,0:52:27.47,0:52:30.94,Default,,0,0,0,,that now 10 years old code in 5 years will be 15 years old!] 711 | Dialogue: 0,0:52:30.94,0:52:32.94,Default,,0,0,0,, and it is not going to feel any better! 712 | Dialogue: 0,0:52:33.87,0:52:40.11,Default,,0,0,0,,and gradual adaption, of course is nessesary for this. 713 | Dialogue: 0,0:52:40.34,0:52:52.24,Default,,0,0,0,,the idea of taking 5 million lines of codebase and saying, ok we just change this, and after the weekend we'll use the new version 714 | Dialogue: 0,0:52:52.26,0:52:53.56,Default,,0,0,0,,hmmm... 715 | Dialogue: 0,0:52:53.81,0:52:55.93,Default,,0,0,0,,probably not. 716 | Dialogue: 0,0:52:56.18,0:53:01.12,Default,,0,0,0,,we will not agree what the code should look like so there'll be some discussions. 717 | Dialogue: 0,0:53:01.55,0:53:04.70,Default,,0,0,0,,part of it will be, that not all code should look the same 718 | Dialogue: 0,0:53:05.15,0:53:15.01,Default,,0,0,0,,I really don't want work under constraints from my flight control software when I'm writting ordinary applications, it just too painful 719 | Dialogue: 0,0:53:15.19,0:53:19.16,Default,,0,0,0,,on the other hand there'll be discussion about what is common and what isn't. 720 | Dialogue: 0,0:53:19.28,0:53:24.69,Default,,0,0,0,,if you look at the rules you'll find that some of them are some what controversial. 721 | Dialogue: 0,0:53:24.95,0:53:26.56,Default,,0,0,0,,and that's fine. 722 | Dialogue: 0,0:53:27.66,0:53:29.22,Default,,0,0,0,,I just choose what I'm presume right answer. 723 | Dialogue: 0,0:53:29.36,0:53:32.38,Default,,0,0,0,,if you don't agree, I'll willing to argue with you. 724 | Dialogue: 0,0:53:32.53,0:53:34.54,Default,,0,0,0,,so that's going to be fun! 725 | Dialogue: 0,0:53:34.91,0:53:36.85,Default,,0,0,0,,and help wanted 726 | Dialogue: 0,0:53:36.97,0:53:39.94,Default,,0,0,0,,look at the rules, help reviewing them 727 | Dialogue: 0,0:53:40.26,0:53:42.34,Default,,0,0,0,,help man suggest new rules 728 | Dialogue: 0,0:53:42.34,0:53:45.15,Default,,0,0,0,,help suggest better explanation of the rules 729 | Dialogue: 0,0:53:46.03,0:53:49.42,Default,,0,0,0,,currently there's only two editors of this, me and Herb Sutter. 730 | Dialogue: 0,0:53:49.69,0:53:52.23,Default,,0,0,0,,that is too lower number. 731 | Dialogue: 0,0:53:52.23,0:53:54.11,Default,,0,0,0,,so we need more editors 732 | Dialogue: 0,0:53:54.19,0:53:57.08,Default,,0,0,0,,but you have to earn your right to be an editor 733 | Dialogue: 0,0:53:57.08,0:54:01.76,Default,,0,0,0,,that's a crucial positon in the community 734 | Dialogue: 0,0:54:01.97,0:54:05.58,Default,,0,0,0,,so the current status, about 350 rules. 735 | Dialogue: 0,0:54:05.92,0:54:07.88,Default,,0,0,0,,and there's a github for it 736 | Dialogue: 0,0:54:08.80,0:54:12.30,Default,,0,0,0,,we put it live I think friday 737 | Dialogue: 0,0:54:12.92,0:54:16.55,Default,,0,0,0,,and we already getting pull requests. 738 | Dialogue: 0,0:54:16.80,0:54:20.79,Default,,0,0,0,,and thers's guidelines support library. 739 | Dialogue: 0,0:54:20.90,0:54:28.56,Default,,0,0,0,,tested on clang, gcc, microsoft on windows, linux and mac 740 | Dialogue: 0,0:54:28.68,0:54:30.80,Default,,0,0,0,,it's avaliable now 741 | Dialogue: 0,0:54:30.90,0:54:32.84,Default,,0,0,0,,the first tool should come 742 | Dialogue: 0,0:54:32.86,0:54:35.68,Default,,0,0,0,,microsoft is shipping something I think next month 743 | Dialogue: 0,0:54:35.81,0:54:38.72,Default,,0,0,0,,I don't know their shipping schedules so it can't be percise. 744 | Dialogue: 0,0:54:38.90,0:54:44.92,Default,,0,0,0,,and we hope ports to the other systems comming right after. 745 | Dialogue: 0,0:54:45.09,0:54:54.66,Default,,0,0,0,,it's written as fairly intentive portable iso c++, so that should work. 746 | Dialogue: 0,0:54:55.02,0:54:57.10,Default,,0,0,0,,and we need help 747 | Dialogue: 0,0:54:57.79,0:54:59.06,Default,,0,0,0,,and 748 | Dialogue: 0,0:54:59.43,0:55:05.03,Default,,0,0,0,,this paper, from my perspective means, that the basic c++ model is actually complete 749 | Dialogue: 0,0:55:05.54,0:55:22.90,Default,,0,0,0,,hours going for the idea that you could get perfect resource safety and type safety now have been trying to get there for many many years, it was the idea from day 1 and I knew we couldn't get there in any time soon, I think we are there (now) 750 | Dialogue: 0,0:55:24.87,0:55:25.86,Default,,0,0,0,,BTW 751 | Dialogue: 0,0:55:25.86,0:55:28.35,Default,,0,0,0,,if you look at my definition of resource safety 752 | Dialogue: 0,0:55:28.58,0:55:32.61,Default,,0,0,0,,you'll see that it's really not very many languages that can claim that. 753 | Dialogue: 0,0:55:33.04,0:55:38.84,Default,,0,0,0,,and for static type safety, not very many languages can claim that. 754 | Dialogue: 0,0:55:39.26,0:55:46.91,Default,,0,0,0,,no range errors and dereference errors without serious overhead, more language can cliam that but it's still hard. 755 | Dialogue: 0,0:55:47.40,0:55:50.11,Default,,0,0,0,,this is not unambitious as I said 756 | Dialogue: 0,0:55:50.24,0:55:55.98,Default,,0,0,0,,we now have concepts so we can deal templates in a more resonable way 757 | Dialogue: 0,0:55:56.41,0:56:00.78,Default,,0,0,0,,so, with all of the problems solved from the resource point of view 758 | Dialogue: 0,0:56:01.04,0:56:04.13,Default,,0,0,0,,why didn't I just go back to academia and design a new language? 759 | Dialogue: 0,0:56:04.13,0:56:06.36,Default,,0,0,0,,That's after all what most people do right? 760 | Dialogue: 0,0:56:06.36,0:56:07.86,Default,,0,0,0,,it's a cool thing to do 761 | Dialogue: 0,0:56:08.07,0:56:09.27,Default,,0,0,0,,etc 762 | Dialogue: 0,0:56:09.25,0:56:11.66,Default,,0,0,0,,competing wieh c++ is hard 763 | Dialogue: 0,0:56:11.90,0:56:19.97,Default,,0,0,0,,I put these toolchains up there to show what anybody with a new languages are up against. 764 | Dialogue: 0,0:56:21.06,0:56:26.32,Default,,0,0,0,,competing with c++ has over the years not been the winning strategy 765 | Dialogue: 0,0:56:26.60,0:56:28.24,Default,,0,0,0,,and 766 | Dialogue: 0,0:56:28.45,0:56:30.33,Default,,0,0,0,,it'll take, take time 767 | Dialogue: 0,0:56:30.50,0:56:38.21,Default,,0,0,0,,and further more, certainly going into a new language could fracture the c++ community which is among the last thing I want to do. 768 | Dialogue: 0,0:56:38.98,0:56:41.37,Default,,0,0,0,,so, we're going for something that can work now! 769 | Dialogue: 0,0:56:41.92,0:56:46.06,Default,,0,0,0,,guidelines and tools, hope to get there. 770 | Dialogue: 0,0:56:46.41,0:56:59.04,Default,,0,0,0,,so, with that, I'll switch to questions and I left the outline of the guidelines up there. 771 | Dialogue: 0,0:56:59.14,0:57:00.48,Default,,0,0,0,,by the way 772 | Dialogue: 0,0:57:00.74,0:57:06.69,Default,,0,0,0,,what we called guide there is Helios, Hercules fighting the Hydra. 773 | Dialogue: 0,0:57:06.93,0:57:09.45,Default,,0,0,0,,this is a bit like what I feels like 774 | Dialogue: 0,0:57:09.62,0:57:14.39,Default,,0,0,0,,we have many-headed monster we have to fight. 775 | Dialogue: 0,0:57:14.56,0:57:19.20,Default,,0,0,0,,and there's a nasty tendency of getting more heads as we make progress 776 | Dialogue: 0,0:57:19.46,0:57:20.43,Default,,0,0,0,,so, thank you! 777 | Dialogue: 0,0:57:21.29,0:57:31.37,居中标题,,0,0,0,,~感谢 avplayer.org 制作英文字幕~ 778 | Dialogue: 0,0:57:33.10,0:57:36.61,Default,,0,0,0,,is there mic-phone somewhere? 779 | Dialogue: 0,0:57:37.81,0:57:43.87,演讲回答,,0,0,0,,OK, I am back. so the questions is "why do I mark the owner rather than non-owner?" 780 | Dialogue: 0,0:57:44.50,0:57:46.35,演讲回答,,0,0,0,,yes we discussed that 781 | Dialogue: 0,0:57:47.70,0:57:56.00,演讲回答,,0,0,0,,My conjecture is that there are too many hundreds of millions lines of code that uses T* to mean non-owner. 782 | Dialogue: 0,0:57:58.02,0:58:01.12,演讲回答,,0,0,0,,and I really don't want people to write very many owners. 783 | Dialogue: 0,0:58:01.21,0:58:04.03,演讲回答,,0,0,0,,I want the owers to disapper into abstractions 784 | Dialogue: 0,0:58:05.11,0:58:09.73,演讲回答,,0,0,0,,as for now, there are many more non-owners and owners 785 | Dialogue: 0,0:58:19.68,0:58:22.13,演讲回答,,0,0,0,,in the future, I expect there to be a thousand or more than a thousand times as many non-owners as owners in code 786 | Dialogue: 0,0:58:19.78,0:58:25.38,演讲回答,,0,0,0,,because pointers are now getting safer and you can use them more freely 787 | Dialogue: 0,0:58:25.54,0:58:30.40,演讲回答,,0,0,0,,so I think a got the owner/non-owner default correct. 788 | Dialogue: 0,0:58:30.50,0:58:37.33,演讲回答,,0,0,0,,maybe the first time in history of c++ we got default right. but I'm pretty sure this one is right! 789 | Dialogue: 0,0:58:39.46,0:58:40.64,Default,主持人,0,0,0,,{\pos(1673,414)}Question here 790 | Dialogue: 0,0:58:41.25,0:58:41.78,Default,,0,0,0,,{\pos(1702,218)}there 791 | Dialogue: 0,0:58:42.77,0:58:43.17,观众提问,,0,0,0,,Hi! 792 | Dialogue: 0,0:58:43.92,0:59:00.53,观众提问,,0,0,0,,I had a question about owner T. and one thing I was confused about is that, is owner T is just something that is used at compile time or does it use any sort of like runtime overhead or ? 793 | Dialogue: 0,0:59:00.53,0:59:05.44,演讲回答,,0,0,0,,it's something that used only at compile time and it does absolutely nothing (at runtime) 794 | Dialogue: 0,0:59:06.05,0:59:15.33,演讲回答,,0,0,0,,it is something that guides or an enforcement tool to see what you suppose to do with it. 795 | Dialogue: 0,0:59:15.49,0:59:18.79,演讲回答,,0,0,0,,in paticular, if you're not an owner, you're not suppose to delete it 796 | Dialogue: 0,0:59:19.02,0:59:21.01,演讲回答,,0,0,0,,you're not going to pass it to an owner. 797 | Dialogue: 0,0:59:21.33,0:59:23.41,演讲回答,,0,0,0,,if you are an owner. 798 | Dialogue: 0,0:59:23.44,0:59:28.93,演讲回答,,0,0,0,,you have better either give it to somebody else who is also an owner or delete it 799 | Dialogue: 0,0:59:29.62,0:59:33.38,演讲回答,,0,0,0,,a tool can verify that, it doesn't do anything. 800 | Dialogue: 0,0:59:33.73,0:59:37.84,演讲回答,,0,0,0,,you can encapsulated an owner into a, say, unique pointer. 801 | Dialogue: 0,0:59:38.05,0:59:42.67,演讲回答,,0,0,0,,and then just use it because it does the delete and has the right semantics 802 | Dialogue: 0,0:59:42.67,0:59:46.21,演讲回答,,0,0,0,,the owner is a low-level marker to help static analysis 803 | Dialogue: 0,0:59:46.44,0:59:55.62,演讲回答,,0,0,0,,I didn't mention but I sure static analysis is local, static analysis using very few rules, it's going to be fast 804 | Dialogue: 0,0:59:55.65,1:00:00.02,演讲回答,,0,0,0,,it's not one of these going to be in cute algorithm over all of your code 805 | Dialogue: 0,1:00:00.17,1:00:03.38,演讲回答,,0,0,0,,it is local rules 806 | Dialogue: 0,1:00:04.95,1:00:10.02,观众提问,,0,0,0,,What happens when you move from not null? 807 | Dialogue: 0,1:00:10.84,1:00:13.87,演讲回答,,0,0,0,,What happens when I move from not null? 808 | Dialogue: 0,1:00:14.52,1:00:15.50,演讲回答,,0,0,0,,into what? 809 | Dialogue: 0,1:00:15.70,1:00:25.94,观众提问,,0,0,0,,you moved and the remaining status becomes null, right? 810 | Dialogue: 0,1:00:26.21,1:00:27.45,演讲回答,,0,0,0,,emmm 811 | Dialogue: 0,1:00:31.26,1:00:38.13,演讲回答,,0,0,0,,if you move from a pointer. it's just a copy. so it doesn't become null 812 | Dialogue: 0,1:00:38.50,1:00:44.16,演讲回答,,0,0,0,,if you generalized it to smart pointers and such 813 | Dialogue: 0,1:00:44.27,1:00:53.00,演讲回答,,0,0,0,,it will have to have the appropriate semantics, I don't know the implementations there, you should ask Neil Macintosh on Wednesday 814 | Dialogue: 0,1:00:53.01,1:00:58.84,演讲回答,,0,0,0,,he is one of the editor of the last version of the implementation which I haven't read yet 815 | Dialogue: 0,1:00:58.95,1:01:01.54,演讲回答,,0,0,0,,he made some improvements last week 816 | Dialogue: 0,1:01:01.61,1:01:05.82,演讲回答,,0,0,0,,but basically, no, you can not violate not_null that easy 817 | Dialogue: 0,1:01:13.67,1:01:18.52,观众提问,,0,0,0,,I'm guessing 818 | Dialogue: 0,1:02:44.90,1:03:03.57,观众提问,,0,0,0,,总结起来就一句话: do you have guidelines for makeing C api safer in c++? 819 | Dialogue: 0,1:03:04.37,1:03:10.58,演讲回答,,0,0,0,,I have no plans of dealing with foreign systems. 820 | Dialogue: 0,1:03:10.67,1:03:14.77,演讲回答,,0,0,0,,that will not be in the core guidelines 821 | Dialogue: 0,1:03:15.17,1:03:34.76,演讲回答,,0,0,0,,but I wouldn't be at all surprised and I'll be very happy if somebody would write a section asist how to interact with *, how to interact java, how to interact with python, I really hope to see somebody write those sections. 822 | Dialogue: 0,1:03:34.87,1:03:41.56,演讲回答,,0,0,0,,quiet likely they will be of the form that you can do this the static analysis to make it simpler 823 | Dialogue: 0,1:03:41.67,1:03:47.44,演讲回答,,0,0,0,,you can have this tiny tiny little setup classes for doing the transmission 824 | Dialogue: 0,1:03:47.61,1:03:49.84,演讲回答,,0,0,0,, 825 | -------------------------------------------------------------------------------- /CppCon2015/CppCon 2015 Bjarne Stroustrup - Writing Good C++14.chs.ass: -------------------------------------------------------------------------------- 1 | [Script Info] 2 | ; Script generated by Aegisub 3.1.3 3 | ; http://www.aegisub.org/ 4 | Title: Default Aegisub file 5 | ScriptType: v4.00+ 6 | WrapStyle: 0 7 | ScaledBorderAndShadow: yes 8 | YCbCr Matrix: TV.601 9 | Last Style Storage: Default 10 | Aegisub Scroll Position: 3 11 | Aegisub Active Line: 15 12 | Aegisub Video Zoom Percent: 1.000000 13 | PlayResX: 1920 14 | PlayResY: 1080 15 | Audio URI: ../../../Videos/CppCon2015/BjarneStroustrupWritingGoodC++14.mp4 16 | Video File: ../../../Videos/CppCon2015/BjarneStroustrupWritingGoodC++14.mp4 17 | Aegisub Video Aspect Ratio: c1.777778 18 | Aegisub Video Position: 2832 19 | 20 | [V4+ Styles] 21 | Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding 22 | Style: Default,Courier New,55,&H00FF00FF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,3,3,2,10,10,20,1 23 | Style: 居中标题,文泉驿正黑,150,&H0097108D,&H000000FF,&H00000000,&H00F7A350,0,0,0,0,100,100,0,0,1,3,6,8,10,10,10,1 24 | Style: 观众提问,Arial,55,&H00FFFF00,&H000000FF,&H0000FFFF,&H00000000,0,0,0,0,100,100,0,0,1,1,1,2,10,10,10,1 25 | Style: 演讲回答,Arial,55,&H000000FF,&H00000000,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1 26 | 27 | [Events] 28 | Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text 29 | Dialogue: 0,0:00:00.00,0:00:07.10,居中标题,,0,0,0,,avplayer.org\n社区出品 30 | Comment: 0,0:00:05.00,0:00:07.00,Default,,0,0,0,,视频文件请到 http://pan.baidu.com/s/1pJquXBl 下载,提取码 2in6 31 | Dialogue: 0,0:00:00.00,0:00:02.04,Default,,0,0,0,,好, 可以开始了 32 | Dialogue: 0,0:00:05.41,0:00:10.45,Default,,0,0,0,,欢迎欢迎~看到那么多人我好兴奋啊~ 33 | Dialogue: 0,0:00:10.75,0:00:19.76,Default,,0,0,0,,特别是老朋友都在,还多了不少新朋友,我开心的紧张死了~ 34 | Dialogue: 0,0:00:20.19,0:00:27.90,Default,,0,0,0,,今天,我就来谈谈如何优美地写现代C++代码 35 | Dialogue: 0,0:00:28.23,0:00:39.16,Default,,0,0,0,,我想大家和我一样,都被一个问题困惑,到底什么是好的现代c++代码呢? 36 | Dialogue: 0,0:00:39.45,0:00:46.18,Default,,0,0,0,,过去的5年里,我们对c++做了不少手术 37 | Dialogue: 0,0:00:46.37,0:00:52.47,Default,,0,0,0,,一些人开始觉得自己知道咋写好c++了 38 | Dialogue: 0,0:00:52.74,0:00:55.74,Default,,0,0,0,,另外的人就开始追问了,“你知道?快告诉我啊” 39 | Dialogue: 0,0:00:55.74,0:01:04.02,Default,,0,0,0,,于是今春,我决定开一个项目,告诉大家咋写好c++ 40 | Dialogue: 0,0:01:04.05,0:01:09.46,Default,,0,0,0,,于是发现其他人也有些个想法咯 41 | Dialogue: 0,0:01:09.61,0:01:13.79,Default,,0,0,0,,于是我们来回答这个问题好了 42 | Dialogue: 0,0:01:14.04,0:01:27.32,Default,,0,0,0,,且慢,谨记我们在帮助超过4百万的c++程序员 43 | Dialogue: 0,0:01:27.57,0:01:34.16,Default,,0,0,0,,如果我们的办法仅有200个专家会用是没用的 44 | Dialogue: 0,0:01:34.47,0:01:42.20,Default,,0,0,0,,所以这个项目的目的是要帮助更多的人 45 | Dialogue: 0,0:01:42.57,0:01:46.56,Default,,0,0,0,,以及面前各位,现在我们有一个伟大的语言 46 | Dialogue: 0,0:01:46.65,0:01:52.74,Default,,0,0,0,,这是一个现代语言,它能做10~20年前我们做不到的酷事 47 | Dialogue: 0,0:01:52.79,0:01:59.63,Default,,0,0,0,,C++11非常酷,C++14更好。两者都在广泛的被使用中 48 | Dialogue: 0,0:01:59.63,0:02:02.09,Default,,0,0,0,,这些都不是玩具语言 49 | Dialogue: 0,0:02:02.24,0:02:08.61,Default,,0,0,0,,据我所了解的标准委员会正在制定的C++17使其更加完美 50 | Dialogue: 0,0:02:08.85,0:02:22.51,Default,,0,0,0,,他们正在制定相关规范文件以及退出新的概念 51 | Dialogue: 0,0:02:22.51,0:02:44.95,Default,,0,0,0,,因此,从我多年来的经验上认为,自从C++11之后将变得更容易实现、更容易维护、效率更高、阅读清晰、更精简 52 | Dialogue: 0,0:02:45.54,0:02:47.11,Default,,0,0,0,,这是一个事实 53 | Dialogue: 0,0:02:47.52,0:02:51.40,Default,,0,0,0,,实际上很少在做这样的事情 54 | Dialogue: 0,0:02:53.67,0:02:57.47,Default,,0,0,0,,也许你认识一千人在写这样的现代C++代码 55 | Dialogue: 0,0:02:57.74,0:03:02.86,Default,,0,0,0,,甚至你认识一万人正在写现代C++代码,但是他们始终还是很小的一部分 56 | Dialogue: 0,0:03:02.86,0:03:04.35,Default,,0,0,0,,我们必须要做的更好 57 | Dialogue: 0,0:03:04.35,0:03:10.78,Default,,0,0,0,,很多人在用SB的方式写C++ 58 | Dialogue: 0,0:03:11.23,0:03:16.20,Default,,0,0,0,,不信你去网上看,你会看到每个菜鸟都臆想自己是语音专家 59 | Dialogue: 0,0:03:16.20,0:03:20.40,Default,,0,0,0,,和谈论各种右值引用的语法问题 60 | Dialogue: 0,0:03:20.40,0:03:27.65,Default,,0,0,0,,这种问题存在于大多数代码中,除非你使用高性能库 61 | Dialogue: 0,0:03:27.65,0:03:34.68,Default,,0,0,0,,所以他们都纠结在语言本身从而迷失在技术细节中 62 | Dialogue: 0,0:03:35.11,0:03:43.55,Default,,0,0,0,,基本上的想法是:"医生,用锤子砸我的头会伤害到我的".显而易见的答案是"不要这样做!" 63 | Dialogue: 0,0:03:43.81,0:03:45.81,Default,,0,0,0,,而这正是我们想做的 64 | Dialogue: 0,0:03:46.93,0:03:49.05,Default,,0,0,0,,这句话是我曾经说过的—— 65 | Dialogue: 0,0:03:52.45,0:03:56.77,Default,,0,0,0,,C++语言有较小的又安全的语言,要努力发扬光大 66 | Dialogue: 0,0:03:56.77,0:04:02.50,Default,,0,0,0,,我想我当时说这句话的时候似乎是1994年还是1992年甚至更久之前了 67 | Dialogue: 0,0:04:02.75,0:04:05.78,Default,,0,0,0,,今天看来依然正确 68 | Dialogue: 0,0:04:05.93,0:04:12.63,Default,,0,0,0,,你可以简化代码你可以维持高效率,我们不限制你能说什么 69 | Dialogue: 0,0:04:12.63,0:04:14.24,Default,,0,0,0,,这些都是重要的事情 70 | Dialogue: 0,0:04:14.24,0:04:16.24,Default,,0,0,0,,这就是C Plus Plus! 71 | Dialogue: 0,0:04:16.24,0:04:21.11,Default,,0,0,0,,它也不是专为特殊应用程序设计的语言 72 | Dialogue: 0,0:04:21.73,0:04:25.34,Default,,0,0,0,,所以,让我们努力让它变得更好 73 | Dialogue: 0,0:04:25.57,0:04:30.84,Default,,0,0,0,,很多人用它发明了更好更简单的新编程语言 74 | Dialogue: 0,0:04:30.84,0:04:32.84,Default,,0,0,0,,但不是现在 75 | Dialogue: 0,0:04:32.84,0:04:42.18,Default,,0,0,0,,如果你发明的新语言在十年内都有很多人在使用它,那么就算成功了 76 | Dialogue: 0,0:04:42.36,0:04:48.97,Default,,0,0,0,,新的一般用途的编程语言能够成功收费盈利的可能性非常低 77 | Dialogue: 0,0:04:48.97,0:04:50.97,Default,,0,0,0,,所以,让我们现在就做! 78 | Dialogue: 0,0:04:51.20,0:04:53.91,Default,,0,0,0,,我想要使用这些编译器 79 | Dialogue: 0,0:04:53.91,0:04:59.92,Default,,0,0,0,,我的意思是,你能使用你的编译器使你的代码优化多少? 80 | Dialogue: 0,0:04:59.92,0:05:08.69,Default,,0,0,0,,doesn't matter which compiler you are using for a modern compiler and sort of standard hardware. 它是令人惊叹的。 81 | Dialogue: 0,0:05:08.90,0:05:15.69,Default,,0,0,0,,我的意思是我不确定十年内能否完成它,但是他们这样做了很长时间 82 | Dialogue: 0,0:05:15.69,0:05:23.70,Default,,0,0,0,,this doesn't just happen for a new language unless you can hijack the c++ code generation phase. which is a fair gain. 83 | Dialogue: 0,0:05:23.94,0:05:32.82,Default,,0,0,0,,因此,我们需要去制定编码准则,为那些想写现代C++代码的人引路 84 | Dialogue: 0,0:05:33.01,0:05:40.04,Default,,0,0,0,,并且,我应该告诉那些人什么事情不应该做 85 | Dialogue: 0,0:05:40.04,0:05:43.04,Default,,0,0,0,,所以你需要工具和库的支持 86 | Dialogue: 0,0:05:43.18,0:05:50.25,Default,,0,0,0,,而且我们想要程序通用、性能高、代码简单、程序轻简 87 | Dialogue: 0,0:05:50.25,0:05:54.77,Default,,0,0,0,,我目前不想让C++程序运行在特殊的硬件和软件中 88 | Dialogue: 0,0:05:55.05,0:05:56.52,Default,,0,0,0,,所有的人都绝不认输 89 | Dialogue: 0,0:05:56.52,0:06:02.78,Default,,0,0,0,,我认为我们能够做到,我们不是孤军奋战 90 | Dialogue: 0,0:06:02.78,0:06:06.50,Default,,0,0,0,,好吧,我知道确实有天才能办到 91 | Dialogue: 0,0:06:06.50,0:06:08.99,Default,,0,0,0,,但是我想我可以确定一点,没有任何人可以做到 92 | Dialogue: 0,0:06:09.14,0:06:11.97,Default,,0,0,0,,并且没有任何一家公司能够做到 93 | Dialogue: 0,0:06:12.11,0:06:17.39,Default,,0,0,0,,它将让我们认识到某些公司的特殊兴趣 94 | Dialogue: 0,0:06:17.39,0:06:19.15,Default,,0,0,0,,你完全不能相信这一切 95 | Dialogue: 0,0:06:19.15,0:06:27.14,Default,,0,0,0,,很久以前我开始就参加了C++标准制定大会,所以请大家帮忙 96 | Dialogue: 0,0:06:27.14,0:06:33.16,Default,,0,0,0,,我想要说一点关于能够帮助我们以及我们能够做到的事情 97 | Dialogue: 0,0:06:33.16,0:06:36.05,Default,,0,0,0,,所以应该从最原始的工作开始 98 | Dialogue: 0,0:06:36.05,0:06:39.39,Default,,0,0,0,,曾经有一个项目是来自于微软的Herb Sutter和他的朋友们 99 | Dialogue: 0,0:06:39.39,0:06:42.01,Default,,0,0,0,,我开始的时候是在Morgan Stanley 100 | Dialogue: 0,0:06:42.01,0:06:45.98,Default,,0,0,0,,欧洲核子研究中心(CERN)后来也加入,并作出了贡献 101 | Dialogue: 0,0:06:45.98,0:06:47.98,Default,,0,0,0,,他们提交的那些代码都可用 102 | Dialogue: 0,0:06:47.98,0:06:49.98,Default,,0,0,0,,他们的存在 103 | Dialogue: 0,0:06:49.98,0:06:55.06,Default,,0,0,0,,你能够在github上找到它,给你们一个url 104 | Dialogue: 0,0:06:55.06,0:06:58.29,Default,,0,0,0,,这里有一些准则,都在这上面 105 | Dialogue: 0,0:06:58.49,0:07:00.64,Default,,0,0,0,,还有支持一些轻量级的库 106 | Dialogue: 0,0:07:00.64,0:07:11.48,Default,,0,0,0,,那些大多是一些非常简答的类映射到标准库的东西,如果不直接映射到扩平台C++ 107 | Dialogue: 0,0:07:11.48,0:07:16.44,Default,,0,0,0,,便携式的意义 Microsoft, gcc, clang; Windows, Linux 108 | Dialogue: 0,0:07:16.53,0:07:17.64,Default,,0,0,0,,和mac. 109 | Dialogue: 0,0:07:17.97,0:07:25.52,Default,,0,0,0,,这是一个分析工具,它是由微软的一个家伙写的 110 | Dialogue: 0,0:07:25.53,0:07:38.24,Default,,0,0,0,,我们希望以后有可用的port,或许是十一月?我不知道,我的意思你们都明白软件项目时间易遭受延误。 111 | Dialogue: 0,0:07:38.42,0:07:41.09,Default,,0,0,0,,但是我们正在计划做这些事 112 | Dialogue: 0,0:07:43.13,0:07:46.58,Default,,0,0,0,,它已经存在了,所以你可以说我在胡扯 113 | Dialogue: 0,0:07:46.93,0:07:50.52,Default,,0,0,0,,它还获得了麻省理工学院授予使用许可,所以它非常开放和自由 114 | Dialogue: 0,0:07:50.52,0:07:51.44,Default,,0,0,0,,所以你可以轻松地得到它 115 | Dialogue: 0,0:07:51.88,0:07:54.10,Default,,0,0,0,,或者谈论更多关于此类内容 116 | Dialogue: 0,0:07:55.02,0:08:01.92,Default,,0,0,0,,我要去解释一下我们正在做的高级别条款和一些具体例子 117 | Dialogue: 0,0:08:02.17,0:08:04.88,Default,,0,0,0,,Herb Sutter 待会会说这些细节 118 | Dialogue: 0,0:08:05.23,0:08:13.32,Default,,0,0,0,,Gabriel Dos Reis 打算讨论一下具体怎么做,呃,联系标准委员会讨论编写更好的代码 119 | Dialogue: 0,0:08:13.32,0:08:21.84,Default,,0,0,0,,Neil Macintosh 写了一个工具,我们接下来会谈论一些关于类的静态分析 120 | Dialogue: 0,0:08:21.95,0:08:23.12,Default,,0,0,0,,这是所有的弱点 121 | Dialogue: 0,0:08:23.83,0:08:29.08,Default,,0,0,0,,这是代码准则的问题 122 | Dialogue: 0,0:08:29.33,0:08:30.44,Default,,0,0,0,,哪一个是... 123 | Dialogue: 0,0:08:30.45,0:08:32.65,Default,,0,0,0,,你见过一个你真的喜欢的吗? 124 | Dialogue: 0,0:08:32.92,0:08:37.18,Default,,0,0,0,,这可能是非常必要的,就像药,味道很不好喝 125 | Dialogue: 0,0:08:37.77,0:08:39.63,Default,,0,0,0,,我们都讨厌编码规则 126 | Dialogue: 0,0:08:39.79,0:08:44.83,Default,,0,0,0,,常见警告多亏那些菜鸟和SB 127 | Dialogue: 0,0:08:44.92,0:08:46.31,Default,,0,0,0,,但是基本上我们不喜欢它 128 | Dialogue: 0,0:08:46.60,0:08:48.76,Default,,0,0,0,,其中一个原因是: 129 | Dialogue: 0,0:08:48.97,0:08:53.48,Default,,0,0,0,,编码规范更倾向于编写不容易发生事故的代码 130 | Dialogue: 0,0:08:53.77,0:08:59.96,Default,,0,0,0,,所以要让菜鸟避免犯愚蠢的错 131 | Dialogue: 0,0:09:00.01,0:09:02.87,Default,,0,0,0,,所以列出了非常多规则列表申明不能那样做 132 | Dialogue: 0,0:09:02.96,0:09:03.49,Default,,0,0,0,,和 133 | Dialogue: 0,0:09:03.68,0:09:07.03,Default,,0,0,0,,我不喜欢这种名单,我知道你们绝大多数人也不喜欢这种名单 134 | Dialogue: 0,0:09:07.18,0:09:12.34,Default,,0,0,0,,很多组织在一开始就制订了这些规则 135 | Dialogue: 0,0:09:12.40,0:09:18.41,Default,,0,0,0,,他们也不知道到底想要做什么,他们就是想要避免一些问题而已 136 | Dialogue: 0,0:09:18.41,0:09:21.54,Default,,0,0,0,,还把规则放在很低的位置 137 | Dialogue: 0,0:09:21.54,0:09:22.99,Default,,0,0,0,,我的意思是.呃... 138 | Dialogue: 0,0:09:23.07,0:09:25.20,Default,,0,0,0,,是否用下划线? 139 | Dialogue: 0,0:09:25.20,0:09:27.90,Default,,0,0,0,,用多少空格缩进? 140 | Dialogue: 0,0:09:28.24,0:09:32.08,Default,,0,0,0,,这些都很有趣,可能在我们的组织中都必不可少 141 | Dialogue: 0,0:09:32.15,0:09:37.34,Default,,0,0,0,,但是这相对于高质量的软件开发水平来说这不算什么 142 | Dialogue: 0,0:09:37.41,0:09:41.36,Default,,0,0,0,,当我问你,如何判断一段代码是好代码? 143 | Dialogue: 0,0:09:41.76,0:09:46.23,Default,,0,0,0,,很多人只是简单的设置了一些限制 144 | Dialogue: 0,0:09:47.44,0:09:55.96,Default,,0,0,0,,不要使用重载;不要使用异常; 不要使用多重继承; 不要使用运算符重载.... 几乎所有类型的规则都是这样 145 | Dialogue: 0,0:09:56.11,0:10:04.36,Default,,0,0,0,,有一些是好的. 有一些是垃圾. 有些在某些特殊的情况下是好的. 一些却不是.\n真的还有很多误导人的建议 146 | Dialogue: 0,0:10:04.61,0:10:09.77,Default,,0,0,0,,有人告诉你,你真的应该去尝试写一下Java 147 | Dialogue: 0,0:10:09.84,0:10:12.90,Default,,0,0,0,,当你如果真的要写Java,那么你会怎么做? 148 | Dialogue: 0,0:10:12.90,0:10:18.36,Default,,0,0,0,,不要试图阻止C++程序员写好的C++代码 149 | Dialogue: 0,0:10:18.36,0:10:22.91,Default,,0,0,0,,还是"C with classes"吗? 那个概念在1986年确实很酷 150 | Dialogue: 0,0:10:23.04,0:10:25.84,Default,,0,0,0,,但是那是很久以前的事了,大部分人都是之后出生的 151 | Dialogue: 0,0:10:25.84,0:10:36.41,Default,,0,0,0,,还有人认为它应该在K&r被研发出来之后被淘汰 152 | Dialogue: 0,0:10:36.41,0:10:42.09,Default,,0,0,0,,他们可能接受一些关于C++函数原型像是const的几件特性 153 | Dialogue: 0,0:10:42.09,0:10:46.50,Default,,0,0,0,,但是基本上你应该能用C做到 154 | Dialogue: 0,0:10:46.80,0:10:50.35,Default,,0,0,0,,在我看来那是愚蠢的主意,但是我们依然会去做那些事 155 | Dialogue: 0,0:10:50.35,0:10:53.87,Default,,0,0,0,,此外,编码规则一直迭代更新 156 | Dialogue: 0,0:10:53.87,0:11:08.32,Default,,0,0,0,,我看到近几年推荐使用的编码准则,确实真的有很好的准则,它描述如何在约198*年编写好的代码。它还没有被更新,那是很久前的事情了。 157 | Dialogue: 0,0:11:08.45,0:11:10.78,Default,,0,0,0,,于是,他们变成了累赘 158 | Dialogue: 0,0:11:10.78,0:11:23.66,Default,,0,0,0,,大量的代码被专门应用于特定应用程序领域,像我帮他写一套硬实时软件或飞行控制系统 159 | Dialogue: 0,0:11:24.02,0:11:27.25,Default,,0,0,0,,这些都是很好的准则 160 | Dialogue: 0,0:11:27.25,0:11:30.21,Default,,0,0,0,,但是有些人试图把此规则使用在其它领域 161 | Dialogue: 0,0:11:30.21,0:11:38.90,Default,,0,0,0,,而且人们都知道知道,飞行规则是不在起飞之后使用new 162 | Dialogue: 0,0:11:38.90,0:11:41.04,Default,,0,0,0,,和你永远不要使用delete 163 | Dialogue: 0,0:11:41.30,0:11:45.94,Default,,0,0,0,,也许这些都不是最适当的准则 164 | Dialogue: 0,0:11:46.19,0:11:51.40,Default,,0,0,0,,其他某些准则有类似的偏见和约束,人们往往容易忘记他们 165 | Dialogue: 0,0:11:51.78,0:11:55.37,Default,,0,0,0,,也让很多人在很长时间内喘不过气来 166 | Dialogue: 0,0:11:55.37,0:11:59.73,Default,,0,0,0,,你们真的需要去理解一下团队语言规则制定者 167 | Dialogue: 0,0:11:59.73,0:12:04.41,Default,,0,0,0,,我看了看如何在C++中使用指针的规则 168 | Dialogue: 0,0:12:04.41,0:12:10.36,Default,,0,0,0,,我的意思是,看完后当时我很痛苦并不能理解所有这些规则 169 | Dialogue: 0,0:12:10.66,0:12:13.00,Default,,0,0,0,,你不能跟着他们,真的 170 | Dialogue: 0,0:12:13.00,0:12:18.81,Default,,0,0,0,,和大量的准则又没有很好的工具 171 | Dialogue: 0,0:12:19.15,0:12:21.38,Default,,0,0,0,,或者他们有平台依赖性 172 | Dialogue: 0,0:12:21.38,0:12:21.63,Default,,0,0,0,,{\pos(357,499)}da 173 | Dialogue: 0,0:12:21.63,0:12:21.81,Default,,0,0,0,,{\pos(276,477)}da 174 | Dialogue: 0,0:12:21.80,0:12:21.93,Default,,0,0,0,,{\pos(483,425)}da 175 | Dialogue: 0,0:12:21.93,0:12:22.05,Default,,0,0,0,,{\pos(301,424)}da 176 | Dialogue: 0,0:12:22.07,0:12:22.59,Default,,0,0,0,,{\pos(373,400)}da~ 177 | Dialogue: 0,0:12:22.77,0:12:24.50,Default,,0,0,0,,以及没有生产指导性 178 | Dialogue: 0,0:12:24.70,0:12:33.68,Default,,0,0,0,,我真的很想强调,告诉人们不要做什么不如告诉人们应该做什么 179 | Dialogue: 0,0:12:33.79,0:12:36.30,Default,,0,0,0,,所以就让我们来做这些很好的编程规范 180 | Dialogue: 0,0:12:36.30,0:12:40.49,Default,,0,0,0,,全面的浏览一下现代C++, 等一会儿 181 | Dialogue: 0,0:12:40.49,0:12:53.04,Default,,0,0,0,,首先,让我们忽略遗留的代码,让我们忽略旧的东西,让我们为我们的代码看起来像是5年到10年内写的 182 | Dialogue: 0,0:12:53.20,0:12:59.06,Default,,0,0,0,,然后我们再来解决如何做好交互,如何做兼容性 183 | Dialogue: 0,0:13:00.36,0:13:03.16,Default,,0,0,0,,逐渐适应是必不可少的 184 | Dialogue: 0,0:13:03.41,0:13:05.26,Default,,0,0,0,,规则是可学习的 185 | Dialogue: 0,0:13:05.29,0:13:11.46,Default,,0,0,0,,C++确实是有一些坏的教学材料 186 | Dialogue: 0,0:13:11.46,0:13:14.22,Default,,0,0,0,,其中一些是很旧的,顽固不化的 187 | Dialogue: 0,0:13:14.29,0:13:19.57,Default,,0,0,0,,通过自我阉割让C++看起来不那么令人讨厌 188 | Dialogue: 0,0:13:19.57,0:13:21.03,Default,,0,0,0,,以及一些类似的事情 189 | Dialogue: 0,0:13:21.18,0:13:26.34,Default,,0,0,0,,所以设置一些准则还可以让从事教育的教师了解如何教学 190 | Dialogue: 0,0:13:26.54,0:13:29.47,Default,,0,0,0,,Flexiable课程. 因为是一个巨大的社区 191 | Dialogue: 0,0:13:29.64,0:13:30.08,Default,,0,0,0,,我的意思是 192 | Dialogue: 0,0:13:30.19,0:13:33.98,Default,,0,0,0,,我们恢复只做一切计算的事情 193 | Dialogue: 0,0:13:34.12,0:13:36.07,Default,,0,0,0,,这当然是不专业的 194 | Dialogue: 0,0:13:36.07,0:13:39.68,Default,,0,0,0,,我们当然不能做这样的限制 195 | Dialogue: 0,0:13:43.28,0:13:46.51,Default,,0,0,0,,也有一些高层次的规则,也有一些低级别的规则 196 | Dialogue: 0,0:13:46.59,0:13:50.57,Default,,0,0,0,,高级别规则的目的是提供一个覆盖一切的概念框架 197 | Dialogue: 0,0:13:50.68,0:13:53.48,Default,,0,0,0,,那些都是非常自然的法则 198 | Dialogue: 0,0:13:53.60,0:13:54.79,Default,,0,0,0,,以及他们都是非常有用的 199 | Dialogue: 0,0:13:54.79,0:14:00.43,Default,,0,0,0,,比方像,你必须在代码中注释 - 虽然编译器却从来不会去管那些注释 200 | Dialogue: 0,0:14:00.52,0:14:08.12,Default,,0,0,0,,你使用ISO 标准 c++, 是的,有理由使用这样的扩展 201 | Dialogue: 0,0:14:08.12,0:14:13.54,Default,,0,0,0,,但是我们不打算处理特殊限制的情况 202 | Dialogue: 0,0:14:13.72,0:14:16.36,Default,,0,0,0,,我们想要安全的静态类型 203 | Dialogue: 0,0:14:17.10,0:14:18.14,Default,,0,0,0,,例如 204 | Dialogue: 0,0:14:18.32,0:14:21.17,Default,,0,0,0,,就是这样一个哲学框架 205 | Dialogue: 0,0:14:21.31,0:14:26.70,Default,,0,0,0,,问题是再次编译和程序也不能真正的了解哲学 206 | Dialogue: 0,0:14:26.90,0:14:35.84,Default,,0,0,0,,它意味着你必须转化为可以在一块程序的上下文中详细地理解和使用的东西 207 | Dialogue: 0,0:14:35.84,0:14:38.54,Default,,0,0,0,,因此,有理由是一大堆的低级规则 208 | Dialogue: 0,0:14:38.79,0:14:43.65,Default,,0,0,0,,基本上你们应该的大规模丢弃功能 209 | Dialogue: 0,0:14:46.26,0:14:52.70,Default,,0,0,0,,低级的规则,比如,使用 T * 来指定单个对象,而不是数组 210 | Dialogue: 0,0:14:52.90,0:14:57.58,Default,,0,0,0,,和喜欢初始化到构造函数中赋值 211 | Dialogue: 0,0:14:57.71,0:15:01.08,Default,,0,0,0,,这些都是很容易检查的 212 | Dialogue: 0,0:15:01.08,0:15:04.18,Default,,0,0,0,,当你违反了规则,那么我们会有工具提示你 213 | Dialogue: 0,0:15:04.24,0:15:06.00,Default,,0,0,0,,总是初始化对象 214 | Dialogue: 0,0:15:06.04,0:15:11.96,Default,,0,0,0,,这几天做的编译器。但它是好的规则,我们也可以做得更好,我们有他们的外部工具 215 | Dialogue: 0,0:15:12.01,0:15:15.29,Default,,0,0,0,,所以基本上,算是体现通过支配世界的方式 216 | Dialogue: 0,0:15:15.66,0:15:22.27,Default,,0,0,0,,和工具为编程提供反馈,它还有助于统一样式 217 | Dialogue: 0,0:15:22.58,0:15:27.34,Default,,0,0,0,,如果我看着一段代码,我看到一个字符串, 218 | Dialogue: 0,0:15:27.34,0:15:30.20,Default,,0,0,0,,如果我知道它的 std::string,我知道很多 219 | Dialogue: 0,0:15:30.37,0:15:34.28,Default,,0,0,0,,它帮助了我,我没有办法再去读手册 220 | Dialogue: 0,0:15:35.51,0:15:47.51,Default,,0,0,0,,所以一个更统一风格才有助于让我快速编写代码,可以帮助我读代码,理解代码 221 | Dialogue: 0,0:15:47.70,0:15:53.94,Default,,0,0,0,,and one thing you should understand is that the rules and not mean to be minimal or orthogonal. 222 | Dialogue: 0,0:15:54.23,0:16:01.74,Default,,0,0,0,,text book writters spend a lot of time trying to make sure that fix minimal amount of paper. 223 | Dialogue: 0,0:16:02.54,0:16:03.79,Default,,0,0,0,,this is not we are up to 224 | Dialogue: 0,0:16:04.06,0:16:12.33,Default,,0,0,0,,we try to have the most helpful, and have a large set tool to tell you when you fall over the edge. 225 | Dialogue: 0,0:16:12.88,0:16:16.58,Default,,0,0,0,,so the structure of a rule is simple and structured. 226 | Dialogue: 0,0:16:18.24,0:16:21.46,Default,,0,0,0,,"No naked new" for instance, it's a rule. 227 | Dialogue: 0,0:16:21.46,0:16:24.65,Default,,0,0,0,,and Reference numbers - people love reference numbers 228 | Dialogue: 0,0:16:24.65,0:16:27.15,Default,,0,0,0,,It also means that you can search for them. 229 | Dialogue: 0,0:16:27.26,0:16:31.62,Default,,0,0,0,,I mean you can refer to them in error messages. things like that. 230 | Dialogue: 0,0:16:32.01,0:16:38.49,Default,,0,0,0,,and NEVER NEVER tell people what not to do without giving a reason or what to do without giving a reason 231 | Dialogue: 0,0:16:38.53,0:16:44.15,Default,,0,0,0,,so every rule with the first thing that comes up with the rule itself is that rational a reason. 232 | Dialogue: 0,0:16:44.50,0:16:46.32,Default,,0,0,0,,and then it comes with an example. 233 | Dialogue: 0,0:16:46.40,0:16:53.05,Default,,0,0,0,,because by and large we don't understand abstract text, we need a concrete example or more 234 | Dialogue: 0,0:16:53.38,0:16:57.70,Default,,0,0,0,,if it's a "don't do this" rule, there should be alternatives. 235 | Dialogue: 0,0:16:57.81,0:17:01.12,Default,,0,0,0,,never tell people what not to do unless you give them alternatives. 236 | Dialogue: 0,0:17:01.84,0:17:03.54,Default,,0,0,0,,fairly simple to say. 237 | Dialogue: 0,0:17:03.79,0:17:05.64,Default,,0,0,0,,little bit hard to do sometimes. 238 | Dialogue: 0,0:17:05.70,0:17:10.83,Default,,0,0,0,,these rules are variable and value for a long time. 239 | Dialogue: 0,0:17:11.23,0:17:13.55,Default,,0,0,0,,There's references to other things. 240 | Dialogue: 0,0:17:13.55,0:17:18.34,Default,,0,0,0,,There's notes, things that we just felt was useful to say 241 | Dialogue: 0,0:17:18.44,0:17:26.99,Default,,0,0,0,,and then, there suppose to be long discussion at the end where you discuss a set of rules, set of reasons as such. 242 | Dialogue: 0,0:17:27.12,0:17:28.84,Default,,0,0,0,,it's bit weak just now. 243 | Dialogue: 0,0:17:28.91,0:17:30.62,Default,,0,0,0,,but that's the idea. 244 | Dialogue: 0,0:17:30.73,0:17:40.05,Default,,0,0,0,,some time you need more. as an explanation, that what fits on above this many lines, fit right on your screen when you look at them. 245 | Dialogue: 0,0:17:40.30,0:17:42.53,Default,,0,0,0,,so that's structure. 246 | Dialogue: 0,0:17:42.87,0:17:52.28,Default,,0,0,0,,the general idea is that people who have tryed to subset language have by and large failed. 247 | Dialogue: 0,0:17:52.81,0:18:02.73,Default,,0,0,0,,the thing that you really want to get rid of, like bad uses of pointers, bad interactions between inheritance and arrays and things like that 248 | Dialogue: 0,0:18:02.73,0:18:08.96,Default,,0,0,0,,if you just ban everything to get rid of problems, you can't write decent code anymore 249 | Dialogue: 0,0:18:08.96,0:18:11.77,Default,,0,0,0,,Yes! I want to write high-level code! 250 | Dialogue: 0,0:18:11.95,0:18:19.79,Default,,0,0,0,,But how do I do that? I do that by having libraries that allow me to write high-level code, and they implemented it using low-level code. 251 | Dialogue: 0,0:18:19.79,0:18:24.22,Default,,0,0,0,,because otherwise you can't get the efficiency and portability out of that. 252 | Dialogue: 0,0:18:24.22,0:18:27.55,Default,,0,0,0,,So, the general idea is not just the subset. 253 | Dialogue: 0,0:18:27.55,0:18:30.20,Default,,0,0,0,,First, we provide a superset. 254 | Dialogue: 0,0:18:30.20,0:18:33.52,Default,,0,0,0,,we have ISO standard C++ 255 | Dialogue: 0,0:18:33.60,0:18:38.99,Default,,0,0,0,,we have parts of the standard library that we recommend and that's you can use when you want to. 256 | Dialogue: 0,0:18:39.18,0:18:52.81,Default,,0,0,0,,and we have something called the guidelines support libraries which is small set - small as less than 2 dozen little classes and really that smaill - that's added. 257 | Dialogue: 0,0:18:53.04,0:18:54.76,Default,,0,0,0,,And that way, we can say: 258 | Dialogue: 0,0:18:54.76,0:18:57.52,Default,,0,0,0,,the messy dangerous bits, don't use them. 259 | Dialogue: 0,0:18:57.71,0:19:08.54,Default,,0,0,0,,we have provided abstractions that are elegent and efficient to allow you to not go there most of the time, for most people, all of the time. 260 | Dialogue: 0,0:19:08.54,0:19:13.36,Default,,0,0,0,,once you build that superset - the language + libraries. 261 | Dialogue: 0,0:19:13.52,0:19:17.04,Default,,0,0,0,,the you subset, and you can get rid of a lot of the crack. 262 | Dialogue: 0,0:19:17.18,0:19:24.43,Default,,0,0,0,,this is not a brand new idea I wrote a paper about it sometime more than ten years ago. 263 | Dialogue: 0,0:19:24.60,0:19:32.12,Default,,0,0,0,,so, really what we want is not neutered subset of c++ which is a lot of people that tryed. 264 | Dialogue: 0,0:19:32.12,0:19:35.16,Default,,0,0,0,,we want c++ on steroids on the other hand. 265 | Dialogue: 0,0:19:35.16,0:19:36.97,Default,,0,0,0,,so more of a good stuff. 266 | Dialogue: 0,0:19:37.21,0:19:40.78,Default,,0,0,0,,so the rules rely on the libraries. 267 | Dialogue: 0,0:19:40.88,0:19:43.52,Default,,0,0,0,,you can use any standard libraries of course. 268 | Dialogue: 0,0:19:43.69,0:19:46.91,Default,,0,0,0,,but once we rely on it, things like 269 | Dialogue: 0,0:19:46.91,0:19:50.84,Default,,0,0,0,,standart library class like vector or unique_ptr 270 | Dialogue: 0,0:19:50.84,0:19:59.13,Default,,0,0,0,,and some guideline things array_view - this is when you have a begining of a sequence and end 271 | Dialogue: 0,0:20:01.08,0:20:05.42,Default,,0,0,0,,not_null - you can say that a pointer shouldn't be null 272 | Dialogue: 0,0:20:05.42,0:20:06.36,Default,,0,0,0,,now get back to that 273 | Dialogue: 0,0:20:06.49,0:20:10.64,Default,,0,0,0,,so there's rules for using the GSL 274 | Dialogue: 0,0:20:10.64,0:20:13.53,Default,,0,0,0,,Never transfer ownership by raw pointer 275 | Dialogue: 0,0:20:14.06,0:20:18.11,Default,,0,0,0,,the idea is if you see a T*, it points to an element. 276 | Dialogue: 0,0:20:18.32,0:20:23.80,Default,,0,0,0,,you are not suppose to delete it, because it just points to an element, somebody ownes it. that's it. 277 | Dialogue: 0,0:20:23.90,0:20:33.00,Default,,0,0,0,,and if you want to have something that can not ever be null and you still want a pointer, you can use not_null of that pointer type. 278 | Dialogue: 0,0:20:33.00,0:20:36.94,Default,,0,0,0,,now, there's rules that encourage you to use higher level abstractions 279 | Dialogue: 0,0:20:37.05,0:20:46.00,Default,,0,0,0,,but these here are choose to show how you can deal with traditional old style code and improve it : don't pass an array as a ingle pointer. 280 | Dialogue: 0,0:20:46.22,0:20:51.29,Default,,0,0,0,,so basically, guess what this could do' 281 | Dialogue: 0,0:20:51.69,0:20:58.28,Default,,0,0,0,,I don't actually think that we can do less than can say double our productivity 282 | Dialogue: 0,0:20:58.28,0:21:03.82,Default,,0,0,0,,this is big claim but I think it can be done 283 | Dialogue: 0,0:21:03.85,0:21:16.11,Default,,0,0,0,,look at a good programmer working on a modern codebase and looking at same programmer working on a 20year old codebase or 10 year old codebase 284 | Dialogue: 0,0:21:16.27,0:21:22.56,Default,,0,0,0,,also look at a median kind of programmer 285 | Dialogue: 0,0:21:22.56,0:21:25.32,Default,,0,0,0,,and see what it taks to become a greate programmer. 286 | Dialogue: 0,0:21:25.37,0:21:27.23,Default,,0,0,0,,you need support you need time 287 | Dialogue: 0,0:21:27.23,0:21:28.59,Default,,0,0,0,,we can lower that time 288 | Dialogue: 0,0:21:28.84,0:21:37.87,Default,,0,0,0,,so, I think we can imitate experienced programers form rule sets that we trying to enforce. 289 | Dialogue: 0,0:21:38.09,0:21:42.38,Default,,0,0,0,,and so we can eliminate huge classes of errors. 290 | Dialogue: 0,0:21:42.38,0:21:45.08,Default,,0,0,0,,so simplification is important 291 | Dialogue: 0,0:21:45.21,0:21:48.22,Default,,0,0,0,,if we can have simpler code, maintance improves. 292 | Dialogue: 0,0:21:48.22,0:21:50.88,Default,,0,0,0,,consistent style speed up learning 293 | Dialogue: 0,0:21:50.99,0:21:57.52,Default,,0,0,0,,and guide people away from the deep dark corners of the law so much 294 | Dialogue: 0,0:21:58.88,0:22:06.70,Default,,0,0,0,,so much programers spend so much of their time looking on the most complicated code and the most complicated rules of the standard 295 | Dialogue: 0,0:22:06.96,0:22:10.30,Default,,0,0,0,,I'm shaking my head, I mean, this hurts! 296 | Dialogue: 0,0:22:10.49,0:22:11.96,Default,,0,0,0,,why do you do it ?! 297 | Dialogue: 0,0:22:12.46,0:22:19.29,Default,,0,0,0,,so I'm emphasis on avoiding waste, that can improve importance 298 | Dialogue: 0,0:22:19.42,0:22:30.12,Default,,0,0,0,,My guess is every large organization/community that's doing this will need to have some special rules for what they are doing 299 | Dialogue: 0,0:22:30.27,0:22:33.13,Default,,0,0,0,,so I'm talking about what I called the "core guidelines" 300 | Dialogue: 0,0:22:33.13,0:22:35.52,Default,,0,0,0,,things that pretentiously help everybody 301 | Dialogue: 0,0:22:35.52,0:22:39.96,Default,,0,0,0,,And I think most of you will want extensions in places. 302 | Dialogue: 0,0:22:40.09,0:22:53.04,Default,,0,0,0,,and some of you will want restructuring tool because there is some one recommended us that it doesn't quite fit in your world or maybe doesn't fit there for the next couple of years till you upgrade your codebase. 303 | Dialogue: 0,0:22:53.04,0:22:55.31,Default,,0,0,0,,and don't compromise performance 304 | Dialogue: 0,0:22:55.31,0:22:58.00,Default,,0,0,0,,performance is a really important aspect 305 | Dialogue: 0,0:22:58.00,0:23:00.06,Default,,0,0,0,,so I don't think I've gone mad 306 | Dialogue: 0,0:23:00.16,0:23:05.56,Default,,0,0,0,,I think we are actually attacking what we known to be the common most serious sources of errors 307 | Dialogue: 0,0:23:05.56,0:23:09.02,Default,,0,0,0,,and get rid of errors 308 | Dialogue: 0,0:23:10.25,0:23:15.44,Default,,0,0,0,,no resource leaks! that's good, we know how to do that! 309 | Dialogue: 0,0:23:15.48,0:23:21.61,Default,,0,0,0,,eliminate dangling pointer - that suppose to be very hard. I'll show you how to do that 310 | Dialogue: 0,0:23:21.90,0:23:28.48,Default,,0,0,0,,eliminate out-of-range access - that can not be done without a few runtime checks 311 | Dialogue: 0,0:23:28.91,0:23:32.12,Default,,0,0,0,,a few!! if you just check everything you are deracinate 312 | Dialogue: 0,0:23:32.12,0:23:37.53,Default,,0,0,0,,but a few can be done and we have some suggestions about that 313 | Dialogue: 0,0:23:37.79,0:23:39.96,Default,,0,0,0,,and Tool support is essential 314 | Dialogue: 0,0:23:39.96,0:23:43.88,Default,,0,0,0,,a lot of this, humans are not very actually good at it 315 | Dialogue: 0,0:23:46.67,0:23:49.23,Default,,0,0,0,,you look at a million lines of code and your eyes glares over. 316 | Dialogue: 0,0:23:49.45,0:23:57.36,Default,,0,0,0,,you check for a paticular kind of error and mistake in a million lines of code, 100 lines of code 10000 lines of code 317 | Dialogue: 0,0:23:57.42,0:24:00.30,Default,,0,0,0,,you get very tired and your concentration wavers. 318 | Dialogue: 0,0:24:00.38,0:24:01.40,Default,,0,0,0,,we neeeed tools 319 | Dialogue: 0,0:24:02.14,0:24:05.71,Default,,0,0,0,,the support library helps by simplify the rules 320 | Dialogue: 0,0:24:05.72,0:24:09.47,Default,,0,0,0,,and a lot of it has to do is reinforcing the type system. 321 | Dialogue: 0,0:24:09.52,0:24:16.73,Default,,0,0,0,,we can do better than we did it in 1978 and 1985 322 | Dialogue: 0,0:24:16.73,0:24:19.76,Default,,0,0,0,,so let's look at the core, the core rules. 323 | Dialogue: 0,0:24:21.10,0:24:29.00,Default,,0,0,0,,we have to start somewhere, so gradual adaption will be the way most of us will go on. 324 | Dialogue: 0,0:24:29.00,0:24:36.76,Default,,0,0,0,,if we write some brand new code from scratch, not using anybody else's libraries. then you can probably follow all the rules today. 325 | Dialogue: 0,0:24:37.08,0:24:39.32,Default,,0,0,0,,that doesn't happen very often. 326 | Dialogue: 0,0:24:39.52,0:24:42.46,Default,,0,0,0,,so I see gradual adaption be necessary. 327 | Dialogue: 0,0:24:42.91,0:24:47.05,Default,,0,0,0,,and therefore core of the core rules 328 | Dialogue: 0,0:24:47.08,0:24:52.09,Default,,0,0,0,,No leaks, No dangling pointers, No type violations through pointers at all! 329 | Dialogue: 0,0:24:52.46,0:24:55.72,Default,,0,0,0,,we know how to avoid leaks. 330 | Dialogue: 0,0:24:55.88,0:25:00.99,Default,,0,0,0,,we just root every object in a scope 331 | Dialogue: 0,0:25:00.99,0:25:04.48,Default,,0,0,0,,RAII kind of standard containers 332 | Dialogue: 0,0:25:04.48,0:25:09.60,Default,,0,0,0,,new and delete disappear into the abstractions 333 | Dialogue: 0,0:25:09.60,0:25:14.49,Default,,0,0,0,,this is nice. when I see "delete" in application code, there must be bugs somewhere. 334 | Dialogue: 0,0:25:15.04,0:25:15.69,Default,,0,0,0,,why? 335 | Dialogue: 0,0:25:15.69,0:25:19.96,Default,,0,0,0,,because if there is one delete, there probably should be more. 336 | Dialogue: 0,0:25:19.96,0:25:23.58,Default,,0,0,0,,and there are probably been too many. 337 | Dialogue: 0,0:25:23.58,0:25:29.42,Default,,0,0,0,,so new/delete disappear into classes 338 | Dialogue: 0,0:25:29.95,0:25:35.74,Default,,0,0,0,,when you see a "new" in application code, you think there must be a problem here. 339 | Dialogue: 0,0:25:35.88,0:25:41.76,Default,,0,0,0,,because if there's a new there should be a delete somewhere, and if there's delete somewhere and we know from experience we made mistakes. 340 | Dialogue: 0,0:25:42.11,0:25:44.48,Default,,0,0,0,,so we don't do that. 341 | Dialogue: 0,0:25:44.62,0:25:48.76,Default,,0,0,0,,this leads us to what I think is a worse nightmare problem. 342 | Dialogue: 0,0:25:49.60,0:25:50.99,Default,,0,0,0,,dangling pointers 343 | Dialogue: 0,0:25:51.13,0:25:52.80,Default,,0,0,0,,and this are so easy to get to. 344 | Dialogue: 0,0:25:52.86,0:25:58.73,Default,,0,0,0,,here we have a function "f" that you give it a pointer and it deletes. 345 | Dialogue: 0,0:25:58.94,0:26:00.81,Default,,0,0,0,,so you deleted that pointer. 346 | Dialogue: 0,0:26:02.04,0:26:04.24,Default,,0,0,0,,that might be right or might be wrong. 347 | Dialogue: 0,0:26:04.51,0:26:08.76,Default,,0,0,0,,my rulers on it, it's very suspect because it is deleting application code. 348 | Dialogue: 0,0:26:09.18,0:26:12.46,Default,,0,0,0,,here is "g" makes an object, calls f. 349 | Dialogue: 0,0:26:12.76,0:26:20.62,Default,,0,0,0,,and then it uses q which happens to be the pointing the the object that was deleted in f. 350 | Dialogue: 0,0:26:20.80,0:26:23.23,Default,,0,0,0,,this is how you scram your memory 351 | Dialogue: 0,0:26:23.44,0:26:26.78,Default,,0,0,0,,the rules will make sure that you don't do this. 352 | Dialogue: 0,0:26:26.88,0:26:31.65,Default,,0,0,0,,and it'll take care of some of the most shroud and difficult find bugs 353 | Dialogue: 0,0:26:32.18,0:26:39.16,Default,,0,0,0,,and we have to do this because if we don't we can damage type safety. 354 | Dialogue: 0,0:26:39.33,0:26:41.54,Default,,0,0,0,,I say this object is an integer 355 | Dialogue: 0,0:26:42.29,0:26:44.16,Default,,0,0,0,,you do this example 356 | Dialogue: 0,0:26:44.29,0:26:49.33,Default,,0,0,0,,and the object might integer are laies at place where your object wasn't, you scramble it. 357 | Dialogue: 0,0:26:49.76,0:26:52.14,Default,,0,0,0,,Memory safety of course. 358 | Dialogue: 0,0:26:52.15,0:26:55.14,Default,,0,0,0,,because we are not using memory as if it is clear 359 | Dialogue: 0,0:26:55.36,0:27:03.35,Default,,0,0,0,,and Resource safety is compromise because you can destory things that are laying around there. 360 | Dialogue: 0,0:27:03.94,0:27:06.48,Default,,0,0,0,,double delete and no deletes 361 | Dialogue: 0,0:27:06.54,0:27:13.33,Default,,0,0,0,,we have to solve this problem to get type safety to get resource safety. 362 | Dialogue: 0,0:27:13.78,0:27:18.88,Default,,0,0,0,,we're going to eliminate this by combination of rules 363 | Dialogue: 0,0:27:19.01,0:27:20.04,Default,,0,0,0,,I mean eliminated 364 | Dialogue: 0,0:27:20.08,0:27:20.92,Default,,0,0,0,,get rid of it 365 | Dialogue: 0,0:27:21.05,0:27:22.40,Default,,0,0,0,, 366 | Dialogue: 0,0:27:22.87,0:27:26.26,Default,,0,0,0,,we distinguish owners from non-owners 367 | Dialogue: 0,0:27:26.27,0:27:30.78,Default,,0,0,0,,if I have a pointer, am I suppose to delete it or not? NO! 368 | Dialogue: 0,0:27:31.30,0:27:34.27,Default,,0,0,0,,asure raw pointers to be non-owners! 369 | Dialogue: 0,0:27:34.27,0:27:45.28,Default,,0,0,0,,we have many pointers in our programs, far too many, but let's asure they are all innocent, they just point to an object, they are not suppose to be a ownership 370 | Dialogue: 0,0:27:45.60,0:27:55.60,Default,,0,0,0,,Catch all attempts for a pointer to "escape" into a scope that is outside a scope of what it points to. 371 | Dialogue: 0,0:27:55.62,0:27:57.13,Default,,0,0,0,,fairly simple 372 | Dialogue: 0,0:27:57.39,0:28:01.32,Default,,0,0,0,,anything that holds an owner is consider an owner 373 | Dialogue: 0,0:28:01.42,0:28:03.53,Default,,0,0,0,,so all of this works recursively 374 | Dialogue: 0,0:28:03.69,0:28:05.89,Default,,0,0,0,,so this is simple rule. 375 | Dialogue: 0,0:28:05.98,0:28:09.24,Default,,0,0,0,,we have some pointers, they point to an object 376 | Dialogue: 0,0:28:10.32,0:28:13.36,Default,,0,0,0,,that object is held alive by an owner 377 | Dialogue: 0,0:28:13.83,0:28:15.30,Default,,0,0,0,,this works recursively 378 | Dialogue: 0,0:28:15.30,0:28:18.32,Default,,0,0,0,,the object happens to have an owner pointer inside it 379 | Dialogue: 0,0:28:18.54,0:28:24.38,Default,,0,0,0,,thus we have constructors and distructors. constructors to construct, distructors to clean up. 380 | Dialogue: 0,0:28:24.61,0:28:37.43,Default,,0,0,0,,what we really have to avoid is that pointer there. that has been passed below the object owner in the stack so when we delete the owner the object is not there and people are still refering to it. 381 | Dialogue: 0,0:28:37.52,0:28:44.90,Default,,0,0,0,,this must never happen so we can asure that. so long long way to eliminate (dangling) pointers. 382 | Dialogue: 0,0:28:45.03,0:28:46.42,Default,,0,0,0,,this is not new rule 383 | Dialogue: 0,0:28:46.63,0:28:50.85,Default,,0,0,0,,if you look at the standard it suggest you should not do that because it's undefined behavior 384 | Dialogue: 0,0:28:51.07,0:28:53.35,Default,,0,0,0,,the point is how do we actully get there. 385 | Dialogue: 0,0:28:53.90,0:28:58.41,Default,,0,0,0,,so here is dangling pointers thing again 386 | Dialogue: 0,0:28:58.99,0:29:01.83,Default,,0,0,0,,first of all the rule will catch the delete p. 387 | Dialogue: 0,0:29:02.12,0:29:10.42,Default,,0,0,0,,you had a innocent looking pointer X* that is not an owner. so the rules will tell you not to do that. 388 | Dialogue: 0,0:29:10.88,0:29:14.45,Default,,0,0,0,,tools that enforce the rules will tell you that is bad 389 | Dialogue: 0,0:29:14.71,0:29:17.26,Default,,0,0,0,,you go back to the "g" 390 | Dialogue: 0,0:29:17.58,0:29:22.35,Default,,0,0,0,,it says, well, "new X" obviously produces an owner. 391 | Dialogue: 0,0:29:22.44,0:29:29.14,Default,,0,0,0,,so assigning it to a plain old pointer is going to be wrong. 392 | Dialogue: 0,0:29:29.14,0:29:32.09,Default,,0,0,0,,because this could lead to a leak 393 | Dialogue: 0,0:29:32.31,0:29:39.62,Default,,0,0,0,,if fact it is also .. if do that will lead you to problems with exceptions, is another matter. 394 | Dialogue: 0,0:29:39.78,0:29:48.57,Default,,0,0,0,,we'll never get down to the problem because you are already been traped by those simple rules twice. 395 | Dialogue: 0,0:29:49.64,0:29:56.73,Default,,0,0,0,,so we can look at how we represent the ownership. 396 | Dialogue: 0,0:29:57.12,0:30:05.50,Default,,0,0,0,,you can mark every owning pointer as owner 397 | Dialogue: 0,0:30:05.92,0:30:09.15,Default,,0,0,0,,for a long time I think we need a bit to do that 398 | Dialogue: 0,0:30:09.52,0:30:16.06,Default,,0,0,0,,that sort of dynamic module that took every pointer and mark it if owner or not. 399 | Dialogue: 0,0:30:16.45,0:30:22.78,Default,,0,0,0,,I had modules like that before I put and saying whether it's a const or not , things like that 400 | Dialogue: 0,0:30:22.88,0:30:24.64,Default,,0,0,0,,the point is it's useless! 401 | Dialogue: 0,0:30:24.76,0:30:30.41,Default,,0,0,0,,It is very good for thinking about problems but it is useless for actually doing it 402 | Dialogue: 0,0:30:30.41,0:30:36.89,Default,,0,0,0,,because, well, it cost time|space to have that extra bit, or time&space. 403 | Dialogue: 0,0:30:37.07,0:30:47.47,Default,,0,0,0,,It means that the code that uses such smart pointers flat pointers as such are no longer ABI compatible with the existing code. 404 | Dialogue: 0,0:30:47.66,0:30:52.16,Default,,0,0,0,,it runs slower than ordinary C or C++. 405 | Dialogue: 0,0:30:52.28,0:30:53.64,Default,,0,0,0,,that's not acceptable 406 | Dialogue: 0,0:30:53.96,0:30:56.50,Default,,0,0,0,,and we have to rewrite our own code for it 407 | Dialogue: 0,0:30:56.53,0:31:10.50,Default,,0,0,0,,so the idea is that you just have a type system owner that static analysis tools can use. 408 | Dialogue: 0,0:31:10.59,0:31:15.20,Default,,0,0,0,,when I talk about pointers I mean anything that can point to an object. 409 | Dialogue: 0,0:31:15.25,0:31:23.52,Default,,0,0,0,,if we can handle it for pointers, we can handle it for everything, references, containers, smart pointers and things like that. 410 | Dialogue: 0,0:31:27.39,0:31:30.26,Default,,0,0,0,,we are going to eliminate all dangling pointers. 411 | Dialogue: 0,0:31:34.32,0:31:37.35,Default,,0,0,0,,oh yeah, down on the broader you can see the definition of an owner. 412 | Dialogue: 0,0:31:37.39,0:31:40.06,Default,,0,0,0,,just as alien, we mark it as an owner 413 | Dialogue: 0,0:31:40.43,0:31:44.00,Default,,0,0,0,,humans can read it, tools can read it 414 | Dialogue: 0,0:31:44.45,0:31:46.06,Default,,0,0,0,,but your linker doesn't care. 415 | Dialogue: 0,0:31:46.19,0:31:49.28,Default,,0,0,0,,so everything is working as before. 416 | Dialogue: 0,0:31:49.39,0:31:51.00,Default,,0,0,0,,so here is how we can use it. 417 | Dialogue: 0,0:31:51.00,0:32:02.10,Default,,0,0,0,,we can use an owner to improve our implementations of higher level abstractions, we want to use high level abstractions like vector and static array. 418 | Dialogue: 0,0:32:02.22,0:32:12.55,Default,,0,0,0,,and we just mark that, in paticuler cases one of the 3 pointers inside the implementation of the vector is an ower and the other two aren't. 419 | Dialogue: 0,0:32:12.80,0:32:16.76,Default,,0,0,0,,that's the owner, keep it alive, the others just pointing to it 420 | Dialogue: 0,0:32:16.82,0:32:19.63,Default,,0,0,0,,that sort of the general you should see a lot. 421 | Dialogue: 0,0:32:19.85,0:32:26.45,Default,,0,0,0,,and only if we are dealing with pointers directly do we use owners 422 | Dialogue: 0,0:32:26.46,0:32:45.31,Default,,0,0,0,,so there's "f()" that taks an owner, and then trying to call it. I call it with an owner, that'll transfer ownership; I call it with non-owner,that's bad. I delete one of the owners, that's good; delete something that's not an owner, that't bad, we can catch. 423 | Dialogue: 0,0:32:45.56,0:32:54.34,Default,,0,0,0,,and this is just marking, the static analysis tool will tell you when you did something that wasn't good. 424 | Dialogue: 0,0:32:54.34,0:32:58.59,Default,,0,0,0,,an owner has to transfer to someone else or delete it. 425 | Dialogue: 0,0:32:59.69,0:33:04.03,Default,,0,0,0,,the code will check whether you do it (or not) that's it. 426 | Dialogue: 0,0:33:04.82,0:33:06.73,Default,,0,0,0,,and owners are low-leve mechanism. 427 | Dialogue: 0,0:33:06.73,0:33:09.40,Default,,0,0,0,,you don't want to feddle with that all the time. 428 | Dialogue: 0,0:33:09.56,0:33:12.22,Default,,0,0,0,,but having owner allows you to do two things 429 | Dialogue: 0,0:33:12.30,0:33:19.29,Default,,0,0,0,,it provides the support for the implemention of high level abstrastions 430 | Dialogue: 0,0:33:12.30,0:33:19.29,Default,,0,0,0,,it allows you to implement high level abstrastions 431 | Dialogue: 0,0:33:19.29,0:33:25.47,Default,,0,0,0,,c++ are a language where you can design your own container, you can design your own smart pointers, etc 432 | Dialogue: 0,0:33:25.70,0:33:30.33,Default,,0,0,0,,now you get a little bit support in how to express this. 433 | Dialogue: 0,0:33:30.33,0:33:32.70,Default,,0,0,0,,and not make so many mistakes when you do it. 434 | Dialogue: 0,0:33:32.83,0:33:35.53,Default,,0,0,0,,and further more as ABIs 435 | Dialogue: 0,0:33:35.56,0:33:44.88,Default,,0,0,0,,somebody really says that they want any *, er, you don't have to give up all your checking to be able to use that ABI. 436 | Dialogue: 0,0:33:49.41,0:33:51.60,Default,,0,0,0,,What else do we have to do? 437 | Dialogue: 0,0:33:51.61,0:33:54.90,Default,,0,0,0,,we can handle owner ship now we have to handle dangling 438 | Dialogue: 0,0:34:00.49,0:34:05.50,Default,,0,0,0,,Don't transfer to pointer to a local to where it could be accessed by a caller. 439 | Dialogue: 0,0:34:07.31,0:34:09.42,Default,,0,0,0,,ok, let's look at the example there. 440 | Dialogue: 0,0:34:09.54,0:34:12.24,Default,,0,0,0,,I am returning something. 441 | Dialogue: 0,0:34:12.28,0:34:14.78,Default,,0,0,0,,I neither return a pointer to a local. 442 | Dialogue: 0,0:34:14.99,0:34:17.25,Default,,0,0,0,,not a good idea, we all know that. 443 | Dialogue: 0,0:34:17.25,0:34:22.74,Default,,0,0,0,,compiler are able to catch it more or less consistently for the last 20 years. 444 | Dialogue: 0,0:34:23.01,0:34:28.98,Default,,0,0,0,,then I'm returnning a pointer to something I just created on the free-store. 445 | Dialogue: 0,0:34:28.98,0:34:30.26,Default,,0,0,0,,that's fine. 446 | Dialogue: 0,0:34:30.26,0:34:33.46,Default,,0,0,0,,at least it's sortof fine becauseIt didn't mark it as owner. 447 | Dialogue: 0,0:34:33.47,0:34:37.41,Default,,0,0,0,,but as far as dangling pointers,it's not going to dangle. 448 | Dialogue: 0,0:34:37.41,0:34:41.41,Default,,0,0,0,,and finnaly, there's a pointer that is given to me 449 | Dialogue: 0,0:34:41.41,0:34:44.84,Default,,0,0,0,,then obviously I can give it back because it came from my caller. 450 | Dialogue: 0,0:34:45.14,0:34:48.89,Default,,0,0,0,,those are roughly only 3 cases we can handle that. 451 | Dialogue: 0,0:34:49.18,0:34:56.46,Default,,0,0,0,,we can stop pointers from escaping down to the bottom of the stack and out live the owner. 452 | Dialogue: 0,0:34:56.99,0:35:06.44,Default,,0,0,0,,so catches all kinds of the things , pointers references etc and that's so fine 453 | Dialogue: 0,0:35:06.49,0:35:13.69,Default,,0,0,0,,so, we need to classify acording to owner ship to work here. 454 | Dialogue: 0,0:35:13.76,0:35:17.21,Default,,0,0,0,,because, look at the f() there. 455 | Dialogue: 0,0:35:17.52,0:35:21.30,Default,,0,0,0,,it returns a vector of integers 456 | Dialogue: 0,0:35:21.53,0:35:35.44,Default,,0,0,0,,and inside that vector of integers we put something that's an owner, something that's a pointer to a local and something we got from our caller 457 | Dialogue: 0,0:35:35.92,0:35:41.82,Default,,0,0,0,,this... we can't handle the ownership, it just mixed. 458 | Dialogue: 0,0:35:42.44,0:35:45.02,Default,,0,0,0,,that's bad code. 459 | Dialogue: 0,0:35:45.08,0:35:46.88,Default,,0,0,0,,it's asking for touble. 460 | Dialogue: 0,0:35:46.97,0:35:49.30,Default,,0,0,0,,it'll be rejected for mixing it. 461 | Dialogue: 0,0:35:49.89,0:36:00.76,Default,,0,0,0,,in code we would have to try and deal with it and we can't 462 | Dialogue: 0,0:36:00.76,0:36:03.45,Default,,0,0,0,,because clearly the ownership became mixed. 463 | Dialogue: 0,0:36:03.54,0:36:07.60,Default,,0,0,0,,and when we passed it out, all the information about who shoud delete what has gone 464 | Dialogue: 0,0:36:07.64,0:36:29.17,Default,,0,0,0,,the only way of doing that is actually to hav something like big vector of (what) that should tell you which should be deleted or you can sort of hope you can change into unique_ptr so that preseve the ownership. 465 | Dialogue: 0,0:36:29.17,0:36:34.42,Default,,0,0,0,,don't mix ownership in containers! 466 | Dialogue: 0,0:36:34.52,0:36:38.70,Default,,0,0,0,,bacause in corrent code it doesn't work too well. 467 | Dialogue: 0,0:36:40.85,0:36:42.84,Default,,0,0,0,,in this code it'll be caught. 468 | Dialogue: 0,0:36:43.55,0:36:48.26,Default,,0,0,0,,so let's course many other ways of mis-using pointers and such. 469 | Dialogue: 0,0:36:48.26,0:36:51.38,Default,,0,0,0,,range errors, dereferencing nullptr 470 | Dialogue: 0,0:36:51.88,0:36:57.22,Default,,0,0,0,,I'm going to go little bit about that 471 | Dialogue: 0,0:36:57.57,0:37:03.37,Default,,0,0,0,,and I notice that there's a copy of printable here 472 | Dialogue: 0,0:37:03.48,0:37:07.24,Default,,0,0,0,,some of the rules are meanable to static analysis. 473 | Dialogue: 0,0:37:07.30,0:37:13.41,Default,,0,0,0,,some of them are meanable to sort of high G you can look at and give it as guidelines 474 | Dialogue: 0,0:37:13.52,0:37:16.57,Default,,0,0,0,,and some of them really accquire runtime checks. 475 | Dialogue: 0,0:37:16.76,0:37:20.11,Default,,0,0,0,,we want to minimize runtime checks because we want to run fast. 476 | Dialogue: 0,0:37:20.89,0:37:29.47,Default,,0,0,0,,so here is one of the tools that we are providing - it's similar to the proposals in standard committee. 477 | Dialogue: 0,0:37:29.49,0:37:39.12,Default,,0,0,0,,this one here, we'll do re-write, we have for some reason I don't understand at. the array view will be proposed in standard as read-only structure. 478 | Dialogue: 0,0:37:39.66,0:37:41.22,Default,,0,0,0,,but anyway, here. 479 | Dialogue: 0,0:37:41.32,0:37:42.88,Default,,0,0,0,,we have a common style 480 | Dialogue: 0,0:37:42.97,0:37:47.21,Default,,0,0,0,,we call with a pointer and a count 481 | Dialogue: 0,0:37:47.39,0:37:49.93,Default,,0,0,0,,this is my least favorite kind of interface 482 | Dialogue: 0,0:37:50.05,0:37:53.32,Default,,0,0,0,,least favorite, because it is so error prone. 483 | Dialogue: 0,0:37:53.32,0:37:56.20,Default,,0,0,0,,and least favorite because it is so common. 484 | Dialogue: 0,0:37:56.44,0:37:58.19,Default,,0,0,0,,so a lot of errors there. 485 | Dialogue: 0,0:37:58.27,0:38:01.25,Default,,0,0,0,,so I assign 9 to a[7]. 486 | Dialogue: 0,0:38:01.57,0:38:02.73,Default,,0,0,0,,it that ok? 487 | Dialogue: 0,0:38:02.99,0:38:04.56,Default,,0,0,0,,we have no ways of knowing! 488 | Dialogue: 0,0:38:04.56,0:38:06.56,Default,,0,0,0,,the information is not there 489 | Dialogue: 0,0:38:06.99,0:38:13.80,Default,,0,0,0,,and I can make a loop, let's hope a really was the count 490 | Dialogue: 0,0:38:13.96,0:38:16.49,Default,,0,0,0,,and we hope the count was right, that's fine. 491 | Dialogue: 0,0:38:16.73,0:38:19.96,Default,,0,0,0,,so instead, we provide you an abstraction that's array_view. 492 | Dialogue: 0,0:38:20.14,0:38:23.94,Default,,0,0,0,,a begining that can browse integers, doesn't matter 493 | Dialogue: 0,0:38:24.09,0:38:31.52,Default,,0,0,0,,there. you could check the runtime if you wanted to that a[7] is valid 494 | Dialogue: 0,0:38:31.77,0:38:35.32,Default,,0,0,0,,and if you don't want the checks. we can only have it on debug mode 495 | Dialogue: 0,0:38:35.50,0:38:41.64,Default,,0,0,0,,we can now write range-for loop that will work. 496 | Dialogue: 0,0:38:41.90,0:38:48.01,Default,,0,0,0,,notice that there is not int n to get wrong and the code get simplified and is become more checkable 497 | Dialogue: 0,0:38:48.01,0:38:50.97,Default,,0,0,0,,we are lifting the abstraction just a little bit. 498 | Dialogue: 0,0:38:51.15,0:38:54.28,Default,,0,0,0,,and so we can look at some calls there. 499 | Dialogue: 0,0:38:54.51,0:38:57.79,Default,,0,0,0,,I call it for a[100] 500 | Dialogue: 0,0:38:57.86,0:39:00.28,Default,,0,0,0,,I have to say a and 100. 501 | Dialogue: 0,0:39:00.28,0:39:05.30,Default,,0,0,0,,even though I have told there are 100 elements in a. 502 | Dialogue: 0,0:39:05.60,0:39:13.29,Default,,0,0,0,,and if I finger flipson the keyborad and I write a 1000, all kinds of bad things will happen 503 | Dialogue: 0,0:39:14.39,0:39:17.09,Default,,0,0,0,,if it's a variable it gets more interesting 504 | Dialogue: 0,0:39:17.19,0:39:18.84,Default,,0,0,0,,for array_view 505 | Dialogue: 0,0:39:20.02,0:39:20.64,Default,,0,0,0,,well 506 | Dialogue: 0,0:39:20.80,0:39:25.92,Default,,0,0,0,,you can just say it was an array_view or you can rely on the conversion of an array to an array_view 507 | Dialogue: 0,0:39:26.14,0:39:32.40,Default,,0,0,0,,it just socks on that array, makes it into array_view, having the size deduced 508 | Dialogue: 0,0:39:32.88,0:39:36.85,Default,,0,0,0,,if you are going to call it on a value. 509 | Dialogue: 0,0:39:37.12,0:39:45.99,Default,,0,0,0,,it's fairly easy to check agains the array of values there, if not you are on errors as often, 510 | Dialogue: 0,0:39:46.15,0:39:50.80,Default,,0,0,0,,so this follows the idea of make simple things simple 511 | Dialogue: 0,0:39:51.09,0:39:55.83,Default,,0,0,0,,and array_view is roughly the same as (int*p,int n); 512 | Dialogue: 0,0:39:56.13,0:39:59.91,Default,,0,0,0,,but we can use it easier and make few mistakes. 513 | Dialogue: 0,0:40:00.84,0:40:06.49,Default,,0,0,0,,nullptr. deal with it simply by saying what we mean. 514 | Dialogue: 0,0:40:06.61,0:40:09.78,Default,,0,0,0,,the problem is , today , we don't say what we mean. 515 | Dialogue: 0,0:40:09.85,0:40:12.21,Default,,0,0,0,,I have f(char*) 516 | Dialogue: 0,0:40:12.74,0:40:15.60,Default,,0,0,0,,is it alright to call it with nullptr ? 517 | Dialogue: 0,0:40:16.37,0:40:17.78,Default,,0,0,0,,where does it say so? 518 | Dialogue: 0,0:40:18.16,0:40:20.58,Default,,0,0,0,,in the documentation, OK. 519 | Dialogue: 0,0:40:20.84,0:40:26.05,Default,,0,0,0,,compiler don't read document and neither do I when I hear it 520 | Dialogue: 0,0:40:26.16,0:40:27.17,Default,,0,0,0,,not a good thing. 521 | Dialogue: 0,0:40:27.41,0:40:29.21,Default,,0,0,0,,when I implementing f(). 522 | Dialogue: 0,0:40:29.27,0:40:33.08,Default,,0,0,0,,should I turst my users (that they will) follow the rules or not? 523 | Dialogue: 0,0:40:33.69,0:40:34.95,Default,,0,0,0,,should I test (against parameter)? 524 | Dialogue: 0,0:40:36.65,0:40:38.04,Default,,0,0,0,,if I test, I test too much 525 | Dialogue: 0,0:40:38.04,0:40:40.51,Default,,0,0,0,,because that's a waste of resources. 526 | Dialogue: 0,0:40:40.52,0:40:42.39,Default,,0,0,0,,If I test too little, it'll crash. 527 | Dialogue: 0,0:40:42.49,0:40:45.09,Default,,0,0,0,,there're all kinds of things about that. 528 | Dialogue: 0,0:40:45.09,0:40:48.31,Default,,0,0,0,,so, one way to dealing with it is that we use not_null. 529 | Dialogue: 0,0:40:48.37,0:40:53.11,Default,,0,0,0,,currently that's a class that will test whether it's null or not. 530 | Dialogue: 0,0:40:53.25,0:40:57.01,Default,,0,0,0,,but a lot of it can be eliminated and can be debug only. 531 | Dialogue: 0,0:40:57.09,0:41:02.01,Default,,0,0,0,,so if nullptr is an error it toke f(not_null) 532 | Dialogue: 0,0:41:02.32,0:41:12.05,Default,,0,0,0,,and little bit saddle here. if you pass a variable that is not a pointer. that requires checking 533 | Dialogue: 0,0:41:12.31,0:41:17.68,Default,,0,0,0,,but now we write f() we don't need to do the checking 534 | Dialogue: 0,0:41:17.89,0:41:27.71,Default,,0,0,0,,so it's simplier and more class. it makes the code more explict, it detects a paticular specific well known problem. 535 | Dialogue: 0,0:41:28.07,0:41:32.00,Default,,0,0,0,,thers's many ways to the tagging most problem this is the one way we choose for those. 536 | Dialogue: 0,0:41:32.29,0:41:35.37,Default,,0,0,0,,so we go after bugs 537 | Dialogue: 0,0:41:35.43,0:41:37.97,Default,,0,0,0,,we provide type and resource safety 538 | Dialogue: 0,0:41:38.34,0:41:44.60,Default,,0,0,0,,now we can go after other problems 539 | Dialogue: 0,0:41:44.61,0:41:45.47,Default,,0,0,0,,logic errors 540 | Dialogue: 0,0:41:45.47,0:41:47.69,Default,,0,0,0,,performance bugs, maintenance hassles 541 | Dialogue: 0,0:41:47.69,0:41:49.57,Default,,0,0,0,,there are rules going there. 542 | Dialogue: 0,0:41:49.57,0:41:55.01,Default,,0,0,0,,but there are not as complete as things for extending the type-system. 543 | Dialogue: 0,0:41:55.22,0:42:03.21,Default,,0,0,0,,one thing we noticed is that there is a lot of over use of smart pointers. 544 | Dialogue: 0,0:42:03.21,0:42:10.16,Default,,0,0,0,,i noticed a lot of shared_ptr been used simply to return a value from a function 545 | Dialogue: 0,0:42:10.87,0:42:18.77,Default,,0,0,0,,so the use count goes from zero to 1 and 1 to 2 and 2 to 1 and to 0 546 | Dialogue: 0,0:42:18.77,0:42:28.40,Default,,0,0,0,,and all we did is to get something transferd simply because people didn't trust ordinary pointers 547 | Dialogue: 0,0:42:28.40,0:42:33.23,Default,,0,0,0,,quiet resonably so because all ordinary pointers might dangle 548 | Dialogue: 0,0:42:34.18,0:42:35.51,Default,,0,0,0,,wait a minite! 549 | Dialogue: 0,0:42:35.71,0:42:37.34,Default,,0,0,0,,we just solved that problem! 550 | Dialogue: 0,0:42:37.34,0:42:41.32,Default,,0,0,0,,so we have to re-think the way we're using smart pointers 551 | Dialogue: 0,0:42:41.32,0:42:43.08,Default,,0,0,0,,shared_ptr in paticular 552 | Dialogue: 0,0:42:43.31,0:42:45.65,Default,,0,0,0,,and my feeling is that they over used it. 553 | Dialogue: 0,0:42:45.80,0:42:51.20,Default,,0,0,0,,a lot of protection in shared_ptr when used int that way is just a overhead. 554 | Dialogue: 0,0:42:51.29,0:42:58.32,Default,,0,0,0,,because once the bugs have gone you don't have to have the use count anymore. 555 | Dialogue: 0,0:42:58.32,0:43:02.40,Default,,0,0,0,,but it sits there forever counting what ever you called and passed a smart pointer 556 | Dialogue: 0,0:43:02.85,0:43:05.22,Default,,0,0,0,,{\s1}with smart pointers{\s0} 557 | Dialogue: 0,0:43:05.50,0:43:12.40,Default,,0,0,0,,with dangling pointers eliminated by tools you don't need to do that. 558 | Dialogue: 0,0:43:12.53,0:43:15.40,Default,,0,0,0,,I'm going to show a little bit about it. 559 | Dialogue: 0,0:43:15.77,0:43:21.05,Default,,0,0,0,,so here are the alternatives, in the standard we can take a T* 560 | Dialogue: 0,0:43:22.69,0:43:24.95,Default,,0,0,0,,doesn't deal with ownership just a pointer 561 | Dialogue: 0,0:43:25.13,0:43:26.41,Default,,0,0,0,,just use the pointer 562 | Dialogue: 0,0:43:26.66,0:43:27.97,Default,,0,0,0,,with the rules here. 563 | Dialogue: 0,0:43:28.04,0:43:33.32,Default,,0,0,0,,we know that f(T*) will not delete T. 564 | Dialogue: 0,0:43:33.45,0:43:35.85,Default,,0,0,0,,the rules will stop that 565 | Dialogue: 0,0:43:36.04,0:43:38.03,Default,,0,0,0,,it just point to something 566 | Dialogue: 0,0:43:38.56,0:43:42.68,Default,,0,0,0,,if we want to transfer ownership we can use unique_ptr 567 | Dialogue: 0,0:43:42.85,0:43:44.95,Default,,0,0,0,,if we really want to share ownership 568 | Dialogue: 0,0:43:45.17,0:43:47.70,Default,,0,0,0,,we can use shared_ptr 569 | Dialogue: 0,0:43:48.06,0:43:55.05,Default,,0,0,0,,but if we look at the T* it is familer, it's very general. 570 | Dialogue: 0,0:43:55.47,0:44:00.29,Default,,0,0,0,,if I have shared_ptr, I can take the pointer out of it and give it to f(); 571 | Dialogue: 0,0:44:00.48,0:44:02.95,Default,,0,0,0,,I don't have to do anything fancy. 572 | Dialogue: 0,0:44:03.30,0:44:05.53,Default,,0,0,0,,no dangling pointers 573 | Dialogue: 0,0:44:05.79,0:44:13.32,Default,,0,0,0,,and think about pointers degenerate things and it works 574 | Dialogue: 0,0:44:13.64,0:44:15.69,Default,,0,0,0,,so here is an example 575 | Dialogue: 0,0:44:16.19,0:44:21.97,Default,,0,0,0,,if g() and h() has been written using different kinds of pointers 576 | Dialogue: 0,0:44:22.36,0:44:30.49,Default,,0,0,0,,if I make it, f(shared_ptr), if I make a shared_ptr with make_shared 577 | Dialogue: 0,0:44:30.78,0:44:35.78,Default,,0,0,0,,then to call f(), I have to get the pointer 578 | Dialogue: 0,0:44:35.88,0:44:43.10,Default,,0,0,0,,if I'm calling g(), we have the overhead of using pointers 579 | Dialogue: 0,0:44:43.21,0:44:54.73,Default,,0,0,0,,and the h() I really have to modify. because if I pass the ownership in, I have to pass it out again unless I want it to be destoryed in h() 580 | Dialogue: 0,0:44:54.81,0:44:57.22,Default,,0,0,0,,so we can keep things simpler now 581 | Dialogue: 0,0:44:57.44,0:45:02.19,Default,,0,0,0,,simply use f(X*) as we always did. 582 | Dialogue: 0,0:45:03.71,0:45:09.39,Default,,0,0,0,,one question I've had quiet resonably is would the rules be enforced by a compiler? 583 | Dialogue: 0,0:45:09.84,0:45:12.15,Default,,0,0,0,,some could, some can't 584 | Dialogue: 0,0:45:12.72,0:45:15.91,Default,,0,0,0,,on the other hand, I would like to use thiese rules now. 585 | Dialogue: 0,0:45:16.14,0:45:19.55,Default,,0,0,0,,And I would like to use for all of the compilers 586 | Dialogue: 0,0:45:19.69,0:45:28.61,Default,,0,0,0,,so, yes, it'll be nice if the compiler would use some of these rules 587 | Dialogue: 0,0:45:28.67,0:45:29.24,Default,,0,0,0,,but 588 | Dialogue: 0,0:45:29.76,0:45:32.62,Default,,0,0,0,,please be careful don't have false positives 589 | Dialogue: 0,0:45:32.62,0:45:34.07,Default,,0,0,0,,people hate false positives 590 | Dialogue: 0,0:45:34.07,0:45:35.91,Default,,0,0,0,,and that destoryes the whole system 591 | Dialogue: 0,0:45:36.43,0:45:38.64,Default,,0,0,0,,because people does surprising things 592 | Dialogue: 0,0:45:38.84,0:45:40.34,Default,,0,0,0,,and not worrying it 593 | Dialogue: 0,0:45:40.41,0:45:41.67,Default,,0,0,0,,and further more 594 | Dialogue: 0,0:45:41.78,0:45:48.00,Default,,0,0,0,,an external tool is not just useful accross the span of compilers 595 | Dialogue: 0,0:45:48.57,0:45:52.69,Default,,0,0,0,,it also can tolerate a few more false positives 596 | Dialogue: 0,0:45:53.07,0:45:59.46,Default,,0,0,0,,and it can handle changes more easily 597 | Dialogue: 0,0:46:00.60,0:46:05.76,Default,,0,0,0,,you can use a compiler that enforce rules or the compiler are using false rules. 598 | Dialogue: 0,0:46:06.20,0:46:07.69,Default,,0,0,0,,having an external tool helps 599 | Dialogue: 0,0:46:07.69,0:46:09.93,Default,,0,0,0,,so let's start with an external tool. 600 | Dialogue: 0,0:46:10.01,0:46:15.24,Default,,0,0,0,,and if the compiler writers get interested, that's so much better 601 | Dialogue: 0,0:46:15.67,0:46:18.48,Default,,0,0,0,,and the other things 602 | Dialogue: 0,0:46:18.65,0:46:22.82,Default,,0,0,0,,why didn't we just use the standard only? 603 | Dialogue: 0,0:46:23.20,0:46:31.47,Default,,0,0,0,,because the standard currently as a stand doesn't have all the rules that we want for the standard for the GSL(the guideline library) 604 | Dialogue: 0,0:46:31.59,0:46:33.88,Default,,0,0,0,,we want to use things now! 605 | Dialogue: 0,0:46:34.57,0:46:38.76,Default,,0,0,0,,It's tiny, portable C++11 606 | Dialogue: 0,0:46:39.16,0:46:41.57,Default,,0,0,0,,it doesn't depend on other libraries. free-standing. 607 | Dialogue: 0,0:46:41.57,0:46:45.38,Default,,0,0,0,,you don't have to include whole broad of things you don't need. 608 | Dialogue: 0,0:46:48.30,0:46:52.01,Default,,0,0,0,,it's a similar tool but not identical to boost:: and experimental:: components 609 | Dialogue: 0,0:46:52.10,0:46:55.98,Default,,0,0,0,,that's actually good chance that it will become in some form or other. 610 | Dialogue: 0,0:46:55.98,0:46:57.36,Default,,0,0,0,,but we are not going to wait 611 | Dialogue: 0,0:46:57.46,0:46:58.90,Default,,0,0,0,,this is too simple 612 | Dialogue: 0,0:46:58.96,0:47:01.35,Default,,0,0,0,,too easy, let's get going. 613 | Dialogue: 0,0:47:01.35,0:47:02.33,Default,,0,0,0,,it's on github. 614 | Dialogue: 0,0:47:02.33,0:47:05.88,Default,,0,0,0,,some of you've accessed yesterday or the day before. 615 | Dialogue: 0,0:47:06.22,0:47:08.93,Default,,0,0,0,,and we use standard library 616 | Dialogue: 0,0:47:09.52,0:47:21.63,Default,,0,0,0,,one of the things that you find with reasonably comprehensive or reasonably good old rules set is that there's too many rules. 617 | Dialogue: 0,0:47:22.02,0:47:27.64,Default,,0,0,0,,we need to help novices, experts, people with infrastructures, applicaions, 618 | Dialogue: 0,0:47:27.64,0:47:27.80,Default,,0,0,0,,{\pos(287,363)}da 619 | Dialogue: 0,0:47:27.80,0:47:28.01,Default,,0,0,0,,{\pos(273,367)}da 620 | Dialogue: 0,0:47:28.01,0:47:28.13,Default,,0,0,0,,{\pos(241,360)}da 621 | Dialogue: 0,0:47:28.13,0:47:28.33,Default,,0,0,0,,{\pos(215,349)}da 622 | Dialogue: 0,0:47:28.33,0:47:28.47,Default,,0,0,0,,{\pos(157,361)}da 623 | Dialogue: 0,0:47:28.47,0:47:28.84,Default,,0,0,0,,{\pos(128,374)}da 624 | Dialogue: 0,0:47:29.10,0:47:33.08,Default,,0,0,0,,there are no way you can remember all of those rules 625 | Dialogue: 0,0:47:33.26,0:47:34.60,Default,,0,0,0,,further more 626 | Dialogue: 0,0:47:34.91,0:47:38.78,Default,,0,0,0,,I think I have 350 by now for this and no at the end. 627 | Dialogue: 0,0:47:38.99,0:47:41.34,Default,,0,0,0,,these's too many and you won't even need to go and read them. 628 | Dialogue: 0,0:47:41.45,0:47:47.44,Default,,0,0,0,,and, or, more interstingly, you don't need all those rules 629 | Dialogue: 0,0:47:48.67,0:47:51.76,Default,,0,0,0,,Most of you do it anyway, we don't make that mistakes 630 | Dialogue: 0,0:47:51.87,0:47:53.52,Default,,0,0,0,,that we relearned that 10 years ago 631 | Dialogue: 0,0:47:53.52,0:47:55.15,Default,,0,0,0,,so that all exist 632 | Dialogue: 0,0:47:54.79,0:47:56.81,Default,,0,0,0,,every body knows it. 633 | Dialogue: 0,0:47:57.02,0:47:57.89,Default,,0,0,0,,on the other hand 634 | Dialogue: 0,0:47:57.89,0:48:00.97,Default,,0,0,0,,the rules are for the people that don't know it 635 | Dialogue: 0,0:48:01.05,0:48:10.91,Default,,0,0,0,,the novices, the people that are casual users, people that has fifteen years experience on a different kind of code base. things like that, that's what the rules for. 636 | Dialogue: 0,0:48:11.27,0:48:15.43,Default,,0,0,0,,and you can't sit wasting your time programming 637 | Dialogue: 0,0:48:15.63,0:48:18.11,Default,,0,0,0,,trying to remember the rules or looking them up. 638 | Dialogue: 0,0:48:18.11,0:48:19.32,Default,,0,0,0,,NO! 639 | Dialogue: 0,0:48:19.37,0:48:23.05,Default,,0,0,0,,further more, you won't get there because the rules are extensible. 640 | Dialogue: 0,0:48:23.05,0:48:25.15,Default,,0,0,0,,as we learned we add rules 641 | Dialogue: 0,0:48:25.34,0:48:28.19,Default,,0,0,0,,so if last month you wrote something, 642 | Dialogue: 0,0:48:28.38,0:48:31.72,Default,,0,0,0,,and you fulfill all the rules and this month you try again. 643 | Dialogue: 0,0:48:32.16,0:48:35.40,Default,,0,0,0,,we hope to catch you again with some new rules. 644 | Dialogue: 0,0:48:35.68,0:48:44.53,Default,,0,0,0,,that verified priciple, valided by experience will be helpful 645 | Dialogue: 0,0:48:44.81,0:48:49.36,Default,,0,0,0,,and you shouldn't know all the rules, the tool knows the rules. 646 | Dialogue: 0,0:48:49.52,0:48:56.35,Default,,0,0,0,,my idea is that you run the tool and it drop you right in there showing the rule on the screen. 647 | Dialogue: 0,0:48:57.24,0:48:59.28,Default,,0,0,0,,what was the rule that violated? 648 | Dialogue: 0,0:48:59.28,0:49:00.96,Default,,0,0,0,,where was it violated? 649 | Dialogue: 0,0:49:00.96,0:49:02.91,Default,,0,0,0,,what's the rational for the rule? 650 | Dialogue: 0,0:49:02.91,0:49:07.48,Default,,0,0,0,,what's the example of how bad it can get from problems like that? 651 | Dialogue: 0,0:49:07.54,0:49:09.31,Default,,0,0,0,,and here is what you should do instead. 652 | Dialogue: 0,0:49:09.39,0:49:10.93,Default,,0,0,0,,That's what I would like to see. 653 | Dialogue: 0,0:49:12.75,0:49:15.32,Default,,0,0,0,,so thers is too many rules that doesn't worry me. 654 | Dialogue: 0,0:49:15.40,0:49:16.96,Default,,0,0,0,,I want lots of rules. 655 | Dialogue: 0,0:49:17.47,0:49:21.45,Default,,0,0,0,,here is a set of classification 656 | Dialogue: 0,0:49:21.62,0:49:23.66,Default,,0,0,0,,there is philosophical rules 657 | Dialogue: 0,0:49:23.80,0:49:26.33,Default,,0,0,0,,basically the conceptual framework 658 | Dialogue: 0,0:49:26.59,0:49:28.66,Default,,0,0,0,,that cannot be validated 659 | Dialogue: 0,0:49:28.70,0:49:32.73,Default,,0,0,0,,but it's really good if you understood what been said there. 660 | Dialogue: 0,0:49:33.33,0:49:36.98,Default,,0,0,0,,if nothing else you'll know what we were thinking when we wrote them 661 | Dialogue: 0,0:49:37.61,0:49:43.04,Default,,0,0,0,,and then there's all kinds of things, interfaces, functions, classes, class hierarchies 662 | Dialogue: 0,0:49:43.04,0:49:43.19,Default,,0,0,0,,{\pos(48,248)}da 663 | Dialogue: 0,0:49:43.19,0:49:43.42,Default,,0,0,0,,{\pos(39,269)}da 664 | Dialogue: 0,0:49:43.42,0:49:43.55,Default,,0,0,0,,{\pos(66,314)}da 665 | Dialogue: 0,0:49:43.56,0:49:43.77,Default,,0,0,0,,{\pos(24,408)}da 666 | Dialogue: 0,0:49:43.75,0:49:43.90,Default,,0,0,0,,{\pos(69,423)}da 667 | Dialogue: 0,0:49:43.90,0:49:44.16,Default,,0,0,0,,{\pos(100,437)}da 668 | Dialogue: 0,0:49:45.27,0:49:48.50,Default,,0,0,0,, there's supporting sections, naming and layout 669 | Dialogue: 0,0:49:48.50,0:49:53.89,Default,,0,0,0,,that's where every body goes and they say they don't like the rules we wrote that's fine. 670 | Dialogue: 0,0:49:53.89,0:49:57.44,Default,,0,0,0,,never made anybody that the whole set of rules 671 | Dialogue: 0,0:49:57.56,0:49:59.66,Default,,0,0,0,,people say that they want camel case. 672 | Dialogue: 0,0:49:59.82,0:50:01.95,Default,,0,0,0,,sure, I hate camel case 673 | Dialogue: 0,0:50:02.07,0:50:03.17,Default,,0,0,0,,apart from that. 674 | Dialogue: 0,0:50:03.26,0:50:06.96,Default,,0,0,0,,what that c# camel case or java camel case ? 675 | Dialogue: 0,0:50:08.45,0:50:09.94,Default,,0,0,0,,there's just too much of it 676 | Dialogue: 0,0:50:09.99,0:50:11.68,Default,,0,0,0,,there's rules for performence. 677 | Dialogue: 0,0:50:11.68,0:50:13.68,Default,,0,0,0,,some people interested in performence 678 | Dialogue: 0,0:50:13.68,0:50:15.64,Default,,0,0,0,,there's different kinds of performence 679 | Dialogue: 0,0:50:15.73,0:50:23.22,Default,,0,0,0,,some of these rules, you can go up and look at today now. but some of the areas are weak. 680 | Dialogue: 0,0:50:23.29,0:50:25.76,Default,,0,0,0,,the guidence for standard library is weak 681 | Dialogue: 0,0:50:26.04,0:50:30.02,Default,,0,0,0,,the standard for concurrency is fairly weak 682 | Dialogue: 0,0:50:30.31,0:50:32.85,Default,,0,0,0,,because we hadn't have enough time 683 | Dialogue: 0,0:50:32.88,0:50:39.83,Default,,0,0,0,,this as a project that infact started in April and we are shipping now. 684 | Dialogue: 0,0:50:41.91,0:50:48.27,Default,,0,0,0,,This talk is trying to encourage you to help, to make it a community, a large community project 685 | Dialogue: 0,0:50:48.45,0:50:52.20,Default,,0,0,0,,it is not some kind of polished academic things we'd like to 686 | Dialogue: 0,0:50:52.20,0:50:56.02,Default,,0,0,0,,if we love to prove greate levels then this is the right thing 687 | Dialogue: 0,0:50:56.34,0:51:02.29,Default,,0,0,0,,no, this is an attempt to do something major and something interesting. 688 | Dialogue: 0,0:51:02.29,0:51:04.24,Default,,0,0,0,,this is not unambitious 689 | Dialogue: 0,0:51:04.65,0:51:16.52,Default,,0,0,0,,we're trying to scale to the 4+ million c++ programmers and a few billion lines of code while not break the zero-overhead principle. 690 | Dialogue: 0,0:51:17.25,0:51:19.35,Default,,0,0,0,,so the code will be better 691 | Dialogue: 0,0:51:20.11,0:51:25.96,Default,,0,0,0,,no type errors, no resource leaks, no dangling pointers 692 | Dialogue: 0,0:51:25.96,0:51:26.08,Default,,0,0,0,,{\pos(290,406)}da 693 | Dialogue: 0,0:51:26.08,0:51:26.27,Default,,0,0,0,,{\pos(301,402)}da 694 | Dialogue: 0,0:51:26.27,0:51:26.39,Default,,0,0,0,,{\pos(323,397)}da 695 | Dialogue: 0,0:51:26.40,0:51:26.71,Default,,0,0,0,,{\pos(319,407)}da 696 | Dialogue: 0,0:51:26.62,0:51:32.76,Default,,0,0,0,,we go after our least favorite bugs 697 | Dialogue: 0,0:51:34.44,0:51:38.85,Default,,0,0,0,,so it's a full speed ahead, and we expect some rough waters 698 | Dialogue: 0,0:51:39.30,0:51:44.18,Default,,0,0,0,,if you are thinking of a sailing ship you can actually sail faster if there is a storm going on 699 | Dialogue: 0,0:51:44.50,0:51:46.24,Default,,0,0,0,,what's what we're headding into. 700 | Dialogue: 0,0:51:46.61,0:51:51.03,Default,,0,0,0,,we actually aim to change the way we write code 701 | Dialogue: 0,0:51:51.52,0:51:53.52,Default,,0,0,0,,and that means {\b1}YOU{\b0}. 702 | Dialogue: 0,0:51:54.96,0:52:00.20,Default,,0,0,0,,what would you like your code to look like in 5 or 10 years? 703 | Dialogue: 0,0:52:01.30,0:52:07.01,Default,,0,0,0,,and really honestly if the answer is {\i1}just like what I wrote yesterday{\i0} 704 | Dialogue: 0,0:52:07.51,0:52:10.13,Default,,0,0,0,,there are some failling imagination here. 705 | Dialogue: 0,0:52:10.45,0:52:12.69,Default,,0,0,0,,we really want to make change 706 | Dialogue: 0,0:52:12.69,0:52:14.00,Default,,0,0,0,,that can be painful 707 | Dialogue: 0,0:52:14.53,0:52:21.01,Default,,0,0,0,,it's not easy to modernize code, it's not easy to modernize a large codebase, it is painful 708 | Dialogue: 0,0:52:21.57,0:52:27.11,Default,,0,0,0,,but, you know, if you don't do it. you have the same pain from your existing code 709 | Dialogue: 0,0:52:27.47,0:52:30.94,Default,,0,0,0,,that now 10 years old code in 5 years will be 15 years old!] 710 | Dialogue: 0,0:52:30.94,0:52:32.94,Default,,0,0,0,, and it is not going to feel any better! 711 | Dialogue: 0,0:52:33.87,0:52:40.11,Default,,0,0,0,,and gradual adaption, of course is nessesary for this. 712 | Dialogue: 0,0:52:40.34,0:52:52.24,Default,,0,0,0,,the idea of taking 5 million lines of codebase and saying, ok we just change this, and after the weekend we'll use the new version 713 | Dialogue: 0,0:52:52.26,0:52:53.56,Default,,0,0,0,,hmmm... 714 | Dialogue: 0,0:52:53.81,0:52:55.93,Default,,0,0,0,,probably not. 715 | Dialogue: 0,0:52:56.18,0:53:01.12,Default,,0,0,0,,we will not agree what the code should look like so there'll be some discussions. 716 | Dialogue: 0,0:53:01.55,0:53:04.70,Default,,0,0,0,,part of it will be, that not all code should look the same 717 | Dialogue: 0,0:53:05.15,0:53:15.01,Default,,0,0,0,,I really don't want work under constraints from my flight control software when I'm writting ordinary applications, it just too painful 718 | Dialogue: 0,0:53:15.19,0:53:19.16,Default,,0,0,0,,on the other hand there'll be discussion about what is common and what isn't. 719 | Dialogue: 0,0:53:19.28,0:53:24.69,Default,,0,0,0,,if you look at the rules you'll find that some of them are some what controversial. 720 | Dialogue: 0,0:53:24.95,0:53:26.56,Default,,0,0,0,,and that's fine. 721 | Dialogue: 0,0:53:27.66,0:53:29.22,Default,,0,0,0,,I just choose what I'm presume right answer. 722 | Dialogue: 0,0:53:29.36,0:53:32.38,Default,,0,0,0,,if you don't agree, I'll willing to argue with you. 723 | Dialogue: 0,0:53:32.53,0:53:34.54,Default,,0,0,0,,so that's going to be fun! 724 | Dialogue: 0,0:53:34.91,0:53:36.85,Default,,0,0,0,,and help wanted 725 | Dialogue: 0,0:53:36.97,0:53:39.94,Default,,0,0,0,,look at the rules, help reviewing them 726 | Dialogue: 0,0:53:40.26,0:53:42.34,Default,,0,0,0,,help man suggest new rules 727 | Dialogue: 0,0:53:42.34,0:53:45.15,Default,,0,0,0,,help suggest better explanation of the rules 728 | Dialogue: 0,0:53:46.03,0:53:49.42,Default,,0,0,0,,currently there's only two editors of this, me and Herb Sutter. 729 | Dialogue: 0,0:53:49.69,0:53:52.23,Default,,0,0,0,,that is too lower number. 730 | Dialogue: 0,0:53:52.23,0:53:54.11,Default,,0,0,0,,so we need more editors 731 | Dialogue: 0,0:53:54.19,0:53:57.08,Default,,0,0,0,,but you have to earn your right to be an editor 732 | Dialogue: 0,0:53:57.08,0:54:01.76,Default,,0,0,0,,that's a crucial positon in the community 733 | Dialogue: 0,0:54:01.97,0:54:05.58,Default,,0,0,0,,so the current status, about 350 rules. 734 | Dialogue: 0,0:54:05.92,0:54:07.88,Default,,0,0,0,,and there's a github for it 735 | Dialogue: 0,0:54:08.80,0:54:12.30,Default,,0,0,0,,we put it live I think friday 736 | Dialogue: 0,0:54:12.92,0:54:16.55,Default,,0,0,0,,and we already getting pull requests. 737 | Dialogue: 0,0:54:16.80,0:54:20.79,Default,,0,0,0,,and thers's guidelines support library. 738 | Dialogue: 0,0:54:20.90,0:54:28.56,Default,,0,0,0,,tested on clang, gcc, microsoft on windows, linux and mac 739 | Dialogue: 0,0:54:28.68,0:54:30.80,Default,,0,0,0,,it's avaliable now 740 | Dialogue: 0,0:54:30.90,0:54:32.84,Default,,0,0,0,,the first tool should come 741 | Dialogue: 0,0:54:32.86,0:54:35.68,Default,,0,0,0,,microsoft is shipping something I think next month 742 | Dialogue: 0,0:54:35.81,0:54:38.72,Default,,0,0,0,,I don't know their shipping schedules so it can't be percise. 743 | Dialogue: 0,0:54:38.90,0:54:44.92,Default,,0,0,0,,and we hope ports to the other systems comming right after. 744 | Dialogue: 0,0:54:45.09,0:54:54.66,Default,,0,0,0,,it's written as fairly intentive portable iso c++, so that should work. 745 | Dialogue: 0,0:54:55.02,0:54:57.10,Default,,0,0,0,,and we need help 746 | Dialogue: 0,0:54:57.79,0:54:59.06,Default,,0,0,0,,and 747 | Dialogue: 0,0:54:59.43,0:55:05.03,Default,,0,0,0,,this paper, from my perspective means, that the basic c++ model is actually complete 748 | Dialogue: 0,0:55:05.54,0:55:22.90,Default,,0,0,0,,hours going for the idea that you could get perfect resource safety and type safety now have been trying to get there for many many years, it was the idea from day 1 and I knew we couldn't get there in any time soon, I think we are there (now) 749 | Dialogue: 0,0:55:24.87,0:55:25.86,Default,,0,0,0,,BTW 750 | Dialogue: 0,0:55:25.86,0:55:28.35,Default,,0,0,0,,if you look at my definition of resource safety 751 | Dialogue: 0,0:55:28.58,0:55:32.61,Default,,0,0,0,,you'll see that it's really not very many languages that can claim that. 752 | Dialogue: 0,0:55:33.04,0:55:38.84,Default,,0,0,0,,and for static type safety, not very many languages can claim that. 753 | Dialogue: 0,0:55:39.26,0:55:46.91,Default,,0,0,0,,no range errors and dereference errors without serious overhead, more language can cliam that but it's still hard. 754 | Dialogue: 0,0:55:47.40,0:55:50.11,Default,,0,0,0,,this is not unambitious as I said 755 | Dialogue: 0,0:55:50.24,0:55:55.98,Default,,0,0,0,,we now have concepts so we can deal templates in a more resonable way 756 | Dialogue: 0,0:55:56.41,0:56:00.78,Default,,0,0,0,,so, with all of the problems solved from the resource point of view 757 | Dialogue: 0,0:56:01.04,0:56:04.13,Default,,0,0,0,,why didn't I just go back to academia and design a new language? 758 | Dialogue: 0,0:56:04.13,0:56:06.36,Default,,0,0,0,,That's after all what most people do right? 759 | Dialogue: 0,0:56:06.36,0:56:07.86,Default,,0,0,0,,it's a cool thing to do 760 | Dialogue: 0,0:56:08.07,0:56:09.27,Default,,0,0,0,,etc 761 | Dialogue: 0,0:56:09.25,0:56:11.66,Default,,0,0,0,,competing wieh c++ is hard 762 | Dialogue: 0,0:56:11.90,0:56:19.97,Default,,0,0,0,,I put these toolchains up there to show what anybody with a new languages are up against. 763 | Dialogue: 0,0:56:21.06,0:56:26.32,Default,,0,0,0,,competing with c++ has over the years not been the winning strategy 764 | Dialogue: 0,0:56:26.60,0:56:28.24,Default,,0,0,0,,and 765 | Dialogue: 0,0:56:28.45,0:56:30.33,Default,,0,0,0,,it'll take, take time 766 | Dialogue: 0,0:56:30.50,0:56:38.21,Default,,0,0,0,,and further more, certainly going into a new language could fracture the c++ community which is among the last thing I want to do. 767 | Dialogue: 0,0:56:38.98,0:56:41.37,Default,,0,0,0,,so, we're going for something that can work now! 768 | Dialogue: 0,0:56:41.92,0:56:46.06,Default,,0,0,0,,guidelines and tools, hope to get there. 769 | Dialogue: 0,0:56:46.41,0:56:59.04,Default,,0,0,0,,so, with that, I'll switch to questions and I left the outline of the guidelines up there. 770 | Dialogue: 0,0:56:59.14,0:57:00.48,Default,,0,0,0,,by the way 771 | Dialogue: 0,0:57:00.74,0:57:06.69,Default,,0,0,0,,what we called guide there is Helios, Hercules fighting the Hydra. 772 | Dialogue: 0,0:57:06.93,0:57:09.45,Default,,0,0,0,,this is a bit like what I feels like 773 | Dialogue: 0,0:57:09.62,0:57:14.39,Default,,0,0,0,,we have many-headed monster we have to fight. 774 | Dialogue: 0,0:57:14.56,0:57:19.20,Default,,0,0,0,,and there's a nasty tendency of getting more heads as we make progress 775 | Dialogue: 0,0:57:19.46,0:57:20.43,Default,,0,0,0,,so, thank you! 776 | Dialogue: 0,0:57:21.29,0:57:31.37,居中标题,,0,0,0,,~感谢 avplayer.org 制作英文字幕~ 777 | Dialogue: 0,0:57:33.10,0:57:36.61,Default,,0,0,0,,is there mic-phone somewhere? 778 | Dialogue: 0,0:57:37.81,0:57:43.87,演讲回答,,0,0,0,,OK, I am back. so the questions is "why do I mark the owner rather than non-owner?" 779 | Dialogue: 0,0:57:44.50,0:57:46.35,演讲回答,,0,0,0,,yes we discussed that 780 | Dialogue: 0,0:57:47.70,0:57:56.00,演讲回答,,0,0,0,,My conjecture is that there are too many hundreds of millions lines of code that uses T* to mean non-owner. 781 | Dialogue: 0,0:57:58.02,0:58:01.12,演讲回答,,0,0,0,,and I really don't want people to write very many owners. 782 | Dialogue: 0,0:58:01.21,0:58:04.03,演讲回答,,0,0,0,,I want the owers to disapper into abstractions 783 | Dialogue: 0,0:58:05.11,0:58:09.73,演讲回答,,0,0,0,,as for now, there are many more non-owners and owners 784 | Dialogue: 0,0:58:19.68,0:58:22.13,演讲回答,,0,0,0,,in the future, I expect there to be a thousand or more than a thousand times as many non-owners as owners in code 785 | Dialogue: 0,0:58:19.78,0:58:25.38,演讲回答,,0,0,0,,because pointers are now getting safer and you can use them more freely 786 | Dialogue: 0,0:58:25.54,0:58:30.40,演讲回答,,0,0,0,,so I think a got the owner/non-owner default correct. 787 | Dialogue: 0,0:58:30.50,0:58:37.33,演讲回答,,0,0,0,,maybe the first time in history of c++ we got default right. but I'm pretty sure this one is right! 788 | Dialogue: 0,0:58:39.46,0:58:40.64,Default,主持人,0,0,0,,{\pos(1673,414)}Question here 789 | Dialogue: 0,0:58:41.25,0:58:41.78,Default,,0,0,0,,{\pos(1702,218)}there 790 | Dialogue: 0,0:58:42.77,0:58:43.17,观众提问,,0,0,0,,Hi! 791 | Dialogue: 0,0:58:43.92,0:59:00.53,观众提问,,0,0,0,,I had a question about owner T. and one thing I was confused about is that, is owner T is just something that is used at compile time or does it use any sort of like runtime overhead or ? 792 | Dialogue: 0,0:59:00.53,0:59:05.44,演讲回答,,0,0,0,,it's something that used only at compile time and it does absolutely nothing (at runtime) 793 | Dialogue: 0,0:59:06.05,0:59:15.33,演讲回答,,0,0,0,,it is something that guides or an enforcement tool to see what you suppose to do with it. 794 | Dialogue: 0,0:59:15.49,0:59:18.79,演讲回答,,0,0,0,,in paticular, if you're not an owner, you're not suppose to delete it 795 | Dialogue: 0,0:59:19.02,0:59:21.01,演讲回答,,0,0,0,,you're not going to pass it to an owner. 796 | Dialogue: 0,0:59:21.33,0:59:23.41,演讲回答,,0,0,0,,if you are an owner. 797 | Dialogue: 0,0:59:23.44,0:59:28.93,演讲回答,,0,0,0,,you have better either give it to somebody else who is also an owner or delete it 798 | Dialogue: 0,0:59:29.62,0:59:33.38,演讲回答,,0,0,0,,a tool can verify that, it doesn't do anything. 799 | Dialogue: 0,0:59:33.73,0:59:37.84,演讲回答,,0,0,0,,you can encapsulated an owner into a, say, unique pointer. 800 | Dialogue: 0,0:59:38.05,0:59:42.67,演讲回答,,0,0,0,,and then just use it because it does the delete and has the right semantics 801 | Dialogue: 0,0:59:42.67,0:59:46.21,演讲回答,,0,0,0,,the owner is a low-level marker to help static analysis 802 | Dialogue: 0,0:59:46.44,0:59:55.62,演讲回答,,0,0,0,,I didn't mention but I sure static analysis is local, static analysis using very few rules, it's going to be fast 803 | Dialogue: 0,0:59:55.65,1:00:00.02,演讲回答,,0,0,0,,it's not one of these going to be in cute algorithm over all of your code 804 | Dialogue: 0,1:00:00.17,1:00:03.38,演讲回答,,0,0,0,,it is local rules 805 | Dialogue: 0,1:00:04.95,1:00:10.02,观众提问,,0,0,0,,What happens when you move from not null? 806 | Dialogue: 0,1:00:10.84,1:00:13.87,演讲回答,,0,0,0,,What happens when I move from not null? 807 | Dialogue: 0,1:00:14.52,1:00:15.50,演讲回答,,0,0,0,,into what? 808 | Dialogue: 0,1:00:15.70,1:00:25.94,观众提问,,0,0,0,,you moved and the remaining status becomes null, right? 809 | Dialogue: 0,1:00:26.21,1:00:27.45,演讲回答,,0,0,0,,emmm 810 | Dialogue: 0,1:00:31.26,1:00:38.13,演讲回答,,0,0,0,,if you move from a pointer. it's just a copy. so it doesn't become null 811 | Dialogue: 0,1:00:38.50,1:00:44.16,演讲回答,,0,0,0,,if you generalized it to smart pointers and such 812 | Dialogue: 0,1:00:44.27,1:00:53.00,演讲回答,,0,0,0,,it will have to have the appropriate semantics, I don't know the implementations there, you should ask Neil Macintosh on Wednesday 813 | Dialogue: 0,1:00:53.01,1:00:58.84,演讲回答,,0,0,0,,he is one of the editor of the last version of the implementation which I haven't read yet 814 | Dialogue: 0,1:00:58.95,1:01:01.54,演讲回答,,0,0,0,,he made some improvements last week 815 | Dialogue: 0,1:01:01.61,1:01:05.82,演讲回答,,0,0,0,,but basically, no, you can not violate not_null that easy 816 | Dialogue: 0,1:01:13.67,1:01:18.52,观众提问,,0,0,0,,I'm guessing 817 | Dialogue: 0,1:02:44.90,1:03:03.57,观众提问,,0,0,0,,总结起来就一句话: do you have guidelines for makeing C api safer in c++? 818 | Dialogue: 0,1:03:04.37,1:03:10.58,演讲回答,,0,0,0,,I have no plans of dealing with foreign systems. 819 | Dialogue: 0,1:03:10.67,1:03:14.77,演讲回答,,0,0,0,,that will not be in the core guidelines 820 | Dialogue: 0,1:03:15.17,1:03:34.76,演讲回答,,0,0,0,,but I wouldn't be at all surprised and I'll be very happy if somebody would write a section asist how to interact with *, how to interact java, how to interact with python, I really hope to see somebody write those sections. 821 | Dialogue: 0,1:03:34.87,1:03:41.56,演讲回答,,0,0,0,,quiet likely they will be of the form that you can do this the static analysis to make it simpler 822 | Dialogue: 0,1:03:41.67,1:03:47.44,演讲回答,,0,0,0,,you can have this tiny tiny little setup classes for doing the transmission 823 | Dialogue: 0,1:03:47.61,1:03:49.84,演讲回答,,0,0,0,, 824 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | 663 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CppCon 2 | subtitles for CppCon2014 CppCon2015 CppCon2016 ..... 3 | --------------------------------------------------------------------------------