back to index

Bjarne Stroustrup: Journey to C++ from Fortran, Algol, Simula, and C


Whisper Transcript | Transcript Only Page

00:00:00.000 | And what was the first programming language, if I may ask it this way, that you fell in
00:00:07.660 | love with?
00:00:09.740 | I think I'll call it 60.
00:00:12.460 | And after that, I remember Snowball.
00:00:19.600 | I remember Fortran.
00:00:21.640 | Didn't fall in love with that.
00:00:22.980 | I remember Pascal.
00:00:24.720 | Didn't fall in love with that.
00:00:26.220 | It all got in the way of me.
00:00:29.560 | And then I discovered Assembler, and that was much more fun.
00:00:33.760 | And from there, I went to microcode.
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:51.280 | microcode.
00:00:52.900 | That was sort of the first really profitable things.
00:00:55.480 | I paid for my master's, actually.
00:00:58.920 | And then I discovered Simula, which was absolutely great.
00:01:02.880 | Simula?
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:17.600 | when they were... while they were doing it.
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:40.960 | And that was a surprise to me.
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:03.280 | and flexible.
00:02:04.280 | Let's get into the details a little bit.
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:35.160 | And if you can't, it's not so 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:24.960 | Yes, they invented it.
00:03:27.400 | Every language that uses the word class for type is a descendant of simula.
00:03:35.840 | We are indirectly.
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:51.780 | And so they called their types classes.
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:08.400 | your perspective?
00:04:09.520 | So we started with Algol 60, Simula, Pascal, but that's just the 60s and 70s.
00:04:17.160 | I can try.
00:04:19.840 | The most sort of interesting and major improvement of programming languages was Fortran, the
00:04:27.520 | first Fortran.
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:00.560 | wanted.
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:18.240 | formulas translated into the machine.
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:39.620 | And that was new and that was great.
00:05:42.560 | And it's something to remember, we want to raise the language to the human level, but
00:05:49.360 | we don't want to lose the efficiency.
00:05:52.520 | So that's- And that was the first step towards the human.
00:05:55.700 | That was the first step.
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:07.060 | And Simula came out.
00:06:08.560 | No, let's not go to Simula yet.
00:06:11.620 | Let's go to Algor.
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:32.640 | Lexical, syntax, semantics.
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:49.680 | So we got Algor.
00:06:50.680 | That was very pretty.
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:17.840 | And that's where I got very interested.
00:07:22.160 | Preston Nugent, who's the main idea man behind Simula.
00:07:27.240 | That was late '60s.
00:07:28.240 | This was late '60s.
00:07:29.240 | Well, I was a visiting professor in Aarhus.
00:07:34.080 | And so I learned object-oriented programming by sitting around and well, in theory, discussing
00:07:43.960 | with Preston Nugent.
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:53.080 | You're just listening.
00:07:54.080 | So it was great.
00:07:56.040 | I learned it from there.
00:07:57.540 | Not to romanticize the notion, but it seems like a big leap to think about object-oriented
00:08:02.720 | programming.
00:08:05.400 | It's really a leap of abstraction.
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:18.320 | it an obvious one at the time?
00:08:21.480 | It was not obvious.
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:39.640 | never knowing it.
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:54.000 | flexible types and more efficient types.
00:08:56.460 | But it's still the fundamental idea.
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:13.600 | And that's the key idea.
00:09:16.280 | People picked up on the class hierarchies and the virtual functions and the inheritance.
00:09:23.480 | And that was only part of it.
00:09:27.360 | It was an interesting and major part and still a major part in a lot of graphic stuff.
00:09:33.360 | But it was not the most fundamental.
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:42.320 | independent.
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:20.920 | want to.
00:10:23.320 | And this is actually a real example.
00:10:25.960 | They used it to simulate and optimize the emergency services for somewhere in Norway
00:10:36.960 | back in the 60s.
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:02.040 | Yeah, that's a beautiful, powerful idea.
00:11:05.600 | And of course, it stretches through your work, C++, as we'll talk about.
00:11:10.680 | But I think you've structured it nicely.
00:11:14.840 | What other breakthroughs came along in the history of programming languages?
00:11:19.240 | If we were to tell the history in that way?
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:27.800 | opposed to all the paths.
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:39.920 | It's obviously important.
00:11:41.560 | It's obviously interesting.
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:48.640 | to go to production.
00:11:50.840 | It's in the world I'm at, which are constrained by performance, reliability issues, deployability,
00:12:03.200 | cost of hardware.
00:12:06.120 | I don't like things to be too dynamic.
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:35.200 | The chance is zero.
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:54.240 | I'm interested in.
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:02.960 | flexible languages to the hardware.
00:13:06.280 | The stuff that lasts for 10, 20, 30 years is robust, operates under very constrained
00:13:12.400 | conditions.
00:13:13.400 | Yes, absolutely.
00:13:14.400 | That's right.
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:37.400 | with Smalltalk.
00:13:40.120 | It's just not as relevant in my world.
00:13:48.500 | And by the way, I distinguish between those and the functional languages where I go to
00:13:53.440 | things like ML and Haskell.
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.
00:14:27.000 | [END]
00:14:28.500 | [BLANK_AUDIO]
00:14:37.020 | [BLANK_AUDIO]