‘We need better balance between theory and practice’, Bjarne Stroustrup, Father of C++

It is not every day that you interact with people who have global influence. Meet Bjarne Stroustrup, father of C++ whose code runs nearly every computer on this planet.

YourStory spoke to Bjarne about his life, C++, programming and everything in between. Our niche readers of technology can read his other interviews here.

bjarne stroustrup

Edited excerpts

YS: What is the meaning of your name?

Bjarne: Meaning? I don’t usually think of Danish names as having meaning, but ‘Stroustrup’ is a tiny village in Jutland, and the etymology of ‘Bjarne’ is ‘bear.’

YS: Very little is known about your early days. What sparked your interest in computers?

Bjarne: Like many high-school students, I didn’t have a clue what to do after high-school. I read up on various possible careers, and dreamt of becoming an architect, a historian, a sociologist, an engineer, a psychologist, and more. My family was encouraging me to choose something with a clear job and career path after my studies, such as a business major.

In the end, I chose mathematics with computer science because mathematics was one of my favorite topics in high school and I was under the mistaken impression that computer science was a form of applied mathematics.

I had never seen a computer – in those days computers were rare and hidden away in dedicated machine rooms. I chose mathematics because it would make a good career and a lousy hobby over my second choice, history, which I thought would make a lousy career and a great hobby. To this day, I have more history books than computing books, and I’m part-way through a book on the history of England in the 14th century.

I was right that mathematics would make a great career, but only because I had been completely mistaken about computer science. It turned out to be far more interesting, practical, and useful than I had imagined. Also, real applied mathematics would probably have been beyond my limited talents in that direction. I ended up doing pure math and programming. So, I was signed up for computer science from the start, but what really sparked my interest was the introductory computer science course.

YS:  Tell us about some of the challenges you faced with procedural languages which led to the development of C++?

Bjarne: I enjoyed a lot of languages. I once discovered that I had used more than 20 languages before I started on C++. I was reasonably happy with procedural languages, at least the ones that didn’t try to get in the way of me expressing my ideas by trying to enforce some limited notion of how code should be written – Pascal comes to mind as always putting up some barrier.

I first encountered Simula in a course in the University of Aarhus (my home town) and learned enough about it to later decide to use it for a simulator I wanted to write as part of my PhD project in the University of Cambridge. Writing that program was surprisingly pleasant. It felt more like writing a series of small programs than writing a large program: The error rate and debug time went up linearly, rather than quadratic as I had (quite reasonably) expected. Secondly, the type system of Simula helped me express my ideas clearly, rather than getting in my way like Pascal’s had. I concluded that a flexible and extensible type system was a huge boon compared to both weaker type systems (as in most systems programming languages at that time) and less flexible type systems.

bs2I then had a very rude awakening: My simulator brought the university mainframe computer to its knees without even getting to realistic simulated loads! Out of necessity, I found a small experimental computer, the Cambridge CAP, and rewrote my simulator for that using BCPL. BCPL is a direct ancestor to C that makes C look like a very high-level language, but BCPL was fast and flexible. It was also hard to debug. Had I not done the design with the help of Simula, I don’t think I could have completed that program. My conclusion was that you didn’t just need a language with a flexible and extensible type system; you needed one that can run efficiently everywhere.

I saw Simula’s classes, class hierarchies, and strong static type checking as primarily means of organizing code and manage complexity. I disliked the label “Object-oriented programming” as overly hyped and (as typically practiced) overly restrictive. My very first paper on C++ (then called “C with Classes”) gives an example of the need to parameterize with types, that is, generic programming. I aimed for a synthesis of programming techniques and language support that goes beyond classical object-oriented programming.

YS: As more and more people are learning to code, we see a huge shift towards web technologies, and most of the software is moving to web in the form of apps on cloud, does it indicate that the future of C++ is limited?

Bjarne: C++ unique strengths are in the areas of infrastructure and resource-constrained tasks. The first and most obvious area for C++ is the implementation of those web technologies, such as browsers, virtual machines (e.g. for Java), interpreters (e.g. for JavaScript), and the whole critical net/web/telecommunications infrastructure that underlies it all.

There is even a new operating system designed specifically for the cloud, OSv from Cloudius written in C++. Next, there are the large demanding applications, such as Google’s search platform or Amazon’s web commerce platform.

The need for scale, reliability and energy efficiency ensures C++ a major role. Then there are the hand-held devices – smartphones, tablets, etc. – that require performance and energy conservations for their more advanced applications, such as streaming video, real-time image manipulation, voice recognition, multi-player games (both on the device itself and on the cloud end).

