most difficult to understand and technical sectionof the paper, but it is fundamental to theunderstanding of the weaknesses of C++.The C++ programming language is becomingwidely used. So it is important and timely toquestion its success. Two books are alreadypublished on the subject [Sakkinen 92] and[Yoshida 92]. This critique addresses thefollowing questions. How well does C++implement object-oriented concepts? Can it easilyimplement small, quick projects? Does it scale upwell for large projects? Does it support or hindergood programming practices? As a result, does itease the production of quality software? What isthe relationship between a language, compiler andsoftware developers; and between the language,compiler and the target system? This last questionaddresses issues of correctness, compatibility,portability, and efficiency.Having said that, I hope that you find thiscritique useful, and enjoyable. If by any chanceyou do, please feel free to distribute it to yourmanagement, peers and friends.
2. The Role of a ProgrammingLanguage
A programming language functions at manydifferent levels and has many roles. It should becritiqued with respect to those levels and roles.Historically, programming languages had a verylimited role, that of writing executable programs.As programs have grown in complexity, this rolealone has proved insufficient. Many design andanalysis techniques have arisen to support othernecessary roles. The organisation of projects alsorequired tools external to the language andcompiler, like ‘make.’ Object-oriented techniqueshave arisen to help in the analysis and designphases, and object-oriented languages to supportthe implementation phase of OO. Traditional,tried and tested but failed software practices areinfiltrating the object-oriented world. Object-orientation, however, offers a better rationalapproach to software development. Thecomplementary roles of analysis, design,implementation and project organisation shouldbe better integrated in the object-oriented scheme.This results in economical software production.A paper on the recommended practices for usein C++ [Ellemtel 92] suggests “C++ is a difficultlanguage in which there may be a very fine linebetween a feature and a bug. This places a largeresponsibility upon the programmer.” Is this aresponsibility or a costly burden? The ‘fine line’is a result of poor language definition. The C++standardisation committee warns “C++ is alreadytoo large and complicated for our taste” [X3J1692].While it is true that C++ is immediatelyusable by many C programmers, and many seethis as a strength, the C base is C++’s greatestweakness. This is the engineering compromisethat C++ devotees talk about. Adoption of C++does not suddenly transform C programmers intoobject-oriented programmers. A complete changeof thinking is required, and C++ actually makesthis difficult. A critique of C++ cannot beseparated from criticism of the C base language,as it is essential for the C++ programmer to befluent in C. Many of C’s problems affect the waythat object-orientation is implemented and used inC++. This critique is not exhaustive of theweaknesses of C++, but it illustrates the practicalconsequences of these weaknesses with respect tothe timely and economic production of qualitysoftware.C++ is an interesting experiment in adaptingthe advantages of object-orientation to atraditional programming language. BjarneStroustrup is to be applauded for having theinsight to put the two technologies together. C++,however, retains the problems of the old order of software production. C++ has an advantage overC as it supports many facets of object-orientation.These can be used for limited analysis and design.The processes of analysis, design, andorganisation, however, are still largely external toC++. Thus C++ has not realised the importantadvantages of object-orientation that will indeedlead to the economic production of software.This critique criticises C++ in its own right,without comparison to other languages. Section 2considers the role of a programming language.Section 3 examines some specific aspects of C++.Section 4 examines the general role of language.Section 5 is a short comment on writing. Section6 looks specifically at C. The conclusionexamines where C++ has left us, and considers thefuture. The approach taken is to criticise specificaspects of C++ and C. Each section tries to be self contained. It is expected that not everyone willagree with all of the sections. It is probably best toapproach the paper, not by reading it entirely, butto read those sections that interest you. Onesection, however, is fundamental to the criticismof C++, that on virtual functions. This is also theA language should not only be critiqued froma technical point of view, considering its syntacticand semantic features. It should also be critiquedfrom the viewpoint of its contribution to the entiresoftware development process. It should enablecommunication between project members actingat different levels, from management, who have arequirement for the product, to testers, who musttest the result. It should also enablecommunication between project membersseparated in space and time. Often oneprogrammer is not responsible for a task over itsentire lifetime.
C++?? 2nd Edition page