A Critique of C++ and Programming and Language Trends of the 1990S
Total Page:16
File Type:pdf, Size:1020Kb
C++?? A Critique of C++ and Programming and Language Trends of the 1990s 3rd Edition Ian Joyner The views in this critique in no way reflect the position of my employer © Ian Joyner 1996 C++?? ii 1. INTRODUCTION .................................................................................................................................................1 2. THE ROLE OF A PROGRAMMING LANGUAGE...........................................................................................2 2.1 PROGRAMMING ..................................................................................................................................................3 2.2 COMMUNICATION, ABSTRACTION AND PRECISION.................................................................................................4 2.3 NOTATION .........................................................................................................................................................5 2.4 TOOL INTEGRATION............................................................................................................................................5 2.5 CORRECTNESS....................................................................................................................................................5 2.6 TYPES ................................................................................................................................................................7 2.7 REDUNDANCY AND CHECKING ............................................................................................................................7 2.8 ENCAPSULATION ................................................................................................................................................8 2.9 SAFETY AND COURTESY CONCERNS ....................................................................................................................8 2.10 IMPLEMENTATION AND DEPLOYMENT CONCERNS...............................................................................................9 2.11 CONCLUDING REMARKS ....................................................................................................................................9 3. C++ SPECIFIC CRITICISMS ..............................................................................................................................9 3.1 VIRTUAL FUNCTIONS ..........................................................................................................................................9 3.2 GLOBAL ANALYSIS ...........................................................................................................................................12 3.3 TYPE-SAFE LINKAGE .........................................................................................................................................13 3.4 FUNCTION OVERLOADING .................................................................................................................................14 3.5 THE NATURE OF INHERITANCE ..........................................................................................................................15 3.6 MULTIPLE INHERITANCE ...................................................................................................................................16 3.7 VIRTUAL CLASSES ............................................................................................................................................17 3.8 TEMPLATES ......................................................................................................................................................17 3.9 NAME OVERLOADING .......................................................................................................................................19 3.10 NESTED CLASSES............................................................................................................................................21 3.11 GLOBAL ENVIRONMENTS ................................................................................................................................22 3.12 POLYMORPHISM AND INHERITANCE .................................................................................................................23 3.13 TYPE CASTS ...................................................................................................................................................23 3.14 RTTI AND TYPE CASTS ...................................................................................................................................24 3.15 NEW TYPE CASTS ...........................................................................................................................................25 3.16 JAVA AND CASTS ............................................................................................................................................26 3.17 ‘.’ AND ‘->’...................................................................................................................................................26 3.18 ANONYMOUS PARAMETERS IN CLASS DEFINITIONS ...........................................................................................27 3.19 NAMELESS CONSTRUCTORS.............................................................................................................................27 3.20 CONSTRUCTORS AND TEMPORARIES ................................................................................................................27 3.21 OPTIONAL PARAMETERS .................................................................................................................................28 3.22 BAD DELETIONS .............................................................................................................................................28 3.23 LOCAL ENTITY DECLARATIONS ........................................................................................................................28 3.24 MEMBERS ......................................................................................................................................................29 3.25 INLINES..........................................................................................................................................................29 3.26 FRIENDS.........................................................................................................................................................30 3.27 CONTROLLED EXPORTS VS FRIENDS .................................................................................................................30 3.28 STATIC...........................................................................................................................................................31 3.29 UNION............................................................................................................................................................32 3.30 STRUCTS ........................................................................................................................................................32 3.31 TYPEDEFS ......................................................................................................................................................32 3.32 NAMESPACES..................................................................................................................................................32 3.33 HEADER FILES ................................................................................................................................................33 3.34 CLASS INTERFACES.........................................................................................................................................34 3.35 CLASS HEADER DECLARATIONS.......................................................................................................................34 3.36 GARBAGE COLLECTION...................................................................................................................................34 3.37 LOW LEVEL CODING........................................................................................................................................35 3.38 SIGNATURE VARIANCE....................................................................................................................................35 3.39 PURE VIRTUAL FUNCTIONS .............................................................................................................................36 3.40 PROGRAMMING BY CONTRACT ........................................................................................................................36 3.41 C++ AND THE SOFTWARE LIFECYCLE ...............................................................................................................37 3.42 CASE TOOLS.................................................................................................................................................38 3.43 REUSABILITY AND COMMUNICATION ...............................................................................................................39 3.44 REUSABILITY AND TRUST................................................................................................................................39 3.45 REUSABILITY AND COMPATIBILITY..................................................................................................................40 3rd Edition © Ian Joyner 1996 C++?? iii 3.46