C++ Creator Bjarne Stroustrup Weighs in on Distributed Systems, Type Safety

Started by NiveRoshni, Aug 10, 2020, 11:54 AM

Previous topic - Next topic

NiveRoshni

C++ Creator Bjarne Stroustrup Weighs in on Distributed Systems, Type Safety and Rust

In June the creator of the C++ programming language, 69-year-old Bjarne Stroustrup, appeared on YouTube's channel on behalf of the Association for Computing Machinery's Special Interest Group on Programming Languages.

Some 35 years after bringing his language into the world, Stroustrup compared his earliest goals to how the language has ultimately evolved, shared some thoughts on the world's other programming languages, and revealed what he does when he's not shepherding the language's massive user community. And he also took a few moments to explain why C++ "is far, far better than it was a couple of decades ago."

Ask Stroustrup Anything

Given that is was a "Ask Me Anything"-styled session, someone asked what he'd change if he could take a time machine back to the day he created the language, Stroustrup replied, "Um... That's a time machine question, and we don't have a time machine." And then he went on to explain where that leaves us.

"One of the interesting aspects of programming language design is that if you succeed, you have what you did many many years and decades ago, and you have to live with it. Once you get users, you have responsibilities, and one of the responsibilities is not to break their code. And so stability becomes a major, major issue. There's a few hundred billion lines of C++ out there, and we can't break them," he said.

Later he added that as far as syntax is concerned, early on he'd decided to avoid re-inventing the wheel, since he was extending the conventions from the already-existing C programming language. "I knew it was trouble when I started. However, there was already a C community, and I could spend my time teaching people how to write a For loop, or I could provide a decent class concept. I couldn't do both. There wasn't time for it..."

But besides adding object orientation to C, he also remembered his earliest design goals for C++. "I wanted very great freedom of expression, very great generality. I wanted performance comparable to hand-coded C, straight on the machine. And I wanted basic type safety. Given the time, the technology, and the knowledge, I got two out of three. And I've spent the next 20 years trying to figure out how we get all three."

"I get a little bit sad when I hear people talk about C++ as if they were back in the 1980s, the 1990s, which a lot of people do ... They looked at it back in the dark ages, and they haven't looked since."– Bjarne Stroustrup

But to add that third missing thing — type safety — C++ now has a feature (named "concepts") that can limit the data types of the language's function templates. Elaborating in a later answer, Stroustrup adds "I'm not a great fan of template meta-programming. It is ugly, complicated, and so useful that sane people will do it despite its problems. So what I would like to do is replace the ugly and complicated parts of template meta programming with something simpler. And something simpler is generic programming, mostly." Generic programming involves the use of types to be specified later, and Stroustrup explains that "Concepts is part of that. You can do proper type-checking of your arguments, you can work on the requirements, you can overload on the requirements so that you can have two different functions based on requirements."

He adds later that "If I could've invented concepts in 1988 when I was doing it, we would've been better off today."

A question came in from Delhi: is there another modern must-have language feature he'd like to see retrofitted onto another widespread language (the way he'd brought object-orientation to C?) But Stroustrup's response seemed to take the long perspective, looking back over nearly four decades. "If you're looking at really major things, they don't come very often. There were classes and then class hierarchies that came in the package of object-oriented programming from Simula, and that was what I merged with C. And then I've been looking ever since at generic programming."

But he seems proud about the ways the language has evolved over the years. "I get a little bit sad when I hear people talk about C++ as if they were back in the 1980s, the 1990s, which a lot of people do," Stroustrup says later. "They looked at it back in the dark ages, and they haven't looked since."

Growing or Dying

He's ready when a questioner from Penn State asks what makes C++ attractive to people today. "Bigger community. Better performance. Greater flexibility. That's a pretty good start. Massive tool support, massive libraries. It's just a good, solid language." He also describes what happens to the languages that tried to displace C++. First, "When you simplify a language to make it easier, you usually throw away something..." But even beyond that, simplified languages end up on one of two paths. "You fail because you can't get people to use your language. Or you succeed, and your language grows." And he's ready with an example. "Java is now three, four, five times more complex and larger than it was when it started out, claiming it was better than C++ because it was simpler.

"So you can grow or you can die. Pick your poison."

Later a developer in Dallas couldn't resist asking Stroustrup what his favorite programming languages were, but Stroustrup didn't take the bait. "I don't believe that there is or could be a perfect programming language — at least not in the time scale we're talking about, a few decades or a hundred years. Maybe in a hundred years, but not in my lifetime."

He's aware of other languages, as he reveals in his answer to a later question. ("I think C++ can do anything Rust can do, and I would like it to be much simpler to use.") And towards the end, he couldn't resist noting that longevity has its advantages. "It's highly humorous when some of the Rust people come up and accuse me of having stolen some of their ideas without acknowledging — when some of the things I did I actually did almost 40 years ago."

One of the most interesting responses came to a relatively simple question: what are you working on now? Stroustrup discusses his "day job" as a technical fellow/managing director at Morgan Stanley, where he describes his problem domain as "distributed systems, networking, getting data from A to B under various constraints... I find that quite interesting. That was what my Ph.D. was in, so I've been doing it ever since." He also gets his hands onto some performance issues. ("When I was in academia, I thought I knew about performance because I could count microseconds. Now I have to count nanoseconds!") Stroustrup also makes suggestions about large codebases — "how can you make large amounts of code reliable, maintainable, bring them up to date with modern stuff..." And every year he also teaches a course on software design at Columbia University.

But of course, Stroustrup says he has one more responsibility: "try to look after" the C++ standards process. "People are so excited about C++ that we have 250 people turn up at standards meetings. Getting 250 people to agree to anything is very hard, and it's also relatively easy to get large crowds excited about something that's fashionable or new or something like that. So I have to preach stability and careful progress and not overdoing complexity a lot."

In response to another question, he shared some design goals that may be further off in the future. "We have a model for better concurrency coming up. Almost certainly it will be in [C++ version] 23. It exists and it's used. It's backed by people like Facebook and NVIDIA and Intel... So that's where we'll get a better concurrency, better use of hardware... Beyond that, I am looking at functional-style pattern matching. I've been working on that for a long time — I proposed it for C++ 17. Maybe we'll get it for 23 or 26, but things move slowly when you're moving a really massive community. If we can get it right, I'd love it."

But looking even further down the road, he'd like to see more support for distributed contributing.

"This was how I got into it in the first place. I wanted to build what would've been the first Unix cluster — if I'd managed to finish it instead of getting distracted by C++. And I would like to see support in the language, or in the libraries, for actually communicating with large groups of computers and cores and such. We're pretty good at multicore, multithreading, that kind of stuff. But I'd like to get to not-shared memory.

"Anyway, that's my personal sort of hobby horse — has been for a long time."