There are also efforts to run C++ in the browser (such as Google’s portable-native-client, NaCl) and efforts to more or less automatically port ‘ordinary applications,’ including C++ programs to the cloud (such as Rollapp).

In fact, there are so many efforts to bring C++ to the cloud that I am sure I don’t know about most of them. I’m confident that at least some of these efforts will succeed.

I don’t see C++’s role as trying to be the easiest programming language for simple applications by barely-trained people. There are plenty of languages/systems for that. If what you need is medium performance, medium reliability, medium complexity applications built by low-average programmers then there are plenty of languages for that (including C++, of course). However, C++ comes into its own when your push the envelope a bit. C++11 is a major improvement over C++98 in usability, performance, and flexibility. C++14 and especially C++17 will push further in those directions. None of this is specifically for ‘the cloud,’ but it remains to be seen exactly what the requirements for success ‘in the cloud’ are. As ever, I’ll place my bet on generality, flexibility, and performance.

YS: As an academic, what steps should be taken to improve the way programming is taught in schools and colleges around the world to create better and employable programmers.

Bjarne: We need a better balance between ‘theory’ and practice. There is a lot of talk about teaching methods, but I think the real problem is that the content is lacking in appropriateness; not that the delivery methods are inadequate (though of course that is also a problem in many places).

Bjarne Stroustrup

Bjarne Stroustrup in his early days

Good software and software development require a mixture practical skills and book learning. I find that teachers and students often fail to emphasize one or the other. For more details and examples, see my CACM paper: ‘What should we teach software developers? Why?’ Basically, I argue for a conventional foundation (including mathematics, machine architecture, data structures, and algorithms) complemented by some form of specialization (e.g., graphics, networking, or real-time systems).

Unsurprisingly, I think that greater emphasis should be placed on the practical aspects of constructing quality software (correctness, reliability, maintainability, tools, and performance). Finally, I think that a good developer needs a minor in some non-computer field to learn to appreciate other fiends and to communicate with non-programmers. That’s obviously a lot, so I consider a master’s degree (rather than a bachelor degree) the ideal for developers of demanding applications.

I think we need to place much greater emphasis on professionalism. Our civilization depends on software, so we need professionals to build and maintain our foundational software, not just semi-educated craftsmen willing to ship any program their managers tell them to ship. I see software development as a potentially noble profession, like medicine or some of the classical engineering disciplines, but we still have a long way to go to get there.

YS: What is the biggest mistake you think people commit while learning to program in any language?

Bjarne: I’m not sure what the biggest mistake is, but the first mistake is typically writing code using the style and techniques from some previous language. Some people never get over that. Some people even try to make a virtue out of their lack of understanding, insisting that they know how best to program independently of programming languages. To use a language well, you have to learn its strengths and weaknesses, and to use it idiomatically, the way expert programmers in that language use it to its greatest effect. You can write Fortran in any language, and C, but you don’t have to, and for most languages trying to avoid facilities that go beyond what is available in most languages lead to suboptimal designs, hard-to maintain, low-level, complicated application code that consumes excessive resources (time, space, bandwidth, power).

There are many candidates for the ‘biggest mistake’ title, but maybe not adopting a colloquial style of a language and using a mostly language-independent, low-level, style of code (emulating ‘foreign’ programming styles) could be it. To use any programming language well, you need an understanding of its fundamentals and its ‘native’ techniques.

YS: What are your thoughts about competitive programming? is it really important to learn one language in depth or learn multiple languages at a basic level to be able to write error free applications?

Bjarne: To be a professional, you need to learn to use several languages idiomatically. Knowing just one language is limiting and a shallow understanding of several languages make you write unnecessarily complicated code in every one of those.

YS: What are the three key lessons you would like to share with programmers in their early twenties who are just starting up?

Bjarne: Why three? Well, OK:

Learn several programming language well.

Learn to communicate well, verbally and in writing.

Develop and maintain interests outside software development. Programming is a way of expressing idea, but unless you have an understanding of an application area you won’t have the insights to make contributions to any application area.

In addition to your computer science basics (such as machine architecture, data structures, and algorithms), you should spend significant time on some non-computer topic (mathematics, physics, biology, history, architecture or literature), and learn to speak and write effectively.

We wish Bjarne a great future.

Aditya Bhushan Dwivedi

Aditya Bhushan Dwivedi

Latest Posts