back to indexBjarne Stroustrup: Journey to C++ from Fortran, Algol, Simula, and C
00:00:00.000 |
And what was the first programming language, if I may ask it this way, that you fell in 00:00:29.560 |
And then I discovered Assembler, and that was much more fun. 00:00:38.120 |
So you were drawn to the... you found the low-level stuff beautiful. 00:00:44.360 |
I went through a lot of languages, and then I spent significant time in Assembler and 00:00:52.900 |
That was sort of the first really profitable things. 00:00:58.920 |
And then I discovered Simula, which was absolutely great. 00:01:03.880 |
Simula was the extension of Algor60, done primarily for simulation. 00:01:11.360 |
But basically, they invented object-oriented programming at inheritance and runtime polymorphism 00:01:21.280 |
And that was the language that taught me that you could have the sort of the problems of 00:01:29.560 |
a program grow with size of the program rather than with the square of the size of the program. 00:01:36.720 |
That is, you can actually modularize very nicely. 00:01:43.960 |
It was also a surprise to me that a stricter type system than Pascal's was helpful, whereas 00:01:51.900 |
Pascal's type system got in my way all the time. 00:01:56.360 |
So you need a strong type system to organize your code well, but it has to be extensible 00:02:06.960 |
If you remember, what kind of type system did Pascal have? 00:02:10.460 |
What type system, typing system did Algor60 have? 00:02:14.960 |
Basically, Pascal was sort of the simplest language that Niklaus Wirt could define that 00:02:22.360 |
served the needs of Niklaus Wirt at the time. 00:02:26.640 |
And it has a sort of a highly moral tone to it. 00:02:31.940 |
That is, if you can say it in Pascal, it's good. 00:02:38.240 |
And this simula allowed you basically to build your own type system. 00:02:46.260 |
So instead of trying to fit yourself into Niklaus Wirt's world, Christian Nygaard's 00:02:54.040 |
language and Ole Johan Dahl's language allowed you to build your own. 00:02:59.100 |
So it's sort of close to the original idea of you build a domain-specific language as 00:03:07.800 |
a matter of fact, what you build is a set of types and relations among types that allows 00:03:14.920 |
you to express something that's suitable for an application. 00:03:18.920 |
So when you say types, the stuff you're saying has echoes of object-oriented programming. 00:03:27.400 |
Every language that uses the word class for type is a descendant of simula. 00:03:38.400 |
Christian Nygaard and Ole Johan Dahl were mathematicians and they didn't think in terms 00:03:44.880 |
of types, but they understood sets and classes of elements. 00:03:54.880 |
And basically in C++, as in simula, classes are user-defined type. 00:04:01.880 |
So can you try the impossible task and give a brief history of programming languages from 00:04:09.520 |
So we started with Algol 60, Simula, Pascal, but that's just the 60s and 70s. 00:04:19.840 |
The most sort of interesting and major improvement of programming languages was Fortran, the 00:04:29.200 |
Because before that, all code was written for a specific machine and each specific machine 00:04:34.840 |
had a language, a simply language or macro assembler or some extension of that idea. 00:04:43.400 |
But you are writing for a specific machine in the language of that machine. 00:04:50.760 |
And Bacchus and his team at IBM built a language that would allow you to write what you really 00:05:01.560 |
That is, you could write it in a language that was natural for people. 00:05:06.600 |
Now these people happened to be engineers and physicists, so the language that came 00:05:10.920 |
out was somewhat unusual for the rest of the world. 00:05:13.920 |
But basically they said formula translation because they wanted to have the mathematical 00:05:21.980 |
And as a side effect, they got portability because now they are writing in the terms 00:05:29.940 |
that the humans used and the way humans thought. 00:05:34.060 |
And then they had a program that translated it into the machines needs. 00:05:42.560 |
And it's something to remember, we want to raise the language to the human level, but 00:05:52.520 |
So that's- And that was the first step towards the human. 00:05:58.040 |
And of course, they were very particular kind of humans. 00:06:01.560 |
Business people were different, so they got Cobol instead and et cetera, et cetera. 00:06:14.080 |
Fortran didn't have at the time the notions of- not a precise notion of type, not a precise 00:06:22.680 |
notion of scope, not a set of translation phases that was what we have today. 00:06:35.080 |
It was sort of a bit of a model in the early days, but hey, they had just done the biggest 00:06:41.480 |
breakthrough in the history of programming, right? 00:06:44.360 |
So you can't criticize them for not having gotten all the technical details right. 00:06:53.200 |
And most people in commerce and science considered it useless because it was not flexible enough 00:07:00.760 |
and it wasn't efficient enough and et cetera, et cetera. 00:07:06.080 |
But that was a breakthrough from a technical point of view. 00:07:10.240 |
Then Simula came along to make that idea more flexible and you could define your own types. 00:07:22.160 |
Preston Nugent, who's the main idea man behind Simula. 00:07:34.080 |
And so I learned object-oriented programming by sitting around and well, in theory, discussing 00:07:46.200 |
But Preston, once you get started and in full flow, it's very hard to get a word in edgeways. 00:07:57.540 |
Not to romanticize the notion, but it seems like a big leap to think about object-oriented 00:08:09.360 |
And was that as big and beautiful of a leap as it seems from now in retrospect or was 00:08:24.760 |
And many people have tried to do something like that. 00:08:27.920 |
And most people didn't come up with something as wonderful as Simula. 00:08:33.440 |
Lots of people got their PhDs and made their careers out of forgetting about Simula or 00:08:41.760 |
For me, the key idea was basically I could get my own types. 00:08:46.820 |
And that's the idea that goes further into C++, where I can get better types and more 00:08:58.720 |
When I want to write a program, I want to write it with my types that is appropriate 00:09:03.640 |
to my problem and under the constraints that I'm under with hardware, software, environment, 00:09:16.280 |
People picked up on the class hierarchies and the virtual functions and the inheritance. 00:09:27.360 |
It was an interesting and major part and still a major part in a lot of graphic stuff. 00:09:36.960 |
It was when you wanted to relate one type to another, you don't want them all to be 00:09:43.880 |
The classical example is that you don't actually want to write a city simulation with vehicles 00:09:53.480 |
where you say, well, if it's a bicycle, write the code for turning a bicycle to the left. 00:09:59.480 |
If it's a normal car, turn right the normal car way. 00:10:02.840 |
If it's a fire engine, turn right the fire engine way. 00:10:06.880 |
You get these big case statements and bunches of if statements and such. 00:10:12.280 |
Instead, you tell the base class that that's the vehicle and say turn left the way you 00:10:25.960 |
They used it to simulate and optimize the emergency services for somewhere in Norway 00:10:38.920 |
So this was one of the early examples for why you needed inheritance and you needed 00:10:46.240 |
a runtime polymorphism because you wanted to handle this set of vehicles in a manageable 00:10:57.240 |
You can't just rewrite your code each time a new kind of vehicle comes along. 00:11:05.600 |
And of course, it stretches through your work, C++, as we'll talk about. 00:11:14.840 |
What other breakthroughs came along in the history of programming languages? 00:11:22.240 |
Obviously, I'm better at telling the part of the history that is the path I'm on as 00:11:29.760 |
Yeah, you skipped the hippie John McCarthy in Lisp, one of my favorite languages. 00:11:35.560 |
But Lisp is not one of my favorite languages. 00:11:43.160 |
Lots of people write code in it, and then they rewrite it into C or C++ when they want 00:11:50.840 |
It's in the world I'm at, which are constrained by performance, reliability issues, deployability, 00:12:09.760 |
It is really hard to write a piece of code that's perfectly flexible, that you can also 00:12:16.400 |
deploy on a small computer, and that you can also put in, say, a telephone switch in Bogota. 00:12:24.240 |
What's the chance if you get an error and you find yourself in the debugger, that the 00:12:29.080 |
telephone switch in Bogota on late Sunday night has a programmer around? 00:12:37.040 |
And so a lot of things I think most about can't afford that flexibility. 00:12:44.600 |
I'm quite aware that maybe 70, 80% of all code are not under the kind of constraints 00:12:56.280 |
But somebody has to do the job I'm doing, because you have to get from these high-level 00:13:06.280 |
The stuff that lasts for 10, 20, 30 years is robust, operates under very constrained 00:13:15.400 |
And it's fascinating and beautiful in its own way. 00:13:17.440 |
It's C++ is one of my favorite languages, and so is Lisp. 00:13:22.960 |
So I can embody it too, for different reasons, as a programmer. 00:13:30.720 |
I understand why Lisp is popular, and I can see the beauty of the ideas, and similarly 00:13:48.500 |
And by the way, I distinguish between those and the functional languages where I go to 00:13:57.760 |
Different kind of languages, they have a different kind of beauty, and they're very interesting. 00:14:03.480 |
And I actually try to learn from all the languages I encounter to see what is there that would 00:14:11.400 |
make working on the kind of problems I'm interested in, with the kind of constraints that I'm 00:14:20.480 |
interested in, what can actually be done better? 00:14:24.500 |
Because we can surely do better than we do today.