An interview with Bjarne Stroustrup, creator of C++


Bjarne Stroustrup created the C++ programming language in 1979, and it’s still just as important today as it was 38 years ago, especially with its expansion into mobile development.

C++17, the latest version of the language, is due out later this year, and last week Dr. Stroustrup visited Montreal to present a talk on using modern C++. The lecture, presented by TechnoMontreal and Morgan Stanley, was given last Thursday night at the Centre Mont-Royal to 900 programmers, students, and tech enthusiasts.

While he was in town, MTLinTECH had the chance to talk to Dr. Stroustrup about the history of C++, the changes we can expect to see in C++17, and what’s next on the horizon.


 

What prompted you to develop C++?

I was a young researcher at Bell Labs and I wanted to study and build a distributed system. For that, I needed a language that could do low-level stuff well: Fast drivers, schedulers, memory management, and such. And I needed something where I could abstract away from the low-level hardware because I wanted a distributed system. I also wanted to use shared memory. Some languages at the time were good at hardware, some were good at abstraction, but there were none
that could do both. So, I built one. There was lots of good ideas and good local support for C so I built on that. I knew Simula quite well from my student days, so I knew the power of those abstraction mechanisms. The result turned out to be useful not just for me but also for friends and colleagues.

Who did you build the first C++ model for?

I built it for myself, but very soon I had other people using it also. After half a year, I actually got my first non-research user. C++ turned out to be very useful for people very early on. So, I thought it was just for myself, but very soon it wasn’t.

Between 1960 to 1980 developers mainly followed Procedural Programming Paradigms
and there were many languages COBOL, C, PASCAL etc. Object Oriented was in its early
days, Simula was the first OO language. What was lacking in procedural languages and
what made you realize that Object Oriented Paradigm will be helpful in Software
Development?

Well fundamentally the set of types available was, in my opinion, insufficient. That is, if I want to do just about anything, I want some appropriate types. Classical examples of this are complex numbers, matrices, triangular matrices and such. There’s just not enough types in procedural languages. I used Simula because I had been taught Simula by one of the two designers, Kristen Nygaard. He was one of the inventors of Object Oriented and he was the one who discovered inheritance. Simula was where we got member functions, methods, from. We had been using those object-oriented techniques since Simula came out in 1967.

Why should aspiring developers choose to learn C++ to survive in the growing world of
computers?

I think because C++ is still close to unique in being able to handle both the low-level and high-level stuff. To handle both the machine and the abstraction. Also, because the subdomain that C++ was designed for, the area C++ was designed for, is bigger than ever. It’s applications that have conflicts and require good use of hardware. That a niche; it’s not everything, and it was never meant to be everything, but it’s bigger than it was when I started. There’s currently about four and a half million C++ programmers. A lot of those are in finance because that’s where there’s demands on reliability and performance and good response. Similarly, many are in embedded systems, similarly in games. Our cell phones, the lower levels of any cellphone these days, is C++. Quite often some of the higher levels are too because it’s pretty good with power
consumption. Compared to the sort of language that requires a lot of indirection and housekeeping, C++ just works better. So basically C++’s niche is bigger than it ever was.

How important do you think readability is in a programming language?
 
Oh! it’s immensely important. It’s something I’m working on constantly. Experts want language to be more expressive. However, for most of us, our knowledge is in most fields, limited, so we need all the help we can get. Actually, one of the themes of the talk I gave yesterday was simplification. The example of how C++ is much simpler than it was 10 or 15 years ago. You can write much shorter programs and much easier-to- read programs and they run just as fast or faster than they used to.

So C++17 has been submitted for formal approval now?

C++17 has been signed off by the committee. You need a sign-off from the ISO headquarters in Geneva to get the official number. That has not happened yet, but we’re pretty sure it will be in 2017. It usually takes a couple of months and they got all our last documents earlier this month, so they should be able to do it. There is absolutely no technical work left. 17 has shipped.

Which of these improvements will have the biggest impact on developers?

