We define abstraction as selective ignorance.


My Talk with Dr.Stroustrup

Question_4: What is "library"?


Takashi Toyota asked:
You say that language design is library design and that library design is language design at the same time. I agree with you. This recognition is, however, well beyond C++ students' desire. I mean they want to just use C++ for their purpose at each moment. They do not want to study C++ for any other purpose. They want to do simple calculations only. Those people need no advanced abstractions like exception handling and namespace.

May I have your comment on those C++ potential users? They do not want to become a C++ language expert. How do you explain "library"? Its value. Its meaning. And its role in software history.

Reference:
Experts and Novices
C++ has drifted towards becoming an "expert friendly" language. In a gathering (in person or on the Web) of experts, it is hard to build a consensus (or even interest) for something that "just" helps novices. The general opinion (in such a gathering) is typically that the best we can do for novices is to help them become experts. But it takes time to become an expert and most people need to be reasonably productive during the time it takes. More interesting, many C++ novices have no wish or need to become experts in C++. If you are a physicist needing to do a few calculations a week, an expert in some business processes involving software, or a student learning to program, you want to learn only as many language facilities as you need to get your job done. You don't want to become a language expert - you want to be (or become) an expert in your own field and know just enough of some programming language to get your work done. When supported by suitable libraries, C++ can be used like that - it is widely used like that. However, there are traps, pitfalls, and educational approaches that make such "occasional use" of C++ unnecessarily difficult. With a modest effort, C++0x can do much better in this area.

Dr.Stroustrup answered:
I suspect that you are too pessimistic in your estimate of students' patience and diligence. You are obviously correct in many cases, but here are also many who display a greater degree of professionalism and who know full well that it takes time and effort to become a successful programmer, designer, developer, whatever you care to call it. In fact, it seems to me that from your questions and quotes you must yourself be a counter example to your negative picture - and you are not alone!

There is of course always a shortage of good programmers, especially of programmers who can take the lead in development and help create the infrastructure for an application or a set of applications. I'm sure of that because there is hardly a week where I don't get several request for help finding good programmers. The C++ world is not well organized to make it easy for people to find information and get in touch.

Some people consider "a library" to be something complicate and almost magical. I see a library as nothing but a set of facilities constructed to be the base for an application or a set of applications. It is nothing but a set of user-defined types and functions representing the ideas/concepts of an application area in code.

"Language design is library design and library design is language design" is an old Bell Labs "proverb" that I helped formulate and popularize. The "library design is language design" is the part that is relevant to most programmers. Basically, nothing is easy in the bare language without libraries (for any language, not just for C++), so how do we get to work in a "better language"? We do that by designing libraries that bring our language plus available libraries closer to our ideal language for an application. I rarely attempt an application without building some support/foundation library as part of the early development. Such libraries are often simple - just a few hundred or a few thousand lines of code - and typically build on existing libraries, such as the STL. For example, I needed to do some simple engineering calculations with some students. To simplify that, I built a very basic N-dimensional Matrix library so that we did not have to work directly with the rather primitive built-in multidimensional arrays. In particular, I provided proper N-dimensional subscripting, copy operations, and had the Matrix class keep track or element allocations, the number of elements in each dimension, etc. This is not rocket science and a good set of operations can be found in any freshman linear algebra textbook. However, the result of using this simple library is the absence of the usual nasty overflow and memory management errors and significantly shorter and more readable code.

The "language design is library design" part of the proverb refer to the fact that by defining the built-in language features you determine what libraries can be built without heroic efforts ad how their facilities can be presented to users. Much of the effort in the design of C++ went into finding ways of supporting general, flexible, and efficient libraries. This is also true for the development of the next ISO C++ standard ("C++0x"). For example, see my ACM HOPL-iii paper: Evolving a language in and for the real world: C++ 1991-2006. It's a massive paper that describes the development and use of C++ over the last 15 years.

I think C++ made a major contribution to software history by demonstrating that object-oriented programming can be used by real programmers (not just PhDs from top research universities), for real-world projects (fitting into real-world development and execution environments), and performing on par with the best alternatives (often C or assembler). Before C++, most people considered OOP to be just an expensive toy for ivory tower researchers (obviously, they were wrong about that). C++'s contribution didn't stop there. From the start, I emphasized that C++ was not just a language for OOP and over the last decade C++ has led a drive to make generic programming used and accepted in industrial programming. The STL has been essential in that effort. I expect that when we look back in a few years' time, we will seen that C++ did for generic programming what it earlier did for object-oriented programming.

I use the phrase "expert-friendly" to caution people about getting too enamored with complicated language features and techniques. I don't mind C++ being expert-friendly; obviously, we want it to be very friendly to experts. However it must not be just expert-friendly; it must also be supportive of novices, and I think that not enough effort has been expended at that. Sometimes experts are not as understanding of novices as I think they ought to be. C++0x will be a help here, but not quite as much help as I had hoped for.


Previous | Contents



Our approach is possible only because C++, and our understanding of it, has had time to mature.


Copyright©Takashi Toyota 2004- 2008
Today is 2008-07-07.