back to indexBjarne Stroustrup: Learn More than One Programming Language
00:00:00.000 |
You've said that it's good for any professional programmer to know at least five languages, 00:00:07.560 |
speaking about a variety of languages that you've taken inspiration from. 00:00:13.640 |
And you've listed yours as being, at least at the time, C++, obviously, Java, Python, 00:00:24.520 |
Can you, first of all, update that list, modify it? 00:00:28.360 |
You don't have to be constrained to just five, but can you describe what you picked up also 00:00:37.840 |
How you see them as inspirations for even you working with C++? 00:00:46.280 |
So about languages, you should know languages. 00:00:52.200 |
I reckon I knew about 25 or thereabouts when I did C++. 00:00:57.180 |
It was easier in those days because the languages were smaller and you didn't have to learn 00:01:02.960 |
a whole programming environment and such to do it. 00:01:12.320 |
I imagine just like with natural language for communication, there's different paradigms 00:01:30.360 |
The important thing that the number is not one. 00:01:35.360 |
It's like, I don't like, I mean, if you're a monoglot, you are likely to think that your 00:01:40.160 |
own culture is the only ones, periods, for everybody else's. 00:01:43.760 |
A good learning of a foreign language and a foreign culture is important. 00:01:51.640 |
With programming languages, you become a better programmer, better designer with the second 00:01:58.120 |
Now, once you've got two, the way to five is not that long. 00:02:06.620 |
And then when I had to pick five, I sort of thinking what kinds of languages are there. 00:02:24.560 |
The C++ optimizers write better machine code than I do. 00:02:30.960 |
But I don't think I could appreciate them if I actually didn't understand machine code 00:02:38.480 |
At least in my position, I have to understand a bit of it because you mess up the cache 00:02:45.200 |
and you're off in performance by a factor of 100. 00:02:50.040 |
It shouldn't be that if you are interested in either performance or the size of the computer 00:03:02.000 |
I used to mention C, but these days going low level is not actually what gives you the 00:03:09.080 |
It is to express your ideas so cleanly that you can think about it and the optimizer can 00:03:17.260 |
My favorite way of optimizing these days is throw out the clever bits and see if it still 00:03:28.620 |
So I need the abstraction mechanisms or something like C++ to write compact high performance 00:03:35.820 |
There was a beautiful keynote by Jason Turner at the CPP Con a couple of years ago where 00:03:42.160 |
he decided he was going to program Pong on Motorola 6800 I think it was. 00:03:53.880 |
And he says, well, this is relevant because it looks like a microcontroller. 00:04:00.320 |
It has not very much memory and it's relatively slow. 00:04:04.460 |
And so he shows in real time how he writes Pong starting with fairly straightforward 00:04:15.600 |
And what he's doing, he's writing C++ and it translates into 86 assembler, which you 00:04:25.880 |
can do with Clang and you can see it in real time. 00:04:29.400 |
It's the compiler explorer, which you can use on the web. 00:04:34.100 |
And then he wrote a little program that translated 86 assembler into Motorola assembler. 00:04:41.860 |
And so he types and you can see this thing in real time. 00:04:46.680 |
And even if you can't read the assembly code, you can just see it. 00:04:55.700 |
He increases the abstraction level, uses C++ 11 as it were better. 00:05:02.680 |
His code gets cleaner, it gets easier to maintain, the code shrinks and it keeps shrinking. 00:05:09.180 |
And I could not in any reasonable amount of time, write that assembler as good as the 00:05:17.580 |
compiler generated from really quite nice modern C++. 00:05:22.980 |
And I'll go as far as to say that the thing that looked like C was significantly uglier 00:05:30.260 |
and smaller when it became and larger when it became machine code. 00:05:38.340 |
So the abstractions that can be optimized are important. 00:05:43.340 |
I would love to see that kind of visualization in larger code bases. 00:05:48.620 |
But you can't show a larger code base in a one hour talk and have it fit on screen. 00:05:56.340 |
So my two languages would be machine code and C++. 00:06:00.820 |
And then I think you can learn a lot from the functional languages. 00:06:09.380 |
I think actually you learn the same lessons of expressing especially mathematical notions 00:06:17.720 |
really clearly and having a type system that's really strict. 00:06:24.160 |
And then you should probably have a language for sort of quickly churning out something.