Bjarne Stroustrup on the Indispensable Value of Learning Multiple Programming Languages and C++ Abstraction
Summary
The core argument presented by Bjarne Stroustrup is the critical importance for professional programmers to learn multiple programming languages, not just one. He emphasizes that this broadens one's perspective, akin to how learning a foreign natural language and culture enhances one's thinking and makes one a better person. Stroustrup updates his recommended list beyond the initial C++, Java, Python, Ruby, and JavaScript, suggesting a more foundational approach that includes machine code, C++, a functional language (like Haskell, OCaml, or ML), and a scripting language (Python, JavaScript, or Ruby). The key takeaway is that the number of languages known should "not be one," with the second language being the most impactful for expanding one's programming paradigm and design capabilities.
Stroustrup delves into the specific benefits derived from each type of language. Understanding machine code and machine architecture is deemed essential, even today, for appreciating how optimizers work and for achieving high performance by avoiding cache misses or other low-level inefficiencies. He highlights that modern optimization often involves expressing ideas so cleanly with high-level abstractions that the compiler's optimizer can generate superior machine code, sometimes even outperforming manually "clever" low-level code. C++ is presented as a prime example of a language providing the necessary abstraction mechanisms to write compact, high-performance code that can be effectively optimized.
The discussion further elaborates on the power of abstraction through an example of Jason Turner's CPPCon keynote, where C++ code for Pong on a Motorola 6800 microcontroller, viewed through Compiler Explorer, demonstrated how increasing abstraction levels led to cleaner, more maintainable, and ultimately smaller and faster assembly code. This illustrates that well-designed high-level code, when processed by sophisticated compilers, can yield better machine code than direct low-level attempts. Functional languages are recommended for teaching clear expression, especially for mathematical concepts, and for their strict type systems, while scripting languages are valued for rapid prototyping and quick development.
The broader implications underscore the continuous evolution of programming paradigms and tools. The ability of modern compilers and optimizers to translate high-level, abstract code into highly efficient machine instructions challenges the traditional notion that low-level coding is always superior for performance. Stroustrup's perspective advocates for a holistic understanding of computing, from the bare metal to sophisticated abstractions, enabling programmers to leverage the strengths of different languages and tools to solve complex problems efficiently and elegantly. This multi-lingual approach fosters adaptability and a deeper appreciation for the underlying mechanisms of computation.
Key Quotes
"the important thing that the number is not one"
"if you're mono clot you are likely to think that your own cultures the only ones pair is everybody else's"
"with programming languages you become a better programmer better designer with the second language"
"it's actually good to know machine code movie very still sorry even today"
"you mess up the cache and you're off in performance by a factor of 100"
"my favourite way of optimizing these days is to throw out the clever bits and see if it's dawn runs fast and sometimes it runs faster"
"I need the abstraction mechanisms or something like C++ to write compact high-performance code"
"his code gets better the code the assembler gets Kamala he increases the abstraction level uses C++ 11 as it were better this code gets clean that get easier maintain the code shrinks and it keeps shrinking"
Concepts
Themes
- The value of polyglot programming
- Abstraction vs. low-level control
- Compiler intelligence and optimization
- Evolution of programming languages
- The interplay of human thought and language design
- Performance engineering
- Software maintainability and readability
Related to:
Technology Insights
Programming Languages Discussed
- C++
- Java
- Python
- Ruby
- JavaScript
- Machine Code
- C
- Haskell
- OCaml
- ML
Key Figures Mentioned
- Bjarne Stroustrup
- Jason Turner
Technical Tools Mentioned
- Compiler Explorer
Hardware Architectures Mentioned
- Motorola 6800
- 86 assembler
Optimization Strategies
- Throwing out clever bits
- Leveraging compiler abstraction
- Understanding cache performance