Transcription of Chapter 2 Programming Languages - FTMS
1 PROG0101 Fundamentals of Programming1 PROG0101 FUNDAMENTALS OF PROGRAMMINGC hapter 2 Programming LanguagesPROG0101 Fundamentals of Programming2 Programming LanguagesTopics Definition of Program, Computer Programming , and Computer Programmer. Generations of Programming language Types of Programming LanguagePROG0101 Fundamentals of Programming3 Programming LanguagesComputer Program A program is a set of instructions following the rules of the chosen language . Without programs, computers are useless. A program is like a recipe. It contains a list of ingredients (called variables) and a list of directions (called statements) that tell the computer what to do with the variables.
2 PROG0101 Fundamentals of Programming4 Programming LanguagesProgramming language A vocabulary and set of grammatical rules (syntax) for instructing a computer to perform specific tasks. Programming Languages can be used to create computer programs. The term Programming language usually refers to high-level Languages , such as BASIC, C, C++, COBOL, FORTRAN, Ada, and Pascal. PROG0101 Fundamentals of Programming5 Programming LanguagesProgramming language Youeventuallyneedtoconvertyourprogramint omachinelanguagesothatthecomputercanunde rstandit. Therearetwowaystodothis: Compiletheprogram InterprettheprogramPROG0101 Fundamentals of Programming6 Programming LanguagesProgramming language Compileistotransformaprogramwritteninahi gh-levelprogramminglanguagefromsourcecod eintoobjectcode.
3 Thiscanbedonebyusingatoolcalledcompiler. Fundamentals of Programming7 Programming LanguagesProgramming language Interpreterisaprogramthatexecutesinstruc tionswritteninahigh-levellanguage. Aninterpreterreadsthesourcecodeoneinstru ctionorlineatatime, Fundamentals of Programming8 Programming LanguagesComputer Programming Computerprogrammingistheprocessofwriting ,testing,debugging/troubleshooting,andma intainingthesourcecodeofcomputerprograms . Thissourcecodeiswritteninaprogramminglan guagelikeC++,JAVA, Fundamentals of Programming9 Programming LanguagesComputer Programmer Aprogrammerissomeonewhowritescomputerpro gram.
4 Computerprogrammerswrite,test, Fundamentals of Programming10 Programming LanguagesWhat Skills are Required to Become a Programmer? Programming -Writingcomputerprogramsforva riouspurposes. Writing-Communicatingeffectivelywithothe rsinwritingasindicatedbytheneedsoftheaud ience. ReadingComprehension-Understandingwritte nsentencesandparagraphsinwork-relateddoc uments. Fundamentals of Programming11 Programming LanguagesWhat Skills are Required to Become a Programmer? ComputersandElectronics-Knowledgeofelect riccircuitboards,processors,chips,andcom puterhardwareandsoftware,includingapplic ationsandprogramming.
5 Mathematics-Knowledgeofnumbers,theiroper ations,andinterrelationshipsincludingari thmetic,algebra,geometry,calculus,statis tics,andtheirapplications. Fundamentals of Programming12 Programming LanguagesWhat Skills are Required to Become a Programmer? OralComprehension-Theabilitytolistentoan dunderstandinformationandideaspresentedt hroughspokenwordsandsentences. WrittenExpression-Theabilitytocommunicat einformationandideasinwritingsootherswil lunderstand. Fundamentals of Programming13 Programming LanguagesWhat Skills are Required to Become a Programmer? Fundamentals of Programming14 Programming LanguagesGenerations of Programming language Thefirstgenerationlanguages,or1GL,arelow -levellanguagesthataremachinelanguage.
6 Thesecondgenerationlanguages,or2GL,areal solow-levellanguagesthatgenerallyconsist ofassemblylanguages. Thethirdgenerationlanguages,or3GL, Fundamentals of Programming15 Programming LanguagesGenerations of Programming language Thefourthgenerationlanguages,or4GL, The fifth generation Languages , or 5GL, are Programming Languages that contain visual tools to help develop a program. A good example of a fifth generation language is Visual Fundamentals of Programming16 Programming LanguagesTypes of Programming language Therearethreetypesofprogramminglanguage: Machinelanguage(Low-levellanguage) Assemblylanguage(Low-levellanguage) High-levellanguage Low-levellanguagesareclosertothelanguage usedbyacomputer, Fundamentals of Programming17 Programming LanguagesMachine language Machinelanguageisacollectionofbinarydigi tsorbitsthatthecomputerreadsandinterpret s.
7 Machinelanguagesaretheonlylanguagesunder stoodbycomputers. Whileeasilyunderstoodbycomputers, Fundamentals of Programming18 Programming LanguagesMachine LanguageMachine Language169 1 160 0 153 0 128 153 0 129 153 130 153 0 131 200 208 241 96 High level language5 FOR I=1 TO 1000: PRINT "A";: NEXT IPROG0101 Fundamentals of Programming19 Programming LanguagesMachine LanguageExample: Letussaythatanelectrictoothbrushhasaproc essorandmainmemory. Theprocessorcanrotatethebristlesleftandr ight,andcanchecktheon/offswitch. Themachineinstructionsareonebytelong,and correspondtothefollowingmachineoperation s.
8 PROG0101 Fundamentals of Programming20 Programming LanguagesMachine LanguageMachine InstructionMachine Operation0000 0000 Stop0000 0001 Rotate bristles left0000 0010 Rotate bristles right0000 0100 Gobacktostartofprogram0000 1000 SkipnextinstructionifswitchisoffPROG0101 Fundamentals of Programming21 Programming LanguagesAssembly language A program written in assembly language consists of a series of instructions mnemonics that correspond to a stream of executable instructions, when translated by an assembler, that can be loaded into memory and executed. Assembly Languages use keywords and symbols, much like English, to form a Programming language but at the same time introduce a new problem.
9 PROG0101 Fundamentals of Programming22 Programming LanguagesAssembly language The problem is that the computer doesn't understand the assembly code, so we need a way to convert it to machine code, which the computer does understand. Assembly language programs are translated into machine language by a program called an assembler. PROG0101 Fundamentals of Programming23 Programming LanguagesAssembly language Example: Machine language :10110000 01100001 Assembly language :mov a1, #061h Meaning:Move the hexadecimal value 61 (97 decimal) into the processor register named "a1".
10 PROG0101 Fundamentals of Programming24 Programming LanguagesHigh Level language High-levellanguages allow us to write computer code using instructions resembling everyday spoken language (for example: print, if, while) which are then translatedinto machine language to be executed. Programs written in a high-levellanguage need to be translated into machine languagebefore they can be executed. Some Programming Languages use a compilerto perform this translation and others use an Fundamentals of Programming25 Programming LanguagesHigh-Level language Examples of High-level language : ADA C C++ JAVA BASIC COBOL PASCAL PHYTONPROG0101 Fundamentals of Programming26 Programming LanguagesComparissonMachine LanguageAssembly LanguageHigh-level LanguagesTime to executeSince it is the basic language of the computer, it does not require any translation, and hence ensures better machine efficiency.