📄 drdobbs-interview.html
字号:
<P> I don't think that would be quite right for in-memory datastructures, but this is something that needs to be done. The sameinterfaces defined by STL need to be implemented with other datastructures---skip lists, splay trees, half-balanced trees, and soon. It's a major research activity that needs to be done becauseSTL provides us with a framework where we can compare theperformance of these structures. The interface is fixed. Thebasic complexity requirements are fixed. Now we can havemeaningful experiments comparing different data structures toeach other. There were a lot of people from the data structurecommunity coming up with all kinds of data structures for thatkind of interface. I hope that they would implement them asgeneric data structures within the STL framework.</P><P><B>Are compiler vendors working with you to implement STL into theirproducts?</B></P><P> Yes. I get a lot of calls from compiler vendors. PeteBecker of Borland was extremely helpful. He helped by writingsome code so that we could implement allocators for all thememory models of Borland compilers. Symantec is going to releasean STL implementation for their Macintosh compiler. EdisonDesign Group has been very helpful. We have had a lot of supportfrom most compiler vendors.</P><P><B>STL includes templates that support memory models of 16-bit MS-DOS compilers. With the current emphasis on 32-bit, flat modelcompilers and operating systems, do you think that the memory-model orientation will continue to be valid?</B></P><P> Irrespective of Intel architecture, memory model is anobject, which encapsulates the information about what is apointer, what are the integer size and difference typesassociated with this pointer, what is the reference typeassociated with this pointer, and so on. Abstracting that isimportant if we introduce other kinds of memory such aspersistent memory, shared memory, and so on. A nice feature ofSTL is that the only place that mentions the machine-relatedtypes in STL---something that refers to real pointer, realreference---is encapsulated within roughly 16 lines of code.Everything else, all the containers, all the algorithms, arebuilt abstractly without mentioning anything which relates to themachine. From the point of view of portability, all themachine-specific things which relate to the notion of address, pointer,and so on, are encapsulated within a tiny, well-understoodmechanism. Allocators, however, are not essential to STL, not asessential as the decomposition of fundamental data structures andalgorithms.</P><P><B>The ANSI/ISO C Standards committee treated platform-specificissues such as memory models as implementation details and didnot attempt to codify them. Will the C++ committee be taking adifferent view of these issues? If so, why?</B></P><P> I think that STL is ahead of the C++ standard from the pointof view of memory models. But there is a significant differencebetween C and C++. C++ has constructors and operator new, whichdeal with memory model and which are part of the language. Itmight be important now to look at generalizing things likeoperator new to be able to take allocators the way STL containerstake allocators. It is not as important now as it was before STLwas accepted, because STL data structures will eliminate themajority of the needs for using new. Most people should notallocate arrays because STL does an effective job in doing so. Inever need to use new in my code, and I pay great attention toefficiency. The code tends to be more efficient than if I wereto use new. With the acceptance of STL, new will sort of fadeaway. STL also solves the problem of deleting because, forexample, in the case of a vector, the destructor will destroy iton the exit from the block. You don't need to worry aboutreleasing the storage as you do when you use new. STL candramatically minimize the demand for garbage collection.Disciplined use of containers allows you to do whatever you needto do without automatic memory management. The STL constructorsand destructors do allocation properly.</P><P><B>The C++ Standard Library subcommittee is defining standardnamespaces and conventions for exception handling. Will STLclasses have namespaces and throw exceptions?</B></P><P> Yes they will. Members of the committee are dealing withthat, and they are doing a great job.</P><P><B>How different from the current STL definition will the eventualstandard definition be? Will the committee influence changes oris the design under tighter control?</B></P><P> It seems to be a consensus that there should not be anymajor changes to STL.</P><P><B>How can programmers gain an early experience with STL inanticipation of it becoming a standard?</B></P><P> They can download the STL header files from<tt>butler.hpl.hp.com</tt> under <tt>/stl</tt> and use it with Borland or IBMcompiler, or with any other compiler powerful enough to handleSTL The only way to learn some style of programming is byprogramming. They need to look at examples and write programs inthis style.</P><P><B>You are collaborating with P.J. (Bill) Plauger to write a bookabout STL. What will be the emphasis of the book and when is itscheduled to be published?</B></P><P> It is scheduled to be published in the summer of 1995 and isgoing to be an annotated STL implementation. It will be similarto Bill's books on the Standard C Library and the Draft StandardC++ Library. He is taking the lead on the book, which will serveas a standard reference document on the use of the STL. I hope towrite a paper with Bjarne that will address language/libraryinteractions in the context of C++/STL. It might lead to anotherbook.</P><P> A lot more work needs to be done. For STL to become asuccess, people should do research experimenting with this styleof programming. More books and articles need to be writtenexplaining how to program in this style. Courses need to bedeveloped. Tutorials need to be written. Tools need to be builtwhich help people navigate through libraries. STL is a frameworkand it would be nice to have a tool with which to browse throughthis framework.</P><P><B>What is the relationship between generic programming and object-oriented programming?</B></P><P> In one sense, generic programming is a natural continuationof the fundamental ideas of object-oriented programming---separating the interface and implementation and polymorphicbehavior of the components. However, there is a radicaldifference. Object-oriented programming emphasizes the syntax oflinguistic elements of the program construction. You have to useinheritance, you have to use classes, you have to use objects,objects send messages. Generic programming does not start withthe notion of whether you use inheritance or you don't useinheritance. It starts with an attempt to classify or produce ataxonomy of what kinds of things are there and how they behave.That is, what does it mean that two things are equal? What isthe right way to define equality? Not just actions of equality.You can analyze equality deeper and discover that there is ageneric notion of equality wherein two objects are equal if theirparts, or at least their essential parts are equal. We can havea generic recipe for an equality operation. We can discuss whatkinds of objects there are. There are sequences. There areoperations on sequences. What are the semantics of theseoperations? What types of sequences from the point of view ofcomplexity tradeoffs should we offer the user? What kinds ofalgorithms are there on sequences? What kind of differentsorting functions do we need? And only after we develop that,after we have the conceptual taxonomy of the components, do weaddress the issue of how to implement them. Do we use templates?Do we use inheritance? Do we use macros? What kind of languagetechnology do we use? The fundamental idea of genericprogramming is to classify abstract software components and theirbehavior and come up with a standard taxonomy. The startingpoint is with real, efficient algorithms and data structures andnot with the language. Of course, it is always embodied in thelanguage. You cannot have generic programming outside of alanguage. STL is done in C++. You could implement it in Ada.You could implement it in other languages. They would beslightly different, but there are some fundamental things thatwould be there. Binary search has to be everywhere. Sort has tobe everywhere. That's what people do. There will be somemodification on the semantics of the containers, slightmodifications imposed by the language. In some languages you canuse inheritance more, in some languages you have to usetemplates. But the fundamental difference is precisely thatgeneric programming starts with semantics and semanticdecomposition. For example, we decide that we need a componentcalled <tt>swap</tt>. Then we figure out how this particular componentwill work in different languages. The emphasis is on thesemantics and semantic classification, while object-orientedness,especially as it has evolved, places a much stronger emphasis,and, I think, too much of an emphasis, on precisely how todevelop things, that is, using class hierarchies. OOP tells youhow to build class hierarchies, but it doesn't tell you whatshould be inside those class hierarchies.</P><P><B>What do you see as the future of STL and generic programming?</B></P><P> I mentioned before the dream of programmers having standardrepositories of abstract components with interfaces that are wellunderstood and that conform to common paradigms. To do thatthere needs to be a lot more effort to develop the scientificunderpinnings of this style of programming. STL starts it tosome degree by classifying the semantics of some fundamentalcomponents. We need to work more on that. The goal is totransform software engineering from a craft to an engineeringdiscipline. It needs a taxonomy of fundamental concepts and somelaws that govern those concepts, which are well understood, whichcan be taught, which every programmer knows even if he cannotstate them correctly. Many people know arithmetic even if theynever heard of commutativity. Everybody who graduated from highschool knows that 2+5 is equal to 5+2. Not all of them know thatit is a commutative property of addition. I hope that mostprogrammers will learn the fundamental semantic properties offundamental operations. What does assignment mean? What doesequality mean? How to construct data structures.</P><P> At present C++ is the best vehicle for this style ofprogramming. I have tried different languages and I think thatC++ allows this marvelous combination of abstractness andefficiency. However, I think that it is possible to design alanguage based on C and on many of the insights that C++ broughtinto the world, a language which is more suitable to this styleof programming, which lacks some of the deficiencies of C++, inparticular its enormous size. STL deals with things calledconcepts. What is an iterator? Not a class. Not a type. It isa concept. (Or, if we want to be more formal, it is what Bourbakicalls a structure type, what logicians call a theory, or whattype theory people call a sort.) It is something which doesn'thave a linguistic incarnation in C++. But it could. You couldhave a language where you could talk about concepts, refine them,and then finally form them in a very programmatic kind of wayinto classes. (There are, of course, languages that deal withsorts, but they are not of much use if you want to sort.) Wecould have a language where we could define something calledforward iterator, which is just defined as a concept in STL---itdoesn't have a C++ incarnation. Then we can refine forwarditerator into bidirectional iterator. Then random iterator canbe refined from that. It is possible to design a language whichwould enable even far greater ease for this style of programming.I am fully convinced that it has to be as efficient and as closeto the machine as are C and C++. And I do believe that it ispossible to construct a language that allows close approximationto the machine on the one hand and has the ability to deal withvery abstract entities on the other hand. I think thatabstractness can be even greater than it is in C++ withoutcreating a gap between underlying machines. I think that genericprogramming can influence language research and that we will havepractical languages, which are easy to use and are well suitedfor that style of programming. From that you can deduce what Iam planning to work on next.</P><Address>Copyright © 1995 <A href="http://www.ddj.com">Dr. Dobb's Journal</A></Address><!--start footer--> <HR SIZE="6"><A href="http://www.sgi.com/"><IMG SRC="surf.gif" HEIGHT="54" WIDTH="54" ALT="[Silicon Surf]"></A><A HREF="index.html"><IMG SRC="stl_home.gif" HEIGHT="54" WIDTH="54" ALT="[STL Home]"></A><BR><FONT SIZE="-2"><A href="http://www.sgi.com/Misc/sgi_info.html" TARGET="_top">Copyright © 1996 Silicon Graphics, Inc.</A> All Rights Reserved.</FONT><FONT SIZE="-3"><a href="http://www.sgi.com/Misc/external.list.html" TARGET="_top">TrademarkInformation</A></FONT><P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -