back to index

Bjarne Stroustrup: C++ | Lex Fridman Podcast #48


small model | large model

link |
00:00:00.000
The following is a conversation with Bjarn Strelstrom. He's a creator of C++, a programming
link |
00:00:06.240
language that after 40 years is still one of the most popular and powerful languages in the world.
link |
00:00:12.480
Its focus on fast, stable, robust code underlies many of the biggest systems in the world
link |
00:00:18.080
that we have come to rely on as a society. If you're watching this on YouTube, for example,
link |
00:00:23.120
many of the critical backend components of YouTube are written in C++. Same goes for Google,
link |
00:00:29.280
Facebook, Amazon, Twitter, most Microsoft applications, Adobe applications, most database
link |
00:00:35.120
systems and most physical systems that operate in the real world like cars, robots, rockets that
link |
00:00:42.080
launch us into space and one day will land us on Mars. C++ also happens to be the language
link |
00:00:49.840
that I use more than any other in my life. I've written several hundred thousand lines of C++
link |
00:00:55.600
source code. Of course, lines of source code don't mean much, but they do give hints of my
link |
00:01:01.440
personal journey through the world of software. I've enjoyed watching the development of C++
link |
00:01:06.800
as a programming language leading up to the big update in the standard in 2011 and those that
link |
00:01:12.960
followed in 14, 17 and toward the new C++20 standard hopefully coming out next year.
link |
00:01:20.240
This is the Artificial Intelligence Podcast. If you enjoy it, subscribe on YouTube, give it
link |
00:01:26.560
five stars on iTunes, support it on Patreon, or simply connect with me on Twitter at Lex
link |
00:01:31.840
Friedman, spelled F R I D M A N. And now here's my conversation with Bjorn Straussstroke.
link |
00:01:40.240
What was the first program you've ever written? Do you remember?
link |
00:01:44.000
It was my second year in university, first year of computer science and it was an Algor 60.
link |
00:01:53.520
I calculated the shape of a super ellipse and then connected points on the perimeter,
link |
00:02:02.320
creating star patterns. It was with a wedding on a paper printer.
link |
00:02:10.400
And that was in college, university? Yeah. I learned to program the second year in university.
link |
00:02:18.400
And what was the first programming language, if I may ask it this way, that you fell in love with?
link |
00:02:26.480
I think Algor 60 and after that I remember I remember Snowball. I remember Fortran didn't
link |
00:02:38.480
fall in love with that. I remember Pascal didn't fall in love with that. It already got in the
link |
00:02:43.840
way of me. And then I discovered Assembler and that was much more fun. And from there I went to
link |
00:02:53.200
microcode. So you were drawn to the, you found the low level stuff beautiful?
link |
00:03:01.120
I went through a lot of languages and then I spent significant time in Assembler and microcode.
link |
00:03:09.440
That was sort of the first really profitable things I paid for my masters actually.
link |
00:03:15.360
And then I discovered Simula, which was absolutely great.
link |
00:03:19.520
Simula? Simula was the extension of Algor 60 done primarily for simulation, but basically
link |
00:03:28.800
they invented object oriented programming at inheritance and runtime polymorphism while
link |
00:03:35.360
they were doing it. And that was a language that taught me that you could have the sort of the
link |
00:03:45.600
problems of a program grow with the size of the program rather than with the square of the size
link |
00:03:51.840
of the program. That is, you can actually modularize very nicely. And that was a surprise to me.
link |
00:04:00.560
It was also a surprise to me that a stricter type system than Pascal's was helpful, whereas
link |
00:04:08.720
Pascal's type system got in my way all the time. So you need a strong type system to organize your
link |
00:04:17.760
code well, but it has to be extensible and flexible. Let's get into the details a little bit. What
link |
00:04:23.680
if you remember what kind of type system did Pascal have? What type system typing system did Algor
link |
00:04:29.680
60 have? Basically, Pascal was sort of the simplest language that Nicholas could define
link |
00:04:38.960
that served the needs of Nicholas. We had at the time and it has a sort of a highly
link |
00:04:46.640
moral tone to it. That is, if you can say it in Pascal, it's good. And if you can't, it's not so good.
link |
00:04:54.560
Whereas, Simula, allowed you basically to build your own type system. So instead of trying to fit
link |
00:05:05.280
yourself into Nicholas Vietz's world, Christen Nugol's language and Oliwann Dahl's language
link |
00:05:13.920
allowed you to build your own. So it's sort of close to the original idea of you build a domain
link |
00:05:22.640
specific language. As a matter of fact, what you build is a set of types and relations among types
link |
00:05:31.200
that allows you to express something that's suitable for an application.
link |
00:05:36.160
So when you say types, stuff you're saying has echoes of object during a programming.
link |
00:05:42.080
Yes, they invented it. Every language that uses the word class for type is a descent of Simula,
link |
00:05:52.000
directly or indirectly. Christen Nugol and Oliwann Dahl were mathematicians and they didn't think in
link |
00:06:01.360
terms of types, but they understood sets and classes of elements and so they called their
link |
00:06:09.520
types classes. And basically in C++, as in Simula, classes are user defined type.
link |
00:06:18.560
So can you try the impossible task and give a brief history of programming languages from
link |
00:06:25.200
your perspective? So we started with Algal 60, Simula, Pascal, but that's just the 60s and 70s.
link |
00:06:33.200
I can try. The most sort of interesting and major improvement of programming languages was
link |
00:06:43.600
Fortran, the first Fortran. Because before that, all code was written for a specific machine and
link |
00:06:49.840
each specific machine had a language, a simply language or a core Simula or some extension
link |
00:06:58.800
of that idea, but you are writing for a specific machine in the language of that machine.
link |
00:07:06.960
And Barker and his team at IBM built a language that would allow you to write what you really
link |
00:07:17.120
wanted. That is, you could write it in a language that was natural for people. Now these people
link |
00:07:24.080
happened to be engineers and physicists, so the language that came out was somewhat unusual for
link |
00:07:29.280
the rest of the world. But basically they said formula translation because they wanted to have
link |
00:07:34.240
the mathematical formulas translated into the machine. And as a side effect, they got portability
link |
00:07:43.200
because now they are writing in the terms that the humans used and the way humans thought.
link |
00:07:49.920
And then they had a program that translated it into the machine's needs. And that was new and
link |
00:07:56.720
that was great. And it's something to remember. We want to raise the language to the human level,
link |
00:08:04.800
but we don't want to lose the efficiency. And that was the first step towards the human?
link |
00:08:11.440
That was the first step. And of course, there were very particular kinds of humans,
link |
00:08:16.800
business people who were different, so they got cobalt instead and et cetera, et cetera.
link |
00:08:23.680
And Simula came out. No, let's not go to Simula yet. Let's go to Algor. Fortran didn't have,
link |
00:08:33.280
at the time, the notions of not a precise notion of type, not a precise notion of scope,
link |
00:08:40.800
not a set of translation phases that was what we have today, lexical, syntax, semantics. It was
link |
00:08:52.560
sort of a bit of a model in the early days, but hey, they had just done the biggest breakthrough
link |
00:08:59.280
in the history of programming. So you can't criticize them for not having gotten all the
link |
00:09:04.560
technical details right. So we got Algor. That was very pretty. And most people in commerce
link |
00:09:13.760
and science considered it useless because it was not flexible enough and it wasn't efficient enough
link |
00:09:19.920
and et cetera, et cetera. But that was the breakthrough from the technical point of view.
link |
00:09:25.520
And then Simula came along to make that idea more flexible and you could define your own types. And
link |
00:09:35.200
that's where I got very interested. Preston Nygo, who's the main idea man behind Simula.
link |
00:09:43.920
That was late 60s.
link |
00:09:45.120
This was late 60s. Well, I was a visiting professor in Aarhus. And so I learned object
link |
00:09:52.000
oriented programming by sitting around and well, in theory, discussing with
link |
00:10:01.280
Kaisen Nygo. But Kaisen, once you get started and in full flow, it's very hard to get a word in
link |
00:10:09.200
edge ways with you just listen. So it was great. I learned it from there.
link |
00:10:14.160
Not to romanticize the notion, but it seems like a big leap to think about object oriented programming.
link |
00:10:20.160
It's really a leap of abstraction. Yes.
link |
00:10:25.840
And was that as big and beautiful of a leap as it seems from now in retrospect,
link |
00:10:34.800
or was it an obvious one at the time?
link |
00:10:38.160
It was not obvious. And many people have tried to do something like that. And most people didn't
link |
00:10:45.600
come up with something as wonderful as Simula. Lots of people got their PhDs and made their
link |
00:10:52.800
careers out of forgetting about Simula or never knowing it. For me, the key idea was basically
link |
00:11:00.480
I could get my own types. And that's the idea that goes further into C++, where I can get
link |
00:11:09.680
better types and more flexible types and more efficient types. But it's still the
link |
00:11:14.160
fundamental idea when I want to write a program, I want to write it with my types.
link |
00:11:19.200
That is appropriate to my problem and under the constraints that I'm under with hardware,
link |
00:11:27.200
software, environment, etc. And that's the key idea. People picked up on the class hierarchies
link |
00:11:36.400
and the virtual functions and the inheritance. And that was only part of it. It was an
link |
00:11:44.880
interesting and major part and still a major part and a lot of graphic stuff.
link |
00:11:50.160
But it was not the most fundamental. It was when you wanted to relate one type to another,
link |
00:11:57.840
you don't want them all to be independent. The classical example is that you don't
link |
00:12:04.320
actually want to write a city simulation with vehicles where you say, well, if it's a bicycle,
link |
00:12:13.360
write the code for turning a bicycle to the left, if it's a normal car, turn right the normal car
link |
00:12:19.200
way, if it's a fire engine, turn right the fire engine, you get these big case statements and
link |
00:12:26.240
bunches of if statements and such. Instead, you tell the base class that that's the vehicle and say,
link |
00:12:36.240
turn left the way you want to. And this is actually a real example. They used it to simulate
link |
00:12:45.040
and optimize the emergency services for somewhere in Norway back in the 60s.
link |
00:12:54.560
Wow. So this was one of the early examples for why you needed inheritance and you needed
link |
00:13:03.120
runtime polymorphism because you wanted to handle this set of vehicles in a manageable way.
link |
00:13:13.760
You can't just rewrite your code each time a new kind of vehicle comes along.
link |
00:13:18.640
Yeah, that's a beautiful, powerful idea. And of course, it is stretched through your work
link |
00:13:24.800
with C++ as we'll talk about. But I think you structured nicely what other breakthroughs came
link |
00:13:33.440
along in the history of programming languages. If we were to tell the history in that way.
link |
00:13:39.520
Obviously, I'm better telling the part of the history that that is the part that I'm on as
link |
00:13:44.720
opposed to all the parts. Yeah, you skipped the hippie John McCarthy and Lisb, one of my favorite
link |
00:13:50.960
languages. But Lisb is not one of my favorite languages. It's obviously important. It's obviously
link |
00:13:59.040
interesting. Lots of people write code in it. And then they rewrite it into CSE++ when they want to
link |
00:14:05.520
go to production. It's in the world I'm at, which are constrained by performance, reliability,
link |
00:14:17.520
issues, deployability, cost of hardware. I don't like things to be too dynamic.
link |
00:14:26.400
It is really hard to write a piece of code that's perfectly flexible
link |
00:14:31.520
that you can also deploy on a small computer. And that you can also put in, say, a telephone switch
link |
00:14:38.640
in Bogota. What's the chance if you get an error and you find yourself in the debugger
link |
00:14:44.640
that the telephone switch in Bogota on late Sunday night has a programmer around?
link |
00:14:50.160
Right. The chance is zero. And so a lot of things I think most about
link |
00:14:55.840
most about can't afford that flexibility. I'm quite aware that maybe 70, 80% of all code
link |
00:15:09.200
are not under the kind of constraints I'm interested in. But somebody has to do the job I'm doing
link |
00:15:17.120
because you have to get from these high level flexible languages to the hardware.
link |
00:15:22.960
The stuff that lasts for 10, 20, 30 years is robust, operates under very constrained conditions.
link |
00:15:29.680
Yes, absolutely. That's right. And it's fascinating and beautiful in its own way.
link |
00:15:34.080
It's C++ is one of my favorite languages and so is Lisp. So I can embody it too
link |
00:15:42.000
for different reasons as a programmer. I understand why Lisp is popular and I can see
link |
00:15:51.120
the beauty of the ideas and similarly with Smalltalk. It's just not as relevant in my world.
link |
00:16:05.200
And by the way, I distinguish between those in the functional languages
link |
00:16:09.280
where I go to things like ML and Haskell. Different kind of languages. They have a
link |
00:16:17.040
different kind of beauty and they're very interesting. And I actually try to learn from
link |
00:16:23.600
all the languages I encounter to see what is there that would make
link |
00:16:29.920
working on the kind of problems I'm interested in with the kind of constraints
link |
00:16:36.640
that I'm interested in. What can actually be done better because we can surely do better than we do
link |
00:16:43.440
today. You've said that it's good for any professional programmer to know at least
link |
00:16:50.160
five languages. Speaking about a variety of languages that you've taken inspiration from
link |
00:16:57.440
and you've listed yours as being at least at the time C++ obviously, Java, Python, Ruby and JavaScript.
link |
00:17:06.640
Can you first of all update that list? Modify it. You don't have to be constrained
link |
00:17:15.200
to just five. But can you describe what you picked up also from each of these languages?
link |
00:17:21.760
How you see them as inspirations for even when you're working with C++?
link |
00:17:25.920
This is a very hard question to answer. So about languages, you should know languages.
link |
00:17:34.320
I reckon I knew about 25 or thereabouts when I did C++. It was easier in those days because
link |
00:17:42.800
the languages were smaller and you didn't have to learn a whole programming environment and such
link |
00:17:49.600
to do it. You could learn the language quite easily and it's good to learn so many languages.
link |
00:17:55.760
I imagine just like with natural language for communication, there's different paradigms that
link |
00:18:03.920
emerge in all of them. That there's commonalities and so on.
link |
00:18:08.800
So I picked five out of a hat. Obviously. The important thing that the number is not one.
link |
00:18:17.760
That's right. I don't like, I mean, if you're a monoglot, you are likely to think that your
link |
00:18:24.240
own culture is the only one's period for everybody else's. A good learning of a foreign language
link |
00:18:29.920
and a foreign culture is important. It helps you think and be a better person. With programming
link |
00:18:36.160
languages, you become a better programmer, a better designer with the second language.
link |
00:18:41.680
Now, once you've got two, the way to five is not that long. It's the second one that's most
link |
00:18:49.040
important. And then when I had to pick five, I sort of thinking what kinds of languages are there.
link |
00:18:59.200
Well, there's a really low level stuff. It's good. It's actually good to know machine code.
link |
00:19:05.040
Even still, sorry. Even today. Even today. The C++ optimizes right better machine code than I do.
link |
00:19:13.200
Yes. But I don't think I could appreciate them if I actually didn't understand machine code and
link |
00:19:21.120
machine architecture. At least in my position, I have to understand a bit of it. Because
link |
00:19:28.160
you mess up the cash and you're off in performance by a factor of 100. Right? It shouldn't be that
link |
00:19:35.280
if you are interested in either performance or the size of the computer you have to deploy.
link |
00:19:40.480
Yeah. So I would go, that's a simpler. I used to mention C, but these days going low level
link |
00:19:50.320
is not actually what gives you the performance. It is to express your ideas so cleanly that you
link |
00:19:57.040
can think about it and the optimizer can understand what you're up to. My favorite way of optimizing
link |
00:20:03.120
these days is to throw out the clever bits and see if it still runs fast. And sometimes it runs
link |
00:20:10.320
faster. So I need the abstraction mechanisms or something like C++ to write compact high
link |
00:20:18.400
performance code. There was a beautiful keynote by Jason Turner at the CPP Con a couple of years ago
link |
00:20:26.000
where he decided he was going to program Pong on Motorola 6800, I think it was. And he says,
link |
00:20:38.560
well this is relevant because it looks like a microcontroller. It has specialized hardware,
link |
00:20:44.240
it has not very much memory and it's relatively slow. And so he shows in real time how he writes
link |
00:20:51.760
Pong starting with fairly straightforward low level stuff, improving his abstractions
link |
00:20:58.800
and what he's doing, he's writing C++ and it translates into 86 assembler which you can do
link |
00:21:09.920
with Clang and you can see it in real time. It's the compiler explorer which you can use on the web
link |
00:21:17.440
and then he wrote a little program that translated 86 assembler into Motorola assembler. And so he
link |
00:21:26.160
types and you can see this thing in real time. You can see it in real time and even if you can't
link |
00:21:31.600
read the assembly code, you can just see it, his code gets better, the code, the assembler gets
link |
00:21:38.000
smaller, he increases the abstraction level, uses C++ 11 as it were better, this code gets cleaner,
link |
00:21:47.600
it gets easier to maintain what the code shrinks and it keeps shrinking. And I could not in any
link |
00:21:56.640
reasonable amount of time write that assembler as good as the compiler generated from really
link |
00:22:03.920
quite nice modern C++. And I'll go as far as to say that the thing that looked like C was
link |
00:22:10.960
significantly uglier and smaller when it became and larger when it became machine code.
link |
00:22:22.160
So the abstractions that can be optimized are important. I would love to see that kind of
link |
00:22:28.480
visualization in larger code bases. That might be beautiful. But you can't show a larger code base
link |
00:22:34.880
in a one hour talk and have it fit on screen. Right. So that's C and C++. So my two languages
link |
00:22:41.680
would be machine code and C++. And then I think you can learn a lot from the functional languages.
link |
00:22:48.960
So PIG has Goliom L. I don't care which. I think actually you learn the same lessons
link |
00:22:56.480
of expressing especially mathematical notions really clearly and having a type system that's
link |
00:23:06.320
really strict. And then you should probably have a language for sort of quickly churning out
link |
00:23:13.920
something. You could pick JavaScript, you could pick Python, you could pick Ruby.
link |
00:23:19.680
What do you make of JavaScript in general? So you're talking in the platonic sense about
link |
00:23:26.800
languages, about what they're good at, what their philosophy of design is. But there's also a large
link |
00:23:32.880
user base behind each of these languages and they use it in the way sometimes maybe it wasn't
link |
00:23:38.400
really designed for. That's right. JavaScript is used way beyond probably what it was designed for.
link |
00:23:43.760
Let me say it this way. When you build a tool, you do not know how it's going to be used.
link |
00:23:48.800
You try to improve the tool by looking at how it's being used and when people cut their fingers off
link |
00:23:54.800
and try and stop that from happening. But really you have no control over how something is used.
link |
00:24:01.280
So I'm very happy and proud of some of the things C++ is being used at and some of the things I wish
link |
00:24:08.080
people wouldn't do. Bitcoin mining being my favorite example uses as much energy as Switzerland
link |
00:24:15.200
and mostly serves criminals. But back to the languages, I actually think that having JavaScript
link |
00:24:26.240
run in the browser was an enabling thing for a lot of things. Yes, you could have done it better,
link |
00:24:34.640
but people were trying to do it better and they were using more principles, language designs,
link |
00:24:42.960
but they just couldn't do it right. And the nonprofessional programmers that write lots of
link |
00:24:50.080
that code just couldn't understand them. So it did an amazing job for what it was. It's not
link |
00:24:59.360
the prettiest language and I don't think it ever will be the prettiest language, but that's not
link |
00:25:05.680
the biggest here. So what was the origin story of C++? You basically gave a few perspectives of
link |
00:25:16.720
your inspiration of object oriented programming. You had a connection with C in performance,
link |
00:25:24.560
efficiency was an important thing you were drawn to. Efficiency and reliability. You have to get
link |
00:25:31.360
both. What's reliability? I really want my telephone calls to get through and I want the
link |
00:25:39.840
quality of what I am talking coming out at the other end. The other end might be in London or
link |
00:25:47.840
wherever. And you don't want the system to be crashing. If you're doing a bank,
link |
00:25:54.560
you mustn't crash. It might be your bank account that is in trouble. There's different constraints
link |
00:26:03.280
like in games, it doesn't matter too much if there's a crash, nobody dies and nobody gets ruined.
link |
00:26:08.720
But I'm interested in the combination of performance partly because of sort of speed
link |
00:26:16.720
of things being done, part of being able to do things that is necessary to have reliable
link |
00:26:24.240
reliability of larger systems. If you spend all your time interpreting a simple function call,
link |
00:26:35.200
you are not going to have enough time to do proper signal processing to get the telephone
link |
00:26:39.920
calls to sound right. Either that or you have to have 10 times as many computers and you can't
link |
00:26:46.480
afford your phone anymore. It's a ridiculous idea in the modern world because we've solved all of
link |
00:26:52.720
those problems. I mean they keep popping up in different ways because we tackle bigger and
link |
00:26:59.200
bigger problems so efficiency remains always an important aspect. But you have to think about
link |
00:27:04.960
efficiency not just as speed but as an enabler to important things. And one of the things it
link |
00:27:12.320
enables is reliability, is dependability. When I press the brake pedal of a car, it is not actually
link |
00:27:23.600
connected directly to anything but a computer. That computer better work.
link |
00:27:31.680
Let's talk about reliability just a little bit. So modern cars have ECUs, have millions of lines
link |
00:27:39.600
of code today. So this is certainly especially true of autonomous vehicles where some of the
link |
00:27:46.560
aspect of the control or driver assistance systems that steer the car, keeping the lanes on.
link |
00:27:52.000
So how do you think, you know, I talked to regulators, people in the government who are
link |
00:27:57.120
very nervous about testing the safety of these systems of software, ultimately software that
link |
00:28:03.520
makes decisions that could lead to fatalities. So how do we test software systems like these?
link |
00:28:13.600
First of all, safety, like performance and like security is a systems property. People tend to
link |
00:28:24.480
look at one part of a system at a time and saying something like, this is secure. That's all right.
link |
00:28:31.600
I don't need to do that. Yeah, that piece of code is secure. I'll buy your operator.
link |
00:28:38.480
If you want to have reliability, if you want to have performance, if you want to have security,
link |
00:28:44.560
you have to look at the whole system. I did not expect you to say that, but that's very true.
link |
00:28:49.520
Yes. I'm dealing with one part of the system and I want my part to be really good,
link |
00:28:54.560
but I know it's not the whole system. Furthermore, making an individual part perfect
link |
00:29:04.320
may actually not be the best way of getting the highest degree of reliability and performance and
link |
00:29:09.680
such. Those people say C++ type safe, not type safe, you can break it. Sure. I can break anything
link |
00:29:18.080
that runs on a computer. I may not go through your type system. If I wanted to break into your
link |
00:29:24.880
computer, I'll probably try SQL injection. It's very true. If you think about safety or even
link |
00:29:31.920
reliability at a system level, especially when a human being is involved, it starts becoming
link |
00:29:40.400
hopeless pretty quickly in terms of proving that something is safe to a certain level,
link |
00:29:49.440
because there are so many variables. It's so complex.
link |
00:29:52.080
Well, let's get back to something we can talk about and actually make some progress on.
link |
00:29:58.480
We can look at C++ programs and we can try and make sure they crash less often.
link |
00:30:05.600
The way you do that is largely by simplification. The first step is to simplify the code, have less
link |
00:30:18.240
code, have code that are less likely to go wrong. It's not by runtime testing everything. It is not
link |
00:30:25.200
by big test frameworks that you're using. Yes, we do that also, but the first step is actually to
link |
00:30:33.840
make sure that when you want to express something, you can express it directly in code rather than
link |
00:30:41.360
going through endless loops and convolutions in your head before it gets down the code.
link |
00:30:49.760
The way you're thinking about a problem is not in the code. There is a missing piece that's just
link |
00:30:57.200
in your head and the code, you can see what it does, but it cannot see what you thought about it
link |
00:31:04.640
unless you have expressed things directly. When you express things directly, you can maintain it.
link |
00:31:11.440
It's easier to find errors. It's easier to make modifications. It's actually easier to test it
link |
00:31:17.920
and, lo and behold, it runs faster. Therefore, you can use a smaller number of computers,
link |
00:31:25.440
which means there's less hardware that could possibly break. I think the key here is simplification,
link |
00:31:33.920
but it has to be to use the Einstein quote as simple as possible and no simpler.
link |
00:31:39.920
Not simpler. There are other areas with under constraints where you can be simpler than you
link |
00:31:45.600
can be in C++, but in the domain I'm dealing with, that's the simplification I'm after.
link |
00:31:52.160
How do you inspire or ensure that the Einstein level simplification is reached?
link |
00:32:04.560
Can you do code review? Can you look at code? If I gave you the code for the Ford F150 and said,
link |
00:32:13.760
here, is this a mess or is this okay? Is it possible to tell? Is it possible to regulate?
link |
00:32:23.040
An experienced developer can look at code and see if it smells. I mixed made it for us deliberately.
link |
00:32:31.680
Yes. The point is that it is hard to generate something that is really obviously clean and
link |
00:32:46.880
can be appreciated, but you can usually recognize when you haven't reached that point.
link |
00:32:52.240
If I have never looked at the F150 code, so I wouldn't know, but I know what I would be looking
link |
00:33:05.280
for. I would be looking for some tricks that correlate with bugs and elsewhere. I have tried
link |
00:33:13.440
to formulate rules for what good code looks like. The current version of that is called the C++
link |
00:33:23.840
core guidelines. One thing people should remember is there's what you can do in a language and what
link |
00:33:33.440
you should do. In a language, you have lots of things that is necessary in some context,
link |
00:33:40.800
but not in others. There are things that exist just because there's 30 year old code out there
link |
00:33:46.640
and you can't get rid of it, but you can't have rules that says when you create it, try and follow
link |
00:33:52.000
these rules. This does not create good programs by themselves, but it limits the damage for
link |
00:34:02.800
mistakes. It limits the possibilities of mistakes. Basically, we are trying to say what is it
link |
00:34:10.000
that a good programmer does at the fairly simple level of where you use the language and how you
link |
00:34:16.880
use it. Now, I can put all the rules for chiseling and marble. It doesn't mean that somebody who
link |
00:34:25.440
follows all of those rules can do a masterpiece by Michelangelo. That is, there's something else
link |
00:34:33.200
to write a good program. Is there something else to create important work of art? There's
link |
00:34:43.600
some kind of inspiration, understanding, gift, but we can approach the technical, the craftsmanship
link |
00:34:57.040
level of it. The famous painters, the famous sculptures was, among other things, superb
link |
00:35:06.000
craftsmen. They could express their ideas using their tools very well. These days, I think what
link |
00:35:17.360
I'm doing, what a lot of people are doing, we're still trying to figure out how it is to use our
link |
00:35:22.320
tools very well. For a really good piece of code, you need a spark of inspiration and you
link |
00:35:31.280
can't, I think, regulate that. You cannot say that I'll buy your picture only if you're,
link |
00:35:41.680
at least, Van Gogh. There are other things you can regulate, but not the inspiration.
link |
00:35:48.960
I think that's quite beautifully put. It is true that there is, as an experienced programmer,
link |
00:35:58.080
when you see code that's inspired, that's like Michelangelo, you know it when you see it.
link |
00:36:09.200
The opposite of that is code that is messy, code that smells, you know when you see it.
link |
00:36:15.040
I'm not sure you can describe it in words except vaguely through guidelines and so on.
link |
00:36:20.480
Yes. It's easier to recognize ugly than to recognize beauty in code. The reason is that
link |
00:36:29.200
sometimes beauty comes from something that's innovative and unusual and you have to
link |
00:36:35.280
sometimes think reasonably hard to appreciate that. On the other hand, the messes have things
link |
00:36:42.720
in common and you can have static checkers and dynamic checkers that finds a large number of the
link |
00:36:55.200
most common mistakes. You can catch a lot of sloppiness mechanically. I'm a great fan of
link |
00:37:04.640
static analysis in particular because you can check for not just the language rules,
link |
00:37:10.480
but for the usage of language rules. I think we will see much more static analysis in the
link |
00:37:17.440
coming decade. Can you describe what static analysis is? You represent a piece of code
link |
00:37:25.840
so that you can write a program that goes over that representation and look for things that are
link |
00:37:33.760
right and not right. For instance, you can analyze a program to see if resources are leaked.
link |
00:37:48.080
That's one of my favorite problems. It's not actually all that hard in modern C++,
link |
00:37:55.440
but you can do it. If you are writing in the C level, you have to have a malloc and a free
link |
00:38:00.640
function. They have to match. If you have them in a single function, you can usually do it very
link |
00:38:08.880
easily. If there's a malloc here, there should be a free there. On the other hand, in between
link |
00:38:15.920
can be showing complete code and then it becomes impossible. If you pass that pointer to the memory
link |
00:38:23.280
out of a function and then want to make sure that the free is done somewhere else,
link |
00:38:31.520
now it gets really difficult. For static analysis, you can run through a program
link |
00:38:37.600
and you can try and figure out if there's any leaks. What you will probably find is that you
link |
00:38:46.560
will find some leaks and you'll find quite a few places where your analysis can't be complete. It
link |
00:38:53.920
might depend on runtime. It might depend on the cleverness of your analyzer and it might take
link |
00:39:02.800
a long time. Some of these programs run for a long time, but if you combine such analysis
link |
00:39:11.120
with a set of rules, such as how people could use it, you can actually see why the rules are
link |
00:39:18.080
violated and that stops you from getting into the impossible complexities. You don't want to solve
link |
00:39:26.320
the holding problem. The static analysis is looking at the code without running the code.
link |
00:39:31.840
Not in production code, but it's almost like an education tool of how the language should be used.
link |
00:39:43.680
It guides you at its best. It would guide you in how you write future code as well and you learn
link |
00:39:51.280
together. Basically, you need a set of rules for how you use the language. Then you need
link |
00:39:57.760
a static analysis that catches your mistakes when you violate the rules or when your code ends up
link |
00:40:07.760
doing things that it shouldn't, despite the rules, because those are the language rules. We can go
link |
00:40:12.400
further. Again, it's back to my idea that I would much rather find errors before I start
link |
00:40:19.280
running the code. If nothing else, once the code runs, if it catches an error at runtime,
link |
00:40:26.000
I have to have an error handler. One of the hardest things to write in code is error handling code,
link |
00:40:33.440
because you know something went wrong. Do you know really exactly what went wrong?
link |
00:40:39.360
Usually not. How can you recover when you don't know what the problem was? You can't be 100%
link |
00:40:45.120
sure what the problem was in many, many cases. This is part of it. Yes, we need good languages,
link |
00:40:55.120
with good type systems. We need rules for how to use them. We need static analysis. The ultimate
link |
00:41:01.840
for static analysis is course program proof, but that still doesn't scale to the kind of systems
link |
00:41:08.160
we deploy. Then we start needing testing and the rest of the stuff. C++ is an object oriented
link |
00:41:19.040
programming language that creates, especially with newer versions, as we'll talk about,
link |
00:41:23.840
higher and higher levels of abstraction. Let's even go back to the origin C++. How do you design
link |
00:41:33.360
something with so much abstraction that's still efficient and is still something that you can
link |
00:41:43.840
manage, do static analysis on, you can have constraints on, they can be,
link |
00:41:49.680
relive all those things we've talked about. To me, there's a slight tension between
link |
00:41:58.000
high level abstraction and efficiency. That's a good question. I could probably have a year's
link |
00:42:04.480
course just trying to answer it. Yes, there's a tension between efficiency and abstraction,
link |
00:42:12.160
but you also get the interesting situation that you get the best efficiency out of the best
link |
00:42:18.480
abstraction. My main tool for efficiency, for performance, actually is abstraction.
link |
00:42:28.320
Let's go back to how C++ got there. You said it was object oriented programming language. I
link |
00:42:34.880
actually never said that. It's always quoted, but I never did. I said C++ supports object oriented
link |
00:42:42.320
programming and other techniques. That's important because I think that the best solution to most
link |
00:42:52.800
complex interesting problems require ideas and techniques from things that have been called
link |
00:43:01.280
object oriented, data abstraction, functional, traditional C style code, all of the above.
link |
00:43:15.440
When I was designing C++, I soon realized I couldn't just add features.
link |
00:43:23.520
If you just add what looks pretty or what people ask for or what you think is good,
link |
00:43:28.560
one by one, you're not going to get a coherent whole. What you need is a set of guidelines that
link |
00:43:38.640
guides your decisions. Should this feature be in or should this feature be out? How should
link |
00:43:44.320
a feature be modified before it can go in and such? In the book I wrote about that,
link |
00:43:51.440
that's signed an evolution of C++. There's a whole bunch of rules like that. Most of them are not
link |
00:43:57.440
language technical. There are things like don't violate static type system because I like static
link |
00:44:06.000
type system for the obvious reason that I like things to be reliable on reasonable amounts of
link |
00:44:14.720
hardware. One of these rules is the zero overhead principle. It basically says that
link |
00:44:25.920
if you have an abstraction, it should not cost anything compared to write the equivalent code
link |
00:44:35.680
at a lower level. If I have, say, a matrix multiply, it should be written in such a way that you
link |
00:44:48.560
could not drop to the C level of abstraction and use arrays and pointers and such and run faster.
link |
00:44:55.200
People have written such matrix multiplications. They've actually gotten code that ran faster than
link |
00:45:06.160
Fortran because once you had the right abstraction, you can eliminate temporaries and you can do
link |
00:45:15.520
loop fusion and other good stuff like that. That's quite hard to do by hand and in a lower
link |
00:45:20.640
level language. There's some really nice examples of that. The key here is that that matrix
link |
00:45:29.520
multiplication, the matrix abstraction, allows you to write code that's simple and easy. You can
link |
00:45:36.000
do that in any language. With C++, it has the features so that you can also have this thing
link |
00:45:41.840
run faster than if you hand coded it. People have given that lecture many times, I and others,
link |
00:45:49.680
and a very common question after the talk where you have demonstrated that you're going
link |
00:45:54.880
to perform Fortran for dense matrix multiplication, people come up and say, yeah,
link |
00:46:00.080
but that was C++. If I rewrote your code and see how much faster would it run, the answer is much
link |
00:46:08.080
slower. This happened the first time actually back in the ages with a friend of mine called
link |
00:46:14.800
Doug McElroy who demonstrated exactly this effect. The principle is you should give programmers the
link |
00:46:25.280
tools so that the abstractions can follow the zero word principle. Furthermore, when you put in a
link |
00:46:32.000
language feature on C++ or a standard library feature, you try to meet this. It doesn't mean
link |
00:46:38.640
it's absolutely optimal, but it means if you hand code it with the usual facilities in the language
link |
00:46:46.880
in C++ in C, you should not be able to better it. Usually you can do better if you use embedded
link |
00:46:55.040
assembler for machine code for some of the details to utilize part of a computer that
link |
00:47:02.560
the compiler doesn't know about, but you should get to that point before you beat the abstraction.
link |
00:47:09.360
That's a beautiful idea to reach for. And we meet it quite often.
link |
00:47:14.640
Quite often. Where's the magic of that coming from? Some of it is the compilation process,
link |
00:47:21.760
so the implementation is C++. Some of it is the design of the feature itself, the guidelines.
link |
00:47:28.480
I've recently often talked to Chris Ladner, so Clang. Just out of curiosity, is your
link |
00:47:40.320
relationship in general with the different implementations in C++, as you think about
link |
00:47:46.560
you and committee and other people in C++, think about the design of new features or design of
link |
00:47:51.200
previous features in trying to reach the ideal of zero overhead? Does the magic come from the
link |
00:48:02.080
design, the guidelines, or from the implementations? And not all. You go for programming technique,
link |
00:48:13.840
program language features, and implementation techniques. You need all three.
link |
00:48:18.000
And how can you think about all three at the same time?
link |
00:48:22.880
It takes some experience, takes some practice, and sometimes you get it wrong. But after a while,
link |
00:48:29.120
you sort of get it right. I don't write compilers anymore. But Brian Kernighan pointed out that
link |
00:48:38.640
one of the reasons C++ succeeded was some of the craftsmanship I put into the early compilers.
link |
00:48:50.720
And of course, I did the languages sign. Of course, I wrote a fair amount of code
link |
00:48:54.800
using this kind of stuff. And I think most of the successes involves progress in all three areas
link |
00:49:03.760
together. A small group of people can do that. Two, three people can work together to do something
link |
00:49:11.520
like that. It's ideal if it's one person that has all the skills necessary. But nobody has all
link |
00:49:17.040
the skills necessary in all the fields where C++ is used. So if you want to approach my ideal in,
link |
00:49:24.160
say, concurrent programming, you need to know about algorithms on concurrent programming. You
link |
00:49:30.560
need to know the trigger of lock free programming. You need to know something about the compiler
link |
00:49:37.040
techniques. And then you have to know some of the application areas where this is,
link |
00:49:45.520
like some forms of graphics or some forms of what we call a web serving kind of stuff.
link |
00:49:55.600
And that's very hard to get into a single head. But small groups can do it too.
link |
00:50:01.440
So is there differences in your view? Not saying which is better or so on, but difference in
link |
00:50:08.720
the different implementations of C++? Why are there several sort of maybe naive questions for me?
link |
00:50:16.080
This is a very reasonable question. When I designed C++,
link |
00:50:28.480
most languages have multiple implementations. Because if you run on an IBM, if you run on a
link |
00:50:36.480
Sun, if you run on a Motorola, there was just many, many companies and they each have their
link |
00:50:41.920
own compilation structure, the old compilers. It was just fairly common that there was many of them.
link |
00:50:49.200
And I wrote Cfront assuming that other people would write compilers with C++ if they were
link |
00:50:56.800
successful. And furthermore, I wanted to utilize all the back end infrastructures that were available.
link |
00:51:05.600
I soon realized that my users were using 25 different linkers. I couldn't write my own linker.
link |
00:51:12.800
Yes, I could, but I couldn't write 25 linkers and also get any work done on the language.
link |
00:51:20.080
And so it came from a world where there was many linkers, many optimizers, many compiler front ends,
link |
00:51:28.480
not to start, but many operating systems. The whole world was not an 86 and Linux box or something,
link |
00:51:39.440
whatever is the standard today. In the old days, they said a Vax. So basically, I assumed there
link |
00:51:47.600
would be lots of compilers. It was not a decision that there should be many compilers. It was just
link |
00:51:54.080
the fact that's the way the world is. And yes, many compilers emerged. And today, there's
link |
00:52:05.680
at least four front ends, Clang, GCC, Microsoft, and EDG. It is the sign group. They supply a lot
link |
00:52:16.560
of the independent organizations and the embedded systems industry. And there's lots and lots of
link |
00:52:25.120
back ends. We have to think about how many dozen back ends there are because different machines
link |
00:52:33.200
have different things, especially in the embedded world, the machines are very different. The
link |
00:52:38.400
architectures are very different. And so having a single implementation was never an option.
link |
00:52:48.720
Now, I also happen to dislike monocultures. Monocultures. They are dangerous because whoever
link |
00:52:57.760
owns the monoculture can go stale and there's no competition and there's no incentive to innovate.
link |
00:53:05.440
There's a lot of incentive to put barriers in the way of change because, hey, we own the world and
link |
00:53:12.640
it's a very comfortable world for us. And who are you to mess with that? So I really am very happy
link |
00:53:21.120
that there's four front ends for C++. Clang's great, but GCC was great. But then it got somewhat
link |
00:53:31.520
stale. Clang came along and GCC is much better now. Competition is good. Microsoft is much better
link |
00:53:40.000
now. So at least a low number of front ends puts a lot of pressure on
link |
00:53:51.040
standards compliance and also on performance and error messages and compile time speed,
link |
00:53:57.680
all of this good stuff that we want. Do you think, crazy question, there might come along,
link |
00:54:05.760
do you hope there might come along implementation of C++ written given all of its history written
link |
00:54:14.560
from scratch? So written today from scratch? Well, Clang and the LLVM is more or less written
link |
00:54:23.760
from scratch. But there's been C++ 11, 14, 17, 20. Sooner or later somebody is going to try again.
link |
00:54:33.920
There has been attempts to write new C++ compilers and some of them has been used and some of them
link |
00:54:41.200
has been absorbed into others and such. Yeah, it'll happen. So what are the key features of C++?
link |
00:54:48.240
And let's use that as a way to sort of talk about the evolution of C++, the new feature.
link |
00:54:57.040
So at the highest level, what are the features that were there in the beginning and what features
link |
00:55:02.560
got added? Let's first get a principle or an aim in place. C++ is for people who want to use
link |
00:55:14.160
hardware really well and then manage the complexity of doing that through abstraction.
link |
00:55:21.600
And so the first facility you have is a way of manipulating the machines at a fairly low level.
link |
00:55:30.960
That looks very much like C. It has loops, it has variables, it has pointers like machine
link |
00:55:39.920
addresses, it can access memory directly, it can allocate stuff in the absolute minimum of space
link |
00:55:49.360
needed on the machine. There's a machine facing part of C++, which is roughly equivalent to C.
link |
00:55:57.200
I said C++ could beat C and it can. It doesn't mean I dislike C. If I disliked C, I wouldn't have
link |
00:56:04.160
built on it. Furthermore, after Dennis Ritchie, I'm probably the major contributor to modern C.
link |
00:56:13.760
And well, I had lunch with Dennis most days for 16 years and we never had a harsh word between us.
link |
00:56:24.480
So these C versus C++ fights are for people who don't quite understand what's going on.
link |
00:56:31.120
Then the other part is the abstraction. And there, the key is the class, which is a user defined type.
link |
00:56:39.040
And my ideal for the class is that you should be able to build a type that's just like the
link |
00:56:44.240
built in types in the way you use them, in the way you declare them, in the way you get the memory
link |
00:56:52.080
and you can do just as well. So in C++ there's an int. As in C, you should be able to build
link |
00:57:00.960
an abstraction, a class, which we can call capital int, that you can use exactly like an integer
link |
00:57:09.200
and run just as fast as an integer. There's the idea right there. And of course, you probably
link |
00:57:16.320
don't want to use the int itself, but it has happened. People have wanted integers that were
link |
00:57:23.920
range checked so that you couldn't overflow and such, especially for very safety critical
link |
00:57:29.040
applications, like the fuel injection for a marine diesel engine for the largest ships.
link |
00:57:35.840
This is a real example, by the way. This has been done. They built themselves an integer
link |
00:57:42.000
that was just like integer, except that it couldn't overflow. If there was an overflow,
link |
00:57:48.000
you went into the error handling. And then you built more interesting types. You can build
link |
00:57:55.120
a matrix, which you need to do graphics, or you could build a gnome for a video game.
link |
00:58:03.520
And all of these are classes and they appear just like the built in types,
link |
00:58:07.520
in terms of efficiency and so on. So what else is there? And flexibility.
link |
00:58:16.000
I don't know. For people who are not familiar with object joining programming,
link |
00:58:19.920
there's inheritance. There's a hierarchy of classes. You can, just like you said,
link |
00:58:25.840
create a generic vehicle that can turn left. So what people found was that you don't actually
link |
00:58:34.800
know. How do I say this? A lot of types are related. That is, the vehicles, all vehicles are
link |
00:58:47.440
related. Bicycles, cars, fire engines, tanks, they have some things in common and some things
link |
00:58:55.920
that differ. And you would like to have the common things common and having the differences
link |
00:59:01.440
specific. And when you didn't want to know about the differences, like just turn left,
link |
00:59:09.040
you don't have to worry about it. That's how you get the traditional object oriented
link |
00:59:14.480
programming coming out of Simula adopted by Smalltalk and C++ and all the other languages.
link |
00:59:21.600
The other kind of obvious similarity between types comes when you have something like a vector.
link |
00:59:27.280
Fortune gave us the vector as called array of doubles. But the minute you have a vector of
link |
00:59:37.280
doubles, you want a vector of double precision doubles and for short doubles for graphics.
link |
00:59:44.480
And why should you have not have a vector of integers while you're at it? Or that vector of
link |
00:59:51.760
vectors and a vector of vectors of chess pieces. Now we have a board, right? So this is you express
link |
01:00:02.320
the commonality as the idea of a vector and the variations come through parameterization.
link |
01:00:10.080
And so here we get the two fundamental ways of abstracting of having similarities of
link |
01:00:17.360
types in C++. There's the inheritance and there's a parameterization. There's the
link |
01:00:24.720
object oriented programming and there's the generic programming with the templates for
link |
01:00:29.600
the generic programming. So you've presented it very nicely. But now you have to make all that
link |
01:00:37.920
happen and make it efficient. So generic programming with templates, there's all kinds of magic going
link |
01:00:44.800
on, especially recently, that you can help catch up on. But it feels to me like you can do way more
link |
01:00:52.240
than what you just said with templates. You can start doing this kind of metaprogramming.
link |
01:00:57.920
You can do metaprogramming also. I didn't go there in that explanation. We're trying to be
link |
01:01:04.960
very basics. But go back on to the implementation. If you couldn't implement this efficiently,
link |
01:01:10.720
if you couldn't use it so that it became efficient, it has no place in C++ because it
link |
01:01:18.080
will violate the zero overhead principle. So when I had to get object oriented programming
link |
01:01:26.080
inheritance, I took the idea of virtual functions from Simula. Virtual functions is a Simula term.
link |
01:01:34.800
Class is a Simula term. If you ever use those words, say thanks to Christian Nugor and Oli Handal.
link |
01:01:43.920
And I get the simplest implementation I knew of, which was basically a jump table. So you get the
link |
01:01:52.000
virtual function table, the function goes in, do it, does an interaction through a table and get
link |
01:01:58.000
the right function. That's how you pick the right thing there. And I thought that was trivial. It's
link |
01:02:05.760
close to optimal. And it was obvious. It turned out the Simula had a more complicated way of doing
link |
01:02:11.760
it and therefore was slower. And it turns out that most languages have something that's a little
link |
01:02:17.680
bit more complicated, sometimes more flexible, but you pay for it. And one of the strengths of
link |
01:02:23.600
C++ was that you could actually do this object oriented stuff and your overhead compared to
link |
01:02:31.200
ordinary functions. There's no indirection. It's sort of in 5, 10, 25 percent. Just the
link |
01:02:39.200
core. It's down there. It's not two. And that means you can afford to use it. Furthermore,
link |
01:02:46.320
in C++, you have the distinction between a virtual function and a non virtual function.
link |
01:02:51.840
If you don't want any overhead, if you don't need the interaction that gives you the flexibility
link |
01:02:57.520
in object oriented programming, just don't ask for it. So the idea is that you only use
link |
01:03:04.960
virtual functions if you actually need the flexibility. So it's not zero overhead,
link |
01:03:10.400
but it's zero overhead compared to any other way of achieving the flexibility.
link |
01:03:14.720
Now, auto parameterization. Basically, the compiler looks at
link |
01:03:26.720
at the template, say the vector, and it looks at the parameter and then combines the two and
link |
01:03:37.040
generates a piece of code that is exactly as if you're ridden a vector of that specific type.
link |
01:03:43.440
Yes. So that's the that's the minimal overhead. If you have many template parameters, you can
link |
01:03:50.320
actually combine code that the compiler couldn't usually see at the same time and therefore get
link |
01:03:56.640
code that is faster than if you had handwritten the stuff, unless you were very, very clever.
link |
01:04:04.960
So the thing is parameterized code, the compiler fills stuff in during the compilation process,
link |
01:04:13.120
not during runtime. That's right. And furthermore, it gives all the information it's gotten,
link |
01:04:21.360
which is the template, the parameter, and the context of use. It combines the three and generates
link |
01:04:28.960
good code. But it can generate. Now, it's a little outside of what I'm even comfortable
link |
01:04:37.120
thinking about, but it can generate a lot of code. Yes. And how do you remember being both
link |
01:04:45.520
amazed at the power of that idea? And how ugly the debugging looked? Yes, debugging can be truly
link |
01:04:55.680
horrid. Come back to this because I have a solution. Anyway, the debugging was ugly.
link |
01:05:02.320
The code generated by C++ has always been ugly, because there's these inherent optimizations.
link |
01:05:12.080
A modern C++ compiler has front end, middle end, and back end optimizations. Even C front,
link |
01:05:18.800
back in 83, had front end and back end optimizations. I actually took the code,
link |
01:05:25.200
generated an internal representation, munched that representation to generate good code.
link |
01:05:34.240
So people say it's not a compiler, it generates C. The reason it generated C was I wanted to use
link |
01:05:39.600
a C code generator that was really good at back end optimizations. But I needed front end
link |
01:05:45.280
optimizations. And therefore, the C I generated was optimized C. The way a really good handcrafted
link |
01:05:56.160
optimizer human could generate it, and it was not meant for humans. It was the output of a program,
link |
01:06:03.440
and it's much worse today. And with templates, it gets much worse still. So it's hard to combine
link |
01:06:10.880
simple debugging with the optimal code, because the idea is to drag in information from different
link |
01:06:20.560
parts of the code to generate good code, machine code. And that's not readable. So what people
link |
01:06:32.080
often do for debugging is they turn the optimizer off. And so you get code that when something in
link |
01:06:41.920
your source code looks like a function core, it is a function core. When the optimizer is turned on,
link |
01:06:49.040
it may disappear. The function core, it may inline. And so one of the things you can do
link |
01:06:55.200
is you can actually get code that is smaller than the function core, because you eliminate the
link |
01:07:04.160
function preamble and return. And there's just the operation there. One of the key things when I did
link |
01:07:14.560
templates was I wanted to make sure that if you have, say, a sort algorithm, and you give it a
link |
01:07:21.200
sorting criteria, if that sorting criteria is simply comparing things with less than,
link |
01:07:31.360
the code generated should be the less than, not a indirect function core to a comparison
link |
01:07:40.560
object, which is what it is in the source code. But we really want down to the single instruction.
link |
01:07:47.200
But anyway, turn off the optimizer and you can debug. The first level of debugging
link |
01:07:56.160
can be done and I always do without the optimization on, because then I can see what's going on.
link |
01:08:02.000
And then there's this idea of concepts that put some, now I've never even,
link |
01:08:10.160
I don't know if it was ever available in any form, but it puts some constraints on the stuff you
link |
01:08:17.760
can parameterize, essentially. Let me try and explain. So yes, it wasn't there 10 years ago.
link |
01:08:27.680
We have had versions of it that actually work for the last four or five years.
link |
01:08:33.840
It was a design by Gabbidas Rays, Drew Sodden and me. We were professors in postdocs in Texas at
link |
01:08:43.760
the time. And the implementation by Andrew Sodden has been available for that time. And it is
link |
01:08:55.280
part of C++20. And there's a standard library that uses it. So this is becoming really very real.
link |
01:09:06.240
It's available in Klangen and GCC, GCC for a couple of years. And I believe Microsoft is soon
link |
01:09:16.240
going to do it. We expect all of C++20 to be available. So in all the major compilers in 20.
link |
01:09:23.760
But this kind of stuff is available now. I'm just saying that because otherwise people might think
link |
01:09:32.080
I was talking about science fiction. And so what I'm going to say is it's concrete. You can run it
link |
01:09:37.680
today. And there's production uses of it. So the basic idea is that when you have
link |
01:09:44.400
a generic component, like a sort function, the sort function will require at least two parameters.
link |
01:09:56.480
One, a data structure with a given type and a comparison criteria. And these things are related.
link |
01:10:06.160
But obviously, you can't compare things if you don't know what the type of things you compare.
link |
01:10:11.280
Yeah. And so you want to be able to say, I'm going to sort something and it is to be sortable.
link |
01:10:20.400
What does it mean to be sortable? You look it up in the standard. It has to be a sequence with a
link |
01:10:26.160
beginning and an end. There has to be random access to that sequence. And the element types
link |
01:10:35.920
has to be comparable. Which means less than operator can operate on. Yes, less than logical
link |
01:10:42.080
operator can operate. Basically, what concepts are their compile time predicates, their predicates
link |
01:10:48.000
you can ask, are you a sequence? Yes, I have a beginning and end. Are you a random access sequence?
link |
01:10:56.320
Yes, I have a subscripting and plus. Is your element type something that has a less than?
link |
01:11:03.920
Yes, I have a less than. And so basically, that's the system. And so instead of saying,
link |
01:11:10.880
I will take a parameter of any type, it'll say I'll take something that's sortable.
link |
01:11:17.040
And it's well defined. And so we say, okay, you can sort with less than. I don't want less than.
link |
01:11:23.040
I want greater than or something I invent. So you have two parameters, the sortable thing and the
link |
01:11:28.880
comparison criteria. And the comparison criteria will say, well, you can write in saying it should
link |
01:11:39.120
operate on the element type. And it has the comparison operations. So that's just simply
link |
01:11:47.120
the fundamental thing. It's compile time predicates. Do you have the properties I need? So it specifies
link |
01:11:53.680
the requirements of the code on the parameters that gets. It's very similar to types, actually.
link |
01:12:03.200
But operating in the space of concepts. The word concept was used by Alex Stefanov,
link |
01:12:13.280
who is sort of the father of generic programming in the context of C++.
link |
01:12:18.000
You know, there's other places that use that word, but the way we call generic programming is
link |
01:12:25.120
Alex's. And he called them concepts, because he said they're the sort of the fundamental
link |
01:12:30.320
concepts of an area. So they should be called concepts. And we've had concepts all the time.
link |
01:12:36.480
If you look at the K&R book about C, C has arithmetic types, and it has
link |
01:12:42.560
integral types. It says so in the book. And then it lists what they are, and they have
link |
01:12:52.080
certain properties. The difference today is that we can actually write a concept that will ask a
link |
01:12:58.640
type, are you an integral type? Do you have the properties necessary to be an integral type?
link |
01:13:05.200
Do you have plus, minus, divide, and such? So maybe the story of concepts, because I thought
link |
01:13:15.200
it might be part of C++11, C0X, whatever it was at the time. We'll talk a little bit about
link |
01:13:28.480
this fascinating process of standards, because I think it's really interesting for people.
link |
01:13:32.560
It's interesting for me. But why did it take so long? What shapes the idea of concepts take?
link |
01:13:41.760
What were the challenges? Back in 1987 or thereabouts. 1987?
link |
01:13:49.120
Well, 1987 or thereabouts. When I was designing templates, obviously, I wanted to express the
link |
01:13:54.880
notion of what is required by a template of its arguments. And so I looked at this. And basically
link |
01:14:03.920
for templates, I wanted three properties. I wanted to be very flexible. It had to be able to express
link |
01:14:14.000
things I couldn't imagine, because I know I can't imagine everything, and I've been suffering from
link |
01:14:20.480
languages that try to constrain you to only do what the designer thought good. I didn't want to do that.
link |
01:14:28.880
Secondly, it had to run faster, as fast or faster than handwritten code. So basically,
link |
01:14:35.920
if I have a vector of t and I take a vector of char, it should run as fast as you build
link |
01:14:42.960
a vector of char yourself without parameterization. And thirdly, I wanted to be able to express
link |
01:14:52.480
the constraints of the arguments, have proper type checking of the interfaces,
link |
01:15:01.680
and neither I nor anybody else at the time knew how to get all three. And I thought for C++,
link |
01:15:09.360
I must have the two first. Otherwise, it's not C++. And it bothered me for another couple of decades
link |
01:15:17.600
that I couldn't solve the third one. I mean, I was the one that put function argument type checking
link |
01:15:24.320
into C. I know the value of good interfaces. I didn't invent that idea. It's very common.
link |
01:15:30.640
But I did it. And I wanted to do the same for templates, of course, and I could. So it bothered
link |
01:15:38.240
me. Then we tried again, 2002, 2003. Gaby just raised and I started analyzing the problem,
link |
01:15:49.200
explained possible solutions. It was not a complete design. A group in University of Indiana,
link |
01:15:57.360
an old friend of mine, they started a project at Indiana. And we thought we could get
link |
01:16:11.360
a good system of concepts in another two or three years. That would have made C++ 11 to C++
link |
01:16:22.000
0607. Well, it turned out that I think we got a lot of the fundamental ideas wrong.
link |
01:16:33.040
They were too conventional. They didn't quite fit C++, in my opinion. Didn't serve implicit
link |
01:16:40.880
conversions very well. It didn't serve mixed type arithmetic, mixed type computations very well.
link |
01:16:49.680
Well, a lot of stuff came out of the functional community. That community
link |
01:17:00.960
didn't deal with multiple types in the same way as C++ does. Had more constraints on what you could
link |
01:17:09.280
express and didn't have the draconian performance requirements. Basically, we tried. We tried very
link |
01:17:18.800
hard. We had some successes, but it just in the end wasn't. Didn't compile fast enough, was too
link |
01:17:28.320
hard to use and didn't run fast enough unless you had optimizers that was beyond the state of the
link |
01:17:39.120
art. They still are. So we had to do something else. Basically, it was the idea that a set of
link |
01:17:47.200
parameters defines a set of operations and you go through an interaction table just like for
link |
01:17:54.400
virtual functions. Then you try to optimize the interaction away to get performance. We just couldn't
link |
01:18:03.360
do all of that. But get back to the standardization. We are standardizing C++ under ISO rules,
link |
01:18:12.720
which is a very open process. People come in. There's no requirements for education or experience.
link |
01:18:19.600
So you've started to develop C++. When was the first standard established? What is that like?
link |
01:18:30.320
The ISO standard? Is there a committee that you're referring to? There's a group of people. What's
link |
01:18:35.840
that like? How often do you meet? What's the discussion? I'll try and explain that. So sometime
link |
01:18:43.840
in early 1989, two people, one from IBM, one from HP turned up in my office and told me I would like
link |
01:18:56.560
to standardize C++. This was a new idea to me. I pointed out that it wasn't finished yet and it
link |
01:19:07.200
wasn't ready for formal standardization and such. They said, no, Bjarne, you haven't gotten it.
link |
01:19:12.880
You really want to do this. Our organizations depend on C++. We cannot depend on something
link |
01:19:22.560
that's owned by another corporation that might be a competitor. Of course, we could rely on you,
link |
01:19:29.840
but you might get run over by a boss. We really need to get this out in the open. It has to be
link |
01:19:38.080
standardized under formal rules. We are going to standardize it under ISO rules. You really want
link |
01:19:49.760
to be part of it because, basically, otherwise, we'll do it ourselves. We know you can do it better.
link |
01:19:58.640
Through a combination of arm twisting and flattery, it got started. In late
link |
01:20:08.720
in late 89, there was a meeting in DC at the, actually, no, it was not ISO, then it was ANSI,
link |
01:20:18.560
the American National Standard we're doing. We met there. We were lectured on the rules of
link |
01:20:26.560
how to do an ANSI standard. There was about 25 of us there, which apparently was a new record for
link |
01:20:33.360
that kind of meeting. Some of the old C guys that has been standardizing C was there, so we
link |
01:20:41.120
got some expertise in. The way this works is that it's an open process. Anybody can sign up if they
link |
01:20:48.720
pay the minimum fee, which is about $1,000. They're less than, it's a little bit more now. I think
link |
01:20:57.200
it's $1,280. It's not going to kill you. We have three meetings a year. This is fairly standard.
link |
01:21:07.280
We tried two meetings a year for a couple of years. That didn't work too well. Three one
link |
01:21:16.160
week meetings a year, and you meet and you have technical meetings, technical discussions,
link |
01:21:24.720
and then you bring proposals forward for votes. The votes are done one person per,
link |
01:21:31.040
one vote per organization. You can't have, say, IBM come in with 10 people and dominate things
link |
01:21:41.440
that's not allowed. These are organizations that extensively use C++? Yes.
link |
01:21:46.640
All individuals. It's a bunch of people in the room deciding the design of a language based
link |
01:21:56.320
on which a lot of the world's systems run. That's right. Well, I think most people would agree it's
link |
01:22:03.760
better than if I decided it, or better than if a single organization like H&C decides it.
link |
01:22:11.920
I don't know if everyone agrees to that, by the way. Bureaucracies have their critics too.
link |
01:22:17.520
Yes, look, standardization is not pleasant. It's horrifying. It's like democracy.
link |
01:22:26.720
But exactly. As Churchill says, democracy is the worst way except for the others.
link |
01:22:33.520
And it's, I would say, the same with formal standardization. But anyway, so we meet and we
link |
01:22:38.880
have these votes and that determines what the standard is. A couple of years later, we extended
link |
01:22:48.560
this so it became worldwide. We have standard organizations that are active in currently 15
link |
01:22:58.080
to 20 countries. And another 15 to 20 are sort of looking and voting based on the rest of the work
link |
01:23:10.960
on it. And we meet three times a year. Next week, I'll be in Cologne, Germany, spending a week
link |
01:23:20.160
doing standardization. And then we will vote out the committee draft of C++20, which goes to the
link |
01:23:26.480
national standards committees for comments and requests for changes and improvements.
link |
01:23:35.120
Then we do that. And there's a second set of votes where hopefully everybody votes in favor.
link |
01:23:41.200
This has happened several times. The first time we finished, we started in the first technical
link |
01:23:47.840
meeting was in 1990. The last was in 98. We voted it out. That was the standard that people used
link |
01:23:56.800
till 11 or a little bit past 11. And it was an international standard. All the countries voted
link |
01:24:04.880
in favor. It took longer with 11. I'll mention why, but all the nations voted in favor. And we
link |
01:24:15.840
work on the basis of consensus. That is, we do not want something that passes 6040,
link |
01:24:24.400
because then we're getting getting a dialects and opponents and people complain too much.
link |
01:24:30.080
They all complain too much. But basically, it has no real effect. The standards has been obeyed.
link |
01:24:37.040
They have been working to make it easier to use many compilers, many computers,
link |
01:24:44.000
and all of that kind of stuff. And so the first, it was traditional with ISO standards to take
link |
01:24:51.360
10 years. We did the first one in eight, brilliant. And we thought we were going to do the next one
link |
01:24:58.080
in six, because now we're good at it. It took 13. Yeah, it was named OX. It was named OX.
link |
01:25:08.240
Hoping that you would at least get it within the single, within the arts, the single digits.
link |
01:25:13.440
I thought we would get, I thought we would get the six, seven or eight. The confidence of youth.
link |
01:25:19.200
Yeah, that's right. Well, the point is that this was sort of like a second system effect.
link |
01:25:25.280
That is, we now knew how to do it. And so we're going to do it much better. And we've got more
link |
01:25:29.920
ambitious and it took longer. Furthermore, there is this tendency because it's a 10 year cycle,
link |
01:25:37.840
or it doesn't matter. Just before you're about to ship, somebody has a bright idea.
link |
01:25:49.600
And so we really, really must get that in. We did that successfully with the STL.
link |
01:25:59.440
We got the standard line that gives us all the STL stuff that that I basically,
link |
01:26:05.680
I think it saved C++. It was beautiful. And then people tried it with other things.
link |
01:26:12.080
And it didn't work so well. They got things in, but it wasn't as dramatic and it took longer and
link |
01:26:18.000
longer and longer. So after C++ 11, which was a huge improvement and what basically what most
link |
01:26:27.280
people are using today, we decided never again. And so how do you avoid those slips? And the
link |
01:26:36.960
answer is that you ship more often so that if you have a slip on a 10 year cycle, by the time
link |
01:26:47.040
you know it's a slip, there's 11 years till you get it. Now with a three year cycle,
link |
01:26:52.400
there is about three, four years till you get it. Like the delay between feature freeze and
link |
01:27:02.080
shipping. So you always get one or two years more. And so we shipped 14 on time. We shipped
link |
01:27:10.240
17 on time. And we shipped, we will ship 20 on time. It'll happen. And furthermore,
link |
01:27:19.280
this allows, this gives a predictability that allows the implementers, the compiler implementers,
link |
01:27:25.680
the library implementers, to, they have a target and they deliver on it. 11 took two years before
link |
01:27:34.320
most compilers were good enough. 14, most compilers were actually getting pretty good in 14.
link |
01:27:42.000
17, everybody shipped in 17. We are going to have at least almost everybody ship almost
link |
01:27:51.840
everything in 20. And I know this because they're shipping in 19. Predictability is good. Delivery
link |
01:27:59.600
on time is good. And so yeah. That's great. So that's how it works. There's a lot of features
link |
01:28:06.960
that came in in C++11. There's a lot of features at the birth of C++ that were amazing and ideas
link |
01:28:15.520
with concepts in 2020. What to you is the most, just to you personally, beautiful or
link |
01:28:25.600
just do you sit back and think, wow, that's just nice and clean feature of C++?
link |
01:28:36.960
I have written two papers for the history of programming languages conference, which basically
link |
01:28:44.160
asked me such questions. And I'm writing a third one, which I will deliver at the history of
link |
01:28:50.800
programming languages conference in London next year. So I've been thinking about that and there
link |
01:28:56.160
is one clear answer. Constructors and destructors. The way a constructor can establish the environment
link |
01:29:04.720
for the use of a type for an object and the destructor that cleans up any messes at the end
link |
01:29:11.680
of it. That is key to C++. That's why we don't have to use garbage collection. That's how we can
link |
01:29:18.880
get predictable performance. That's how you can get the minimal overhead in many, many cases
link |
01:29:27.120
and have really clean types. It's the idea of constructor, destructor pairs. Sometimes it comes
link |
01:29:35.440
out under the name RIAII. Resource acquisition is initialization, which is the idea that you
link |
01:29:43.760
grab resources and the constructor and release them and destructor. It's also the best example
link |
01:29:50.080
of why I shouldn't be in advertising. I get the best idea and I call it resource acquisition is
link |
01:29:56.800
initialization. Not the greatest naming I've ever heard. So it's types, abstraction of types.
link |
01:30:08.800
You said, I want to create my own types. Types is an essential part of C++ and making them
link |
01:30:18.000
efficient is the key part. To you, this is almost getting philosophical, but the construction
link |
01:30:27.680
and the destruction, the creation of an instance of a type and the freeing of resources from that
link |
01:30:35.680
instance of a type is what defines the object. It's almost like birth and death is what defines
link |
01:30:45.120
human life. Yeah, that's right. By the way, philosophy is important. You can't do good
link |
01:30:52.320
language design without philosophy because what you are determining is what people can express
link |
01:30:57.600
and how. This is very important. By the way, constructors, destructors came into C++ in 1979
link |
01:31:07.520
in about the second week of my work with what was then called C++. It is a fundamental idea.
link |
01:31:15.120
Next comes the fact that you need to control copying because once you control, as you said,
link |
01:31:21.200
birth and death, you have to control taking copies, which is another way of creating an object.
link |
01:31:29.520
Finally, you have to be able to move things around so you get the move operations. That's
link |
01:31:35.680
a set of key operations you can define on a C++ type. To you, those things are just a beautiful
link |
01:31:47.280
part of C++ that is at the core of it all. Yes. You mentioned that you hope there will be one
link |
01:31:55.040
unified set of guidelines in the future for how to construct the programming language.
link |
01:32:00.000
So perhaps not one programming language, but a unification of how we build programming languages
link |
01:32:08.400
if you remember such statements. I have some trouble remembering it, but I know the origin
link |
01:32:13.760
of that idea. Maybe you can talk about, C++ has been improving. There's been a lot of programming
link |
01:32:20.000
language. Where does the archer history taking us? Do you hope that there is a unification about
link |
01:32:27.040
the languages with which we communicate in the digital space?
link |
01:32:33.760
I think that languages should be designed not by clobbering language features together and
link |
01:32:42.400
doing slightly different versions of somebody else's ideas, but through the creation of a set
link |
01:32:51.120
of principles, rules of thumbs, whatever you call them. I made them for C++ and we're trying to
link |
01:33:02.560
teach people in the Standards Committee about these rules because a lot of people come in and say,
link |
01:33:07.440
I've got a great idea. Let's put it in the language. Then you have to ask, why does it fit in the
link |
01:33:13.440
language? Why does it fit in this language? It may fit in another language and not here,
link |
01:33:18.960
or it may fit here and not the other language. So you have to work from a set of principles and
link |
01:33:24.240
you have to develop that set of principles. One example that I sometimes remember is I was sitting
link |
01:33:35.360
down with some of the designers of Common Lisp and we were talking about languages and language
link |
01:33:44.880
features and obviously we didn't agree about anything because well, Lisp is not C++ and vice
link |
01:33:52.960
versa. Too many parentheses. But suddenly we started making progress. I said, I had this problem
link |
01:34:02.400
and I developed it according to these ideas and they said, why? We had that problem, different
link |
01:34:09.200
problem and we developed it with the same kind of principles. And so we worked through large chunks
link |
01:34:18.080
of C++ and large chunks of Common Lisp and figured out we actually had similar sets
link |
01:34:26.000
of principles of how to do it. But the constraints on our designs were very different
link |
01:34:31.600
and the aims for the usage was very different. But there was commonality in the way you reason
link |
01:34:40.640
about language features and the fundamental principles you were trying to do.
link |
01:34:45.200
So do you think that's possible? So they're just like there is perhaps a unified theory of physics,
link |
01:34:53.680
of the fundamental forces of physics, that I'm sure there is commonalities among the language
link |
01:35:01.200
but there's also people involved that help drive the development of these languages. Do you have a
link |
01:35:08.000
hope or an optimism that there will be a unification if you think about physics in Einstein towards
link |
01:35:18.560
a simplified language? Do you think that's possible? Let's remember sort of modern physics,
link |
01:35:27.840
I think started with Galileo in the 1300s. So they've had 700 years to get going.
link |
01:35:35.360
Modern computing started in about 49. We've got, what is it, 70 years. They have 10 times.
link |
01:35:46.560
And furthermore, they are not as bothered with people using physics the way we are worried about
link |
01:35:53.760
programming. It's done by humans. So each have problems and constraints the others have but
link |
01:36:02.640
we are very immature compared to physics. So I would look at sort of the philosophical level
link |
01:36:11.600
and look for fundamental principles like you don't leak resources, you shouldn't.
link |
01:36:18.640
You don't take errors at runtime that you don't need to. You don't violate some kind of type
link |
01:36:28.800
system. There's many kinds of type systems, but when you have one, you don't break it, etc. etc.
link |
01:36:36.560
There will be quite a few and it will not be the same for all languages. But I think if we step
link |
01:36:44.240
back at some kind of philosophical level, we would be able to agree on sets of principles
link |
01:36:51.440
that applied to sets of problem areas. And within an area of use, like in C++'s case,
link |
01:37:03.920
what used to be called systems programming, the area between the hardware and the fluffier
link |
01:37:10.800
the fluffier parts of the system, you might very well see a convergence. So these days you see
link |
01:37:18.480
Rust having adopted RAII and some time accuses me for having borrowed it 20 years before they
link |
01:37:26.000
discovered it. But we're seeing some kind of convergence here instead of relying on garbage
link |
01:37:37.280
collection all the time. The garbage collection languages are doing things like the dispose
link |
01:37:44.720
patterns and such that imitate some of the construction, destruction stuff. And they're
link |
01:37:50.800
trying not to use the garbage collection all the time and things like that. So there's a
link |
01:37:56.240
conversion. But I think we have to step back to the philosophical level, agree on principles,
link |
01:38:01.200
and then we'll see some conversions, convergences, and it will be application domain specific.
link |
01:38:12.080
So a crazy question, but I work a lot with machine learning with deep learning. I'm not
link |
01:38:17.520
sure if you touch that world much. But you could think of programming as a thing that takes some
link |
01:38:24.960
input. Programming is the task of creating a program, and the program takes some input and
link |
01:38:30.080
produces some output. So machine learning systems train on data in order to be able
link |
01:38:37.760
to take an input and produce output. But they're messy, fuzzy things, much like
link |
01:38:46.240
we as children grow up, we take some input, we make some output, but we're noisy, we mess up a
link |
01:38:52.960
lot, we're definitely not reliable biological system or a giant mess. So there's a sense in
link |
01:39:00.240
which machine learning is a kind of way of programming, but just fuzzy. It's very, very,
link |
01:39:06.720
very different than C++. Because C++ is a, like it's just like you said, it's extremely reliable,
link |
01:39:14.800
it's efficient, it's, you know, you can, you can measure, you can test in a bunch of different
link |
01:39:19.840
ways with biological systems or machine learning systems. You can't say much, except sort of
link |
01:39:27.520
empirically saying that 99.8% of the time, it seems to work. What do you think about this fuzzy
link |
01:39:35.680
kind of programming? Do you even see it as programming? Is it solely and totally another
link |
01:39:42.080
kind of world? I think it's a different kind of world. And it is fuzzy. And in my domain,
link |
01:39:48.880
I don't like fuzziness. That is, people say things like they want everybody to be able to program.
link |
01:39:58.880
But I don't want everybody to program my airplane controls or the car controls.
link |
01:40:08.080
I want that to be done by engineers. I want that to be done with people that are specifically
link |
01:40:13.840
educated and trained for doing building things. And it is not for everybody. Similarly, a language
link |
01:40:23.760
like C++ is not for everybody. It is generated to be a sharp and effective tool for professionals,
link |
01:40:33.760
basically, and definitely for people who, who, who aim at some kind of precision. You don't
link |
01:40:41.200
have people doing calculations without understanding math, right? Counting on your fingers is not going
link |
01:40:48.400
to cut it if you want to fly to the moon. And so there are areas where an 84% accuracy rate,
link |
01:41:01.680
16% false positive rate is perfectly acceptable and where people will probably get no more than
link |
01:41:10.080
70. You said 98%. I, the, what I've seen is more like 84. And by, by really a lot of blood,
link |
01:41:18.800
sweat and tears, you can get up to the 92 and a half. So this is fine if it is, say,
link |
01:41:26.640
pre screening stuff before the human look at it. It is not good enough for, for life
link |
01:41:35.360
threatening situations. And so there's lots of areas where, where the fuzziness is, is perfectly
link |
01:41:42.720
acceptable and good and better than humans, cheaper than humans. But it's not the kind of
link |
01:41:48.640
engineering stuff I'm mostly interested in. I worry a bit about machine learning in the context
link |
01:41:57.360
of cars. You know, much more about this than I do. I worry too. But I'm, I'm, I'm sort of an
link |
01:42:03.760
amateur here. I've read some of the papers, but I've not ever done it. And the, the, the idea
link |
01:42:10.960
that scares me the most is the one I have heard, and I don't know how common it is, that
link |
01:42:21.840
you have this AI system, machine learning, all of these trained neural nets. And when there's
link |
01:42:32.000
something that's too complicated, they ask the human for help. But the human is reading a book
link |
01:42:39.120
or sleep. And he has 30 seconds or three seconds to figure out what the problem was that the AI
link |
01:42:47.920
system couldn't handle and do the right thing. This is scary. I mean, how do you do the cut over
link |
01:42:55.440
between the machine and the human? It's very, very difficult. And for the designer of one of the most
link |
01:43:05.200
reliable, efficient and powerful programming languages, C plus plus, I can understand why
link |
01:43:11.760
that world is actually unappealing. It is for most engineers. To me, it's extremely appealing,
link |
01:43:18.960
because we don't know how to get that interaction right. But I think it's possible,
link |
01:43:24.080
but it's very, very hard. It is. And now it's stating a problem, not a solution.
link |
01:43:29.280
That is impossible. I mean, I would much rather never rely on a human. If you're driving a nuclear
link |
01:43:34.720
reactor, if you're or an autonomous vehicle, it's much better to design systems written in C plus
link |
01:43:41.600
plus that never ask human for help. Let, let, let's just get one fact in. Yeah. All of this AI
link |
01:43:49.440
stuff is on top of C plus plus. So, so that's one reason I have to keep a weather eye out on
link |
01:43:58.160
what's going on in that field, but I will never become an expert in that area. But it's a good
link |
01:44:03.200
example of how you separate different areas of applications and you have to have different tools,
link |
01:44:10.000
different principles. And then they interact. No major system today is written in one language.
link |
01:44:17.760
And there are good reasons for that. When you look back at your life work,
link |
01:44:25.280
what is a, what is a moment? What is a event creation that you're really proud of?
link |
01:44:33.680
They say, damn, I did pretty good there. Is it as obvious as the creation of C plus plus?
link |
01:44:40.080
It's obvious. I've spent a lot of time with C plus plus and there's a combination of a few good
link |
01:44:48.240
ideas, a lot of hard work and a bit of luck. And I've tried to get away from it a few times,
link |
01:44:55.760
but I get dragged in again, partly because I'm most effective in this area and partly because
link |
01:45:02.320
what I do has much more impact. If I do it in the context of C plus plus, I have four and a half
link |
01:45:10.320
million people that pick it up tomorrow. If I get something right, if I did it in another field,
link |
01:45:16.080
I would have to start learning, then I have to build it and then we'll see if anybody wants to use it.
link |
01:45:22.640
One of the things that has kept me going for all of these years is one, the good things that people
link |
01:45:29.200
do with it and the interesting things they do with it. And also, I get to see a lot of
link |
01:45:37.920
interesting stuff and talk to a lot of interesting people. I mean, if it has just been statements
link |
01:45:46.640
on paper or on a screen, I don't think I could have kept going. But I get to see the telescopes
link |
01:45:53.440
up on Mauna Kea and I actually went and see how Ford built cars and I got to JPL and see how they
link |
01:46:02.480
do the Mars rovers. There's so much cool stuff going on and most of the cool stuff is done by
link |
01:46:11.360
pretty nice people and sometimes in very nice places, Cambridge, Sofia and Tbilisi, Silicon Valley.
link |
01:46:21.680
Yeah, there's more to it than just code. But code is central.
link |
01:46:29.040
On top of the code are the people in very nice places. Well, I think I speak for millions of
link |
01:46:34.960
people. We are in saying thank you for creating this language that so many systems are built on
link |
01:46:43.440
top of that make a better world. So thank you and thank you for talking today.
link |
01:46:49.200
Yeah, thanks and we'll make it even better. Good.