programmertospecifyactionstobeexecutedbythemachine,anditprovidesasetof
conceptsfortheprogrammertousewhenthinkingaboutwhatcanbedone.Thefirst
purposeideallyrequiresalanguagethatis‘‘closetothemachine’’sothatallimportant
aspectsofamachinearehandledsimplyandefficientlyinawaythatisreasonably
obvioustotheprogrammer.TheClanguagewasprimarilydesignedwiththisinmind.The
secondpurposeideallyrequiresalanguagethatis‘‘closetotheproblemtobesolved’’so
thattheconceptsofasolutioncanbeexpresseddirectlyandconcisely.Thefacilitiesadded
toCtocreateC++,suchasfunctionargumentchecking,const,classes,constructorsand
destructors,exceptions,andtemplates,wereprimarilydesignedwiththisinmind.Thus,
C++isbasedontheideaofprovidingboth
•directmappingsofbuilt-inoperationsandtypestohardwaretoprovideefficient
memoryuseandefficientlow-leveloperations,and
•affordableandflexibleabstractionmechanismstoprovideuser-definedtypeswiththe
samenotationalsupport,rangeofuses,andperformanceasbuilt-intypes.
ThiswasinitiallyachievedbyapplyingideasfromSimulatoC.Overtheyears,further
applicationofthesesimpleidealsresultedinafarmoregeneral,efficient,andflexibleset
offacilities.Theresultsupportsasynthesisofprogrammingstylesthatcanbe
simultaneouslyefficientandelegant.
ThedesignofC++hasfocusedonprogrammingtechniquesdealingwithfundamental
notionssuchasmemory,mutability,abstraction,resourcemanagement,expressionof
algorithms,errorhandling,andmodularity.Thosearethemostimportantconcernsofa
systemsprogrammerandmoregenerallyofprogrammersofresource-constrainedand
high-performancesystems.
Bydefininglibrariesofclasses,classhierarchies,andtemplates,youcanwriteC++
programsatamuchhigherlevelthantheonepresentedinthisbook.Forexample,C++is
widelyusedinfinancialsystems,forgamedevelopment,andforscientificcomputation
(§1.4.5).Forhigh-levelapplicationsprogrammingtobeeffectiveandconvenient,weneed
libraries.Usingjustthebarelanguagefeaturesmakesalmostallprogrammingquite
painful.That’strueforeverygeneral-purposelanguage.Conversely,givensuitable
librariesjustaboutanyprogrammingtaskcanbepleasant.
MystandardintroductionofC++usedtostart:
•C++isageneral-purposeprogramminglanguagewithabiastowardsystems
programming.Thisisstilltrue.Whathaschangedovertheyearsisanincreaseinthe
importance,power,andflexibilityofC++’sabstractionmechanisms:
•C++isageneral-purposeprogramminglanguageprovidingadirectandefficientmodel
ofhardwarecombinedwithfacilitiesfordefininglightweightabstractions.
Orterser:
•C++isalanguagefordevelopingandusingelegantandefficientabstractions.By
general-purposeprogramminglanguageImeanalanguagedesignedtosupportawide
varietyofuses.C++hasindeedbeenusedforanincrediblevarietyofuses(from
microcontrollerstohugedistributedcommercialapplications),butthekeypointisthat
C++isnotdeliberatelyspecializedforanygivenapplicationarea.Nolanguageisidealfor
everyapplicationandeveryprogrammer,buttheidealforC++istosupportthewidest
possiblerangeofapplicationareaswell.BysystemsprogrammingImeanwritingcode
thatdirectlyuseshardwareresources,hasserious
resourceconstraints,orcloselyinteractswithcodethatdoes.Inparticular,the