ComputerProgram
Thursday,October30,2014
3:48PM
ComputerProgram, set of instructionsthatdirectsacomputertoperformsomeprocessingfunction
orcombinationoffunctions.Fortheinstructionstobecarriedout,acomputermustexecute a
program,thatis,thecomputerreadstheprogram,andthenfollowsthestepsencodedinthe
programinapreciseorderuntilcompletion.Aprogramcanbeexecutedmanydifferenttimes,with
eachexecutionyieldingapotentiallydifferentresultdependingupontheoptionsanddatathatthe
usergivesthecomputer.
Programs fall into twomajorclasses:applicationprogramsandoperatingsystems.Anapplication
programisonethatcarriesoutsomefunctiondirectlyforauser,suchaswordprocessingorgame
playing.Anoperatingsystemisaprogramthatmanagesthecomputerandthevariousresources
anddevicesconnectedtoit,suchasRAM(randomaccessmemory),harddrives,monitors,
keyboards,printers,andmodems,sothattheymaybeusedbyotherprograms.Examplesof
operatingsystemsareDOS,Windows95,OS/2,andUNIX.
II.
PROGRAMDEVELOPMENT
Software designers createnewprogramsbyusingspecialapplicationsprograms,oftencalled
utilityprogramsordevelopmentprograms.Aprogrammerusesanothertypeofprogramcalledatext
editortowritethenewprograminaspecialnotationcalledaprogramminglanguage.Withthetext
editor,theprogrammercreatesatextfile,whichisanorderedlistofinstructions,alsocalledthe
programsourcefile.Theindividualinstructionsthatmakeuptheprogramsourcefilearecalled
sourcecode.Atthispoint,aspecialapplicationsprogramtranslatesthesourcecodeintomachine
language,orobjectcodeaformatthattheoperatingsystemwillrecognizeasaproperprogram
andbeabletoexecute.
Three types of applicationsprogramstranslatefromsourcecodetoobjectcode:compilers,
interpreters,andassemblers.Thethreeoperatedifferentlyandondifferenttypesofprogramming
languages,buttheyservethesamepurposeoftranslatingfromaprogramminglanguageinto
machinelanguage.See;AssemblyLanguage.
A compiler translatestextfileswritteninahighlevelprogramminglanguagesuchasFortran,C,or
Pascalfromthesourcecodetotheobjectcodeallatonce.Thisdiffersfromtheapproachtakenby
interpretedlanguagessuchasBASIC,APLandLISP,inwhichaprogramistranslatedintoobjectcode
statementbystatementaseachinstructionisexecuted.Theadvantagetointerpretedlanguagesis
thattheycanbeginexecutingtheprogramimmediatelyinsteadofhavingtowaitforallofthesource
codetobecompiled.Changescanalsobemadetotheprogramfairlyquicklywithouthavingtowait
forittobecompiledagain.Thedisadvantageofinterpretedlanguagesisthattheyareslowto
execute,sincetheentireprogrammustbetranslatedoneinstructionatatime,eachtimethe
programisrun.Ontheotherhand,compiledlanguagesarecompiledonlyonceandthuscanbe
executedbythecomputermuchmorequicklythaninterpretedlanguages.Forthisreason,compiled
languagesaremorecommonandarealmostalwaysusedinprofessionalandscientificapplications.
Another type of translatoristheassembler,whichisusedforprogramsorpartsofprogramswritten
inassemblylanguage.Assemblylanguageisanotherprogramminglanguage,butitismuchmore
similartomachinelanguagethanothertypesofhighlevellanguages.Inassemblylanguage,asingle
statementcanusuallybetranslatedintoasingleinstructionofmachinelanguage.Today,assembly
languageisrarelyusedtowriteanentireprogram,butisinsteadmostoftenusedwhenthe
programmerneedstodirectlycontrolsomeaspectofthecomputersfunction.
Programs are often writtenasasetofsmallerpieces,witheachpiecerepresentingsomeaspectof
theoverallapplicationprogram.Aftereachpiecehasbeencompiledseparately,aprogramcalleda
linkercombinesallofthetranslatedpiecesintoasingleexecutableprogram.
Programs seldom work correctlythefirsttime,soaprogramcalledadebuggerisoftenusedtohelp
findproblemscalledbugs.Debuggingprogramsusuallydetectaneventintheexecutingprogram
andpointtheprogrammerbacktotheoriginoftheeventintheprogramcode.
Recent programming systems,suchasJava,useacombinationofapproachestocreateandexecute
programs.AcompilertakesaJavasourceprogramandtranslatesitintoanintermediateform.Such
intermediateprogramsarethentransferredovertheInternetintocomputerswhereaninterpreter
Program Page 1
programthenexecutestheintermediateformasanapplicationprogram.
III.
PROGRAMELEMENTS
Most programs are builtfromjustafewkindsofstepsthatarerepeatedmanytimesindifferent
contextsandindifferentcombinationsthroughouttheprogram.Themostcommonstepperforms
somecomputation,andthenproceedstothenextstepintheprogram,intheorderspecifiedbythe
programmer.
Programs often need torepeatashortseriesofstepsmanytimes,forinstanceinlookingthrougha
listofgamescoresandfindingthehighestscore.Suchrepetitivesequencesofcodearecalledloops.
One of the capabilitiesthatmakescomputerssousefulistheirabilitytomakeconditionaldecisions
andperformdifferentinstructionsbasedonthevaluesofdatabeingprocessed.Ifthenelse
statementsimplementthisfunctionbytestingsomepieceofdataandthenselectingoneoftwo
sequencesofinstructionsonthebasisoftheresult.Oneoftheinstructionsinthesealternativesmay
beagoto statementthatdirectsthecomputertoselectitsnextinstructionfromadifferentpartof
theprogram.Forexample,aprogrammightcomparetwonumbersandbranchtoadifferentpartof
theprogramdependingontheresultofthecomparison:
Ifxisgreaterthany
then
goto instruction#10
else continue
Programs often use a specificsequenceofstepsmorethanonce.Suchasequenceofstepscanbe
groupedtogetherintoasubroutine, whichcanthenbecalled,oraccessed,asneededindifferent
partsofthemainprogram.Eachtimeasubroutineiscalled,thecomputerrememberswhereitwas
intheprogramwhenthecallwasmade,sothatitcanreturnthereuponcompletionofthe
subroutine.Precedingeachcall,aprogramcanspecifythatdifferentdatabeusedbythesubroutine,
allowingaverygeneralpieceofcodetobewrittenonceandusedinmultipleways.
Most programs use severalvarietiesofsubroutines.Themostcommonofthesearefunctions,
procedures,libraryroutines,systemroutines, anddevicedrivers.Functionsareshortsubroutinesthat
computesomevalue,suchascomputationsofangles,whichthecomputercannotcomputewitha
singlebasicinstruction.Proceduresperformamorecomplexfunction,suchassortingasetof
names.Libraryroutinesaresubroutinesthatarewrittenforusebymanydifferentprograms.System
routinesaresimilartolibraryroutinesbutareactuallyfoundintheoperatingsystem.Theyprovide
someservicefortheapplicationprograms,suchasprintingalineoftext.Devicedriversaresystem
routinesthatareaddedtoanoperatingsystemtoallowthecomputertocommunicatewithanew
device,suchasascanner,modem,orprinter.Devicedriversoftenhavefeaturesthatcanbe
executeddirectlyasapplicationsprograms.Thisallowstheusertodirectlycontrolthedevice,which
isusefulif,forinstance,acolorprinterneedstoberealignedtoattainthebestprintingqualityafter
changinganinkcartridge.
IV.
PROGRAMFUNCTION
Modern computers usuallystoreprogramsonsomeformofmagneticstoragemediathatcanbe
accessedrandomlybythecomputer,suchastheharddrivediskpermanentlylocatedinthe
computer,oraportablefloppydisk.Additionalinformationonsuchdisks,calleddirectories,indicate
thenamesofthevariousprogramsonthedisk,whentheywerewrittentothedisk,andwherethe
programbeginsonthediskmedia.Whenauserdirectsthecomputertoexecuteaparticular
applicationprogram,theoperatingsystemlooksthroughthesedirectories,locatestheprogram,and
readsacopyintoRAM.TheoperatingsystemthendirectstheCPU(centralprocessingunit)tostart
executingtheinstructionsatthebeginningoftheprogram.Instructionsatthebeginningofthe
programpreparethecomputertoprocessinformationbylocatingfreememorylocationsinRAMto
holdworkingdata,retrievingcopiesofthestandardoptionsanddefaultstheuserhasindicatedfrom
adisk,anddrawinginitialdisplaysonthemonitor.
The application programrequestsacopyofanyinformationtheuserentersbymakingacalltoa
systemroutine.Theoperatingsystemconvertsanydatasoenteredintoastandardinternalform.
Theapplicationthenusesthisinformationtodecidewhattodonextforexample,performsome
desiredprocessingfunctionsuchasreformattingapageoftext,orobtainsomeadditional
informationfromanotherfileonadisk.Ineithercase,callstoothersystemroutinesareusedto
Program Page 2
actuallycarryoutthedisplayoftheresultsortheaccessingofthefilefromthedisk.
When the application reachescompletionorispromptedtoquit,itmakesfurthersystemcallsto
makesurethatalldatathatneedstobesavedhasbeenwrittenbacktodisk.Itthenmakesafinal
systemcalltotheoperatingsystemindicatingthatitisfinished.Theoperatingsystemthenfreesup
theRAMandanydevicesthattheapplicationwasusingandawaitsacommandfromtheuserto
startanotherprogram.
V.
HISTORY
People have been storingsequencesofinstructionsintheformofaprogramforseveralcenturies.
Musicboxesofthe18thcenturyandplayerpianosofthelate19thandearly20thcenturiesplayed
musicalprogramsstoredasseriesofmetalpins,orholesinpaper,witheachline(ofpinsorholes)
representingwhenanotewastobeplayed,andthepinorholeindicatingwhatnotewastobe
playedatthattime.Moreelaboratecontrolofphysicaldevicesbecamecommonintheearly1800s
withFrenchinventorJosephMarieJacquardsinventionofthepunchcardcontrolledweavingloom.
Intheprocessofweavingaparticularpattern,variouspartsoftheloomhadtobemechanically
positioned.Toautomatethisprocess,Jacquardusedasinglepapercardtorepresenteach
positioningoftheloom,withholesinthecardtoindicatewhichloomactionsshouldbedone.An
entiretapestrycouldbeencodedontoadeckofsuchcards,withthesamedeckyieldingthesame
tapestrydesigneachtimeitwasused.Programsofover24,000cardsweredevelopedandused.
The worlds first programmablemachinewasdesignedalthoughneverfullybuiltbytheEnglish
mathematicianandinventor,CharlesBabbage.Thismachine,calledtheAnalyticalEngine,used
punchcardssimilartothoseusedintheJacquardloomtoselectthespecificarithmeticoperationto
applyateachstep.Insertingadifferentsetofcardschangedthecomputationsthemachine
performed.Thismachinehadcounterpartsforalmosteverythingfoundinmoderncomputers,
althoughitwasmechanicalratherthanelectrical.ConstructionoftheAnalyticalEnginewasnever
completedbecausethetechnologyrequiredtobuilditdidnotexistatthetime.
The first card deck programsfortheAnalyticalEngineweredevelopedbyBritishmathematician
CountessAugustaAdaLovelace,daughterofthepoetLordByron.Forthisreasonsheisrecognized
astheworldsfirstprogrammer.
The modern concept ofaninternallystoredcomputerprogramwasfirstproposedbyHungarian
AmericanmathematicianJohnvonNeumannin1945.VonNeumannsideawastousethe
computersmemorytostoretheprogramaswellasthedata.Inthisway,programscanbeviewed
asdataandcanbeprocessedlikedatabyotherprograms.Thisideagreatlysimplifiestheroleof
programstorageandexecutionincomputers.
VI.
THEFUTURE
The field of computersciencehasgrownrapidlysincethe1950sduetotheincreaseintheiruse.
Computerprogramshaveundergonemanychangesduringthistimeinresponsetouserneedand
advancesintechnology.Newerideasincomputingsuchasparallelcomputing,distributed
computing,andartificialintelligence,haveradicallyalteredthetraditionalconceptsthatonce
determinedprogramformandfunction.
Computer scientists workinginthefieldofparallelcomputing,inwhichmultipleCPUscooperateon
thesameproblematthesametime,haveintroducedanumberofnewprogrammodels(seeParallel
Processing).Inparallelcomputingpartsofaproblemareworkedonsimultaneouslybydifferent
processors,andthisspeedsupthesolutionoftheproblem.Manychallengesfacescientistsand
engineerswhodesignprogramsforparallelprocessingcomputers,becauseoftheextreme
complexityofthesystemsandthedifficultyinvolvedinmakingthemoperateaseffectivelyas
possible.
Another type of parallelcomputingcalleddistributedcomputingusesCPUsfrommany
interconnectedcomputerstosolveproblems.Oftenthecomputersusedtoprocessinformationina
distributedcomputingapplicationareconnectedovertheInternet.Internetapplicationsare
becomingaparticularlyusefulformofdistributedcomputing,especiallywithprogramming
languagessuchasJava.Insuchapplications,auserlogsontoaWebsiteanddownloadsaJava
programontotheircomputer.WhentheJavaprogramisrun,itcommunicateswithotherprograms
atitshomewebsite,andmayalsocommunicatewithotherprogramsrunningondifferent
computersorwebsites.
Research into artificialintelligence(AI)hasledtoseveralothernewstylesofprogramming.Logic
programs, forexample,donotconsistofindividualinstructionsforthecomputertofollowblindly,
Program Page 3
butinsteadconsistofsetsofrules:ifxhappensthendoy.Aspecialprogramcalledaninference
engineusestheserulestoreasonitswaytoaconclusionwhenpresentedwithanewproblem.
Applicationsoflogicprogramsincludeautomaticmonitoringofcomplexsystems,andproving
mathematicaltheorems.
A radically differentapproachtocomputinginwhichthereisnoprogramintheconventionalsense
iscalledaneuralnetwork.Aneuralnetworkisagroupofhighlyinterconnectedsimpleprocessing
elements,designedtomimicthebrain.Insteadofhavingaprogramdirecttheinformation
processinginthewaythatatraditionalcomputerdoes,aneuralnetworkprocessesinformation
dependinguponthewaythatitsprocessingelementsareconnected.Programminganeuralnetwork
isaccomplishedbypresentingitwithknownpatternsofinputandoutputdataandadjustingthe
relativeimportanceoftheinterconnectionsbetweentheprocessingelementsuntilthedesired
patternmatchingisaccomplished.Neuralnetworksareusuallysimulatedontraditionalcomputers,
butunliketraditionalcomputerprograms,neuralnetworksareabletolearnfromtheirexperience.
MORESOURCES
WebLinks
FurtherReading
ALSOINENCARTA
RelatedArticles
Timeline
ContributedBy:
PeterM.Kogge
Howtocitethisarticle:
Kogge,PeterM."ComputerProgram."MicrosoftStudent2008[DVD].Redmond,WA:Microsoft
Corporation,2007.
RelatedArticles
Computer
ProgrammingLanguages
Software
seealso ComputerScience
applications
More
WebSites(1)
AinsworthComputerSeminar
Thisprivatelymaintainedsiteoffersinformationabouthowcomputerprogramswork,structured
bothforthebeginnerandforthemoreadvancedstudent.
http://www.qwerty.com/startacs.htm
FurtherReading(1)
ComputerProgrammingandProgrammingLanguages
ShowAll
VisualBrowser
TaketheTour
MicrosoftEncarta2008.19932007MicrosoftCorporation.Allrightsreserved.
Program Page 4