Questions for Bjarne Stroustrup
Total Page:16
File Type:pdf, Size:1020Kb
December 1, 2006 QUESTIONS FOR BJARNE STROUSTRUP (from Jason Pontin from MIT Technical Review): Q: Why is most software so bad? Or, if you prefer: Why is software not better than it is? Or, even: Why isn’t software as good as it needs to be? Hmm, some software is actually pretty good by any standards – think of the mars rovers, Google, and the human genome project. That’s quality software! (admittedly supported by some quite impressive hardware). Most people – especially experts – would have deemed each of those examples impossible fifteen years ago. Our technological civilization critically depends on software, so if software had been as bad as its reputation, most of us would have been dead by now. On the other hand, looking at “average” pieces of code can make me cry. The structure is appalling, the programmers clearly didn’t think deeply about correctness, algorithms, data structures, and maintainability. However, most people don’t actually read code, they just see IE “freeze”, have their cell-phone drop a call, read the latest newspaper story about viruses, and shudder. The only thing that seems to grow faster than hardware performance is human expectation. Hardware simply cannot keep up, and more and more tasks are pushed into software. At the same time, humans delegate more and more work to computers. The result is a serious overload of individuals and organizations producing software. I think that the real problem is that “we” (that is, the software developers) are in permanent emergency mode and grasping for straws to get our work done. We perform many minor miracles through trial and error, excessive use of brute force, and lots and lost of testing, but – oh, so often – it’s not enough. “We” have become adept at the difficult art of building reasonably reliable systems out of unreliable parts. The snag is that sometimes “reasonably reliable” isn’t good enough and often we do not know exactly how we did it – a system just “sort of evolved” into something minimally acceptable. Personally, I prefer to know when a system will work, and why it will. Q: How can we fix the mess we are in? In theory, the answer is simple: educate our software developers better, use more appropriate design methods, and design for flexibility and for the long haul. Reward correct, solid, and safe systems. Punish sloppiness. In reality, that’s essentially impossible. People want new fancy gadgets right now and reward people who deliver them cheaply, buggy, and first. People don’t want inconvenience, don’t want to learn new ways of interacting with their computers, don’t want delays in delivery, and don’t want to pay extra for quality (unless it’s obvious up front – and often not even then). Even major security problems and crashes seem not to make people willing to change their use of software – and without changes in user behavior, the software suppliers are unlikely to change. Realistically, we need to heed both “theory” and real-world constraints. We can’t just stop to world for a decade while we re-program everything from our coffee machines to our financial systems. For starters, imagine we did that (and managed not to regress into the Stone Age in the meantime), how would we know that our newly designed and built systems would be better than our current mess? On the other hand, just muddling along is expensive, dangerous, and depressing. Significant improvements are needed and they can only come gradually. They must come on a broad front; no individual change is sufficient. One problem is that “academic smokestacks” get in the way: too many people push some area as a panacea. Better design methods can help, better specification techniques can help, better programming languages can help, better testing technologies can help, better operating systems can help, better middle-ware infrastructures can help, better understanding of application domains can help, better understanding of data structures and algorithms can help, etc. For example, type theory, model-based development, and formal methods can undoubtedly provide significant help in some areas, but pushed as the solution to the exclusion of other approaches, each guarantees failure in large-scale projects. People push what they know and what they have seen work – how could they do otherwise? – but few have the overview and technical maturity to balance the demands and the resources. Worse, reward structures often encourage narrow-view approaches. It may be useful to point out that I don’t exclude my own fields of work from this: no programming language is or could be a panacea, not even C++. So, looking at my own narrow field, what can we do better? First, there seem to be two dominant schools of thought: “the choice of language doesn’t matter” and “choosing the right language will solve your problem”. Both are throwing away something essential. My view is that a good language can be a major asset, but only when used appropriately and well. A language doesn’t solve problems; it merely helps the expression of solutions. Object-oriented programming – as pioneered by Simula – can be a major asset. My favorite variant of OO combines it with a serious amount of static (compile-time) type- checking for a more explicit design, earlier error detection, and better performance. In addition, I’m a great fan of generic programming, especially in the areas of data structures and algorithms where GP’s more regular approach to design shines. Combining the two can lead to really beautiful, understandable, and efficient code. However, all the bright ideas in the world won’t help us if software development is dominated by half-educated amateurs. We must improve computer science education and its related fields, and attract more and better students. Only then can we improve the practice of software development, and that only if enough academic efforts stay close enough to practical problems to remain helpful. Q: C++ was designed for engineers at Bell who were creating code to run on ESS machines. Your idea was that programmers would work harder in return for more efficient code. Bell needed a language that a few people would use to write code that would run all over the world, and computers weren't very fast. Today, the reverse is the case, of course. Does that diminish C++’s usefulness? Actually, C++ wasn’t designed specifically for the large switching machines, but for a huge range of applications. Bell Labs was the home of an incredible range of interesting project spanning every scale and using essentially every kind of computer and operating system. But yes, the average Bell Labs programmer was significantly more able than most people’s notion of an “average programmer,” and reliability and performance (in that order) were considered significantly more important than in most other places. Also, performance is still an issue in many of the applications that I’m interested in: responsiveness of interfaces (why do I see character echo delays in Word on my 2GHz, 2Gb computer? I didn’t see that on my editor on a shared 1MHz, 1Mb PDP11 25 years ago), startup and close down time of applications, throughput of servers, hard-real time response of “gadgets”, scientific computations, etc. “We” have neutralized the astounding performance of modern computer hardware by adding layer upon layer of over-elaborate (software) abstractions. We seem to have hit the limits of linear speedup for hardware, but in many cases, we could win a couple of orders of magnitude back from the software. That said, C++ has indeed become too expert friendly at a time where the degree of effective formal education of the average software developer has declined. However, the solution is not to dumb down the programming languages but to use a variety of programming languages and educate more experts. There has to be languages for those experts to use – and C++ is one of those languages. Q: Put another way: Is C++ too hard for most programmers? It shouldn’t be. C++ has become “expert friendly,” partly by design and partly because the notion of professionalism hasn’t taken root in the software development world. The best uses of C++ involve deliberate design. You design classes to represent the notions of your application, you organize those classes into hierarchies, you express your algorithms precisely and abstractly (no, that “and” is not a mistake), you use libraries, you build libraries, you devise error handling and resource management strategies and express them in code. The result can be beautiful, efficient, maintainable, etc. However, it’s not just sitting down and writing a series of statements directly manipulating characters, integers, and floating point numbers. Nor is it simply plugging a few pieces of code into a huge corporate framework. The demands of using C++ well are mainly maturity of system designers and understanding of design and programming technique. They are not primarily demands on the understanding of obscure programming language features. In that sense, the critics are right: Not everybody should write C++, but then I never did claim they should. I do not know if too many people use C++ today, but many do, many more than in the mid-90s, and the use of C++ is still growing in some areas. Obviously, C++ wasn’t too difficult for quite a few people. C++ is designed to allow you to express ideas, but if you don’t have ideas or don’t have any clue about how to express them, C++ doesn’t offer much help. In that, C++ is not that different from other languages, but it is different from languages/systems/tools/frameworks designed to make it easy to express specific things in a specific domain.