I don’t actually think these improvements will have a major impact on developers, because I think C++17 adds lot of little things as opposed to one big thing. I had hoped for bigger things, so if you hear me being a bit grumpy about 17 it’s because it’s too many little things and too few big things. There’s a little bit for everybody. I like particularly a feature called structured binding, it gives us the ability to declare multiple variables initialised from a tuple or struct. It’s simpler, cleaner. That’s good. There’s parallel algorithms that will help people write parallel programs without using threads directly from application code. There’s some new guarantees for the order of evaluation. Nobody will ever notice it; but it will prevent errors from happening. There’s some better guarantees for eliminating copies, that’s also one of these invisible
improvements that will be important over time. The point is that just giving a list of features is boring. If you are doing vectorization, which a lot of people do, you can now dynamically allocate something that requires greater alignment. That’s a highly, highly technical improvement. Vectorization is one of the ways we can increase performance significantly. There’s a file system library so that you can manipulate file systems. There’s a variant type which I really like which will help us get rid of code formerly using unions. One of the things that I look at with the language is what can you do to minimize the chance of errors, minimize the number of errors. Simplification is one component. The other is to directly support, in a type-safe manner, things that people have to do. That’s part of what I work on in my Core Guidelines project. It tries to explain how you could write better code if you weren’t totally constrained by compatibility and such. It also tries to answer the question ‘What is modern C++?’ Of course, you can write C++ the way they did it in the 80s or the 90s and far too many people do. So, you need some guidance. You don’t just need the language features, you need some guidance of how to use them.

Apparently, Concepts, for improving compiler diagnostics, won't make it into C++ 17 after
also not making it into previous releases. Is this a big disappointment?

Yes, it’s a big disappointment. I wanted something like that when I first designed Templates in ’88 and I just didn’t know how to do it, nobody did. Now we know how to do it, but it has taken five years for the committee to accept half of it. Half of the concept design got into the document in the first revision after 17. We’re already past 17. We’re already onto the next iteration, we’re already onto 20. Concepts are shipping in GCC. But it was a disappointment that concepts didn’t get into 17. That would have been the prime feature. Using concepts is one of the major ways you can simplify template use. There’s far too much complexity, so I’ve been attacking this for a while. Something called constexpr functions, which is the functions that can be evaluated at compile time, removes the need for some of the most horrendous templates. Concepts was the other part that will make code much simpler. We’ll get them. If you’re using GCC you can actually use concepts now. I know quite a few places where concepts are in production use. Concepts are just not the official standard yet.

Why not delay shipping for a year in order to include those features in the release?

People had proposed that. I was asked in public if we should delay. But I said no, ship on time. We have a reputation to maintain, we need to deliver on time. There’s still a lot of people who don’t believe it, but we delivered 14 on time, we delivered 17 on time, and I think we’ll deliver 20 on time. And that’s important because once things start to slip, it’s hard to avoid people wanting to slip a little bit further to get in a little bit more. I want to set a good example, even though I was disappointed. Concepts was a feature I had been working on for the better part of a decade, I couldn’t get it but I wasn’t going to mess with our schedule and set a bad example.

What are some of the biggest changes you’ve seen in the developer landscape since C++
was first released?

The first thing that comes to mind is that people these days are much better technicians. They are, however, sometimes not as visionary. Developers and programmers have lost in some sense their willingness to try something new. That’s what I think I’ve seen. Also, there’s a greater appreciation for simplicity.

Where do you see the programming world in the near future?

I think there will be an increasing amount of specialization. That is, application builders will more and more used specialized systems. I think that the world that I tend to live in, which is closer to hardware, where you need performance and dependability, reliability, will be specialized into more classical programming, more demands on system building skills. I think we are going to see many sub-specializations. There are people who think all programming is the same but I disagree: depending on the application constraints and the skills and the individuals, things differ.

Any further comments?
 
I think it’s worth remembering that C++ 17 is just one snapshot of C++. What we are looking at is a developing and living language. We have people still trying to catch up to 11. A lot of people have gotten to 14, but they’re still bringing up the rear. 17 is already shipping, but it is not a target in and of itself. It’s a step on the way to the next thing. I’m keeping my fingers crossed for C++20. It looks to me like we’re going to get concepts and modules and co-routines, I’m working on a contract for run-time assertions and on run-time static reflections. These will make a huge difference for the C++ community. And we’ll get better libraries. We’re doing all the preparation for that, lots of work needed to get to there. So, I’m grumpy that none of it made it into 17, but that doesn’t mean we won’t get there still. C++17 is just one step in the process.

+ There are no comments

Add yours