Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 1/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 2/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 3/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 4/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 5/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 6/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 7/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 8/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 9/59Chapte...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 10/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 11/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 12/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 13/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 14/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 15/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 16/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 17/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 18/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 19/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 20/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 21/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 22/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 23/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 24/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 25/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 26/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 27/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 28/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 29/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 30/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 31/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 32/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 33/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 34/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 35/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 36/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 37/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 38/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 39/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 40/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 41/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 42/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 43/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 44/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 45/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 46/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 47/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 48/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 49/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 50/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 51/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 52/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 53/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 54/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 55/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 56/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 57/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 58/59Chapt...
Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 59/59Chapt...
Upcoming SlideShare
Loading in …5
×

Chapter 02 Computer Languages (re-upload)

599 views
507 views

Published on

re-uploaded

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
599
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Chapter 02 Computer Languages (re-upload)

  1. 1. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 1/59Chapter 12: Computer LanguagesRef Page
  2. 2. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 2/59Chapter 12: Computer LanguagesRef PageIn this chapter you will learn about:§ Computer languages or programming languages§ Three broad categories of programming languages –machine, assembly, and high-level languages§ Commonly used programming language tools such asassembler, compiler, linker, and interpreter§ Concepts of object-oriented programming languages§ Some popular programming languages such asFORTRAN, COBOL, BASIC, Pascal, C, C++, C#, Java,RPG, LISP and SNOBOL§ Related concepts such as Subprogram, Characteristics ofa good programming language, and factors to considerwhile selecting a language for coding an applicationLearning ObjectivesLearning Objectives208
  3. 3. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 3/59Chapter 12: Computer LanguagesRef PageBroad Classification ofComputer LanguagesBroad Classification ofComputer Languages§ Machine language§ Assembly language§ High-level language209
  4. 4. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 4/59Chapter 12: Computer LanguagesRef PageMachine LanguageMachine Language§ Only language of a computer understood by itwithout using a translation program§ Normally written as strings of binary 1s and 0s§ Written using decimal digits if the circuitry ofthe computer being used permits this209
  5. 5. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 5/59Chapter 12: Computer LanguagesRef PageA Typical Machine LanguageInstruction FormatA Typical Machine LanguageInstruction Format§ OPCODE tells the computer which operation to performfrom the instruction set of the computer§ OPERAND tells the address of the data on which theoperation is to be performedOPCODE(operation code)OPERAND(Address/Location)210
  6. 6. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 6/59Chapter 12: Computer LanguagesRef PageA Sample Machine Language ProgramA Sample Machine Language Program1000147114002041300034565077345600000000001000000000001100111001001100000000010000100001011000000000011100101110101000111111011100101110000000000000000000000000In Binary(Difficult to read and understand)In Decimal(Easier to read and understand)210
  7. 7. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 7/59Chapter 12: Computer LanguagesRef PageAdvantages & Limitations ofMachine LanguageAdvantages & Limitations ofMachine LanguageAdvantage§ Can be executed very fastLimitations§ Machine Dependent§ Difficult to program§ Error prone§ Difficult to modify210
  8. 8. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 8/59Chapter 12: Computer LanguagesRef PageAssembly/Symbolic LanguageAssembly/Symbolic Language§ Using alphanumeric mnemonic codes instead of numeric codes forthe instructions in the instruction sete.g. using ADD instead of 1110 (binary) or 14 (decimal) forinstruction to add§ Allowing storage locations to be represented in form of alphanumericaddresses instead of numeric addressese.g. representing memory locations 1000, 1001, and 1002 as FRST,SCND, and ANSR respectively§ Providing pseudo-instructions that are used for instructing thesystem how we want the program to be assembled inside thecomputer’s memorye.g. START PROGRAM AT 0000; SET ASIDE AN ADRESS FOR FRSTProgramming language that overcomes the limitations of machinelanguage programming by:211
  9. 9. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 9/59Chapter 12: Computer LanguagesRef PageAssemblerAssembler§ Software that translates as assembly languageprogram into an equivalent machine language programof a computerOne-to-one correspondence(Source Program) (Object Program)AssemblerAssemblylanguageprogramMachinelanguageprogramInput Output212
  10. 10. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 10/59Chapter 12: Computer LanguagesRef PageA subset of the set of instructions supported by a computerHalt, used at the end of program to stopClear and add into A registerAdd to the contents of A registerSubtract from the contents of A registerStore A register0010141530HLTCLAADDSUBSTAMeaningOpcodeMnemonicAn Example of AssemblyLanguage ProgramAn Example of AssemblyLanguage Program213
  11. 11. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 11/59Chapter 12: Computer LanguagesRef PageSTART PROGRAM AT 0000START DATA AT 1000SET ASIDE AN ADDRESS FOR FRSTSET ASIDE AN ADDRESS FOR SCNDSET ASIDE AN ADDRESS FOR ANSRCLA FRSTADD SCNDSTA ANSRHLTSample assembly language program for adding two numbers andstoring the resultAn Example of AssemblyLanguage ProgramAn Example of AssemblyLanguage Program213
  12. 12. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 12/59Chapter 12: Computer LanguagesRef Page100010011002FRSTSCNDANSRMemory locationSymbolic nameMapping table set up by the assembler for the data itemsof the assembly language programAn Example of AssemblyLanguage ProgramAn Example of AssemblyLanguage Program213
  13. 13. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 13/59Chapter 12: Computer LanguagesRef PageAn Example of AssemblyLanguage ProgramAn Example of AssemblyLanguage ProgramEquivalent machine language program for the assembly language programAddressOpcode100010011002Clear and add the number stored at FRST to A registerAdd the number stored at SCND to the contents of AregisterStore the contents of A register into ANSRHaltReserved for FRSTReserved for SCNDReserved for ANSR101430000000000100020003---100010011002CommentsContentsMemorylocation214
  14. 14. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 14/59Chapter 12: Computer LanguagesRef PageAdvantages of Assembly LanguageOver Machine LanguageAdvantages of Assembly LanguageOver Machine Language§ Easier to understand and use§ Easier to locate and correct errors§ Easier to modify§ No worry about addresses§ Easily relocatable§ Efficiency of machine language214
  15. 15. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 15/59Chapter 12: Computer LanguagesRef PageLimitations of Assembly LanguageLimitations of Assembly Language§ Machine dependent§ Knowledge of hardware required§ Machine level coding215
  16. 16. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 16/59Chapter 12: Computer LanguagesRef Page§ Mainly used today to fine-tune important parts ofprograms written in a high-level language to improvethe program’s execution efficiencyTypical Uses of Assembly LanguageTypical Uses of Assembly Language215
  17. 17. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 17/59Chapter 12: Computer LanguagesRef PageAssembly Languages withMacro InstructionsAssembly Languages withMacro Instructions§ Any assembly language instruction that gets translatedinto several machine language instructions is called amacro instruction§ Several assembly languages support such macroinstructions to speed up the coding process§ Assemblers of such assembly languages are designed toproduce multiple machine language instructions for eachmacro instruction of the assembly language215
  18. 18. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 18/59Chapter 12: Computer LanguagesRef PageHigh-Level LanguagesHigh-Level Languages§ Machine independent§ Do not require programmers to know anything about theinternal structure of computer on which high-levellanguage programs will be executed§ Deal with high-level coding, enabling the programmersto write instructions using English words and familiarmathematical symbols and expressions216
  19. 19. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 19/59Chapter 12: Computer LanguagesRef Page§ Translator program (software) that translates a high-level language program into its equivalent machinelanguage program§ Compiles a set of machine language instructions forevery program instruction in a high-level languageCompilerCompiler217
  20. 20. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 20/59Chapter 12: Computer LanguagesRef PageOne-to-many correspondence(SourceProgram)(ObjectProgram)CompilerHigh-levellanguageprogramMachinelanguageprogramInput OutputCompilerCompiler217
  21. 21. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 21/59Chapter 12: Computer LanguagesRef PageIllustrating the requirement of a separate compiler for eachhigh-level language supported by a computerA computer supporting languages L1 and L2Program P1 inhigh-levellanguage L1Program P2 inhigh-levellanguage L2Machine codefor P1Machine codefor P2Compiler forlanguage L1Compiler forlanguage L2CompilerCompiler(Continued on next slide)218
  22. 22. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 22/59Chapter 12: Computer LanguagesRef PageIllustrating the machine independence characteristic of ahigh-level language. Separate compilers are required for thesame language on different computersCompiler forlanguage L1on computer AProgram P1 in high-level language L1Machine code forP1 that will runon computer AExecuted oncomputer ACompiler forlanguage L1on computer BMachine code forP1 that will run oncomputer BExecuted oncomputer BSame resultsobtainedCompilerCompiler(Continued from previous slide..)218
  23. 23. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 23/59Chapter 12: Computer LanguagesRef PageSyntax ErrorsSyntax ErrorsIn addition to doing translation job, compilers alsoautomatically detect and indicate syntax errorsSyntax errors are typically of following types:Note : A compiler cannot detect logic errors in a program§ Illegal characters§ Illegal combination of characters§ Improper sequencing of instructions in a program§ Use of undefined variable names219
  24. 24. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 24/59Chapter 12: Computer LanguagesRef PageSTARTEditsource programSyntaxerrorsdetected?YesCompilesource programSource programGenerate list of codederror messagesGenerateobject programObject programSTOPNoThe Process of Removing Syntax ErrorsFrom A Source ProgramThe Process of Removing Syntax ErrorsFrom A Source Program219
  25. 25. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 25/59Chapter 12: Computer LanguagesRef Page§ For a large software, storing all the lines of programcode in a single source file will be:§ Hence, a modular approach is generally adapted todevelop large software where the software consists ofmultiple source program files§ No need to write programs for some modules as it mightbe available in library offering the same functionality– Difficult to work with– Difficult to deploy multiple programmers toconcurrently work towards its development– Any change in the source program would require theentire source program to be recompiledLinkerLinker(Continued on next slide)219
  26. 26. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 26/59Chapter 12: Computer LanguagesRef PageLinkerLinker§ Each source program file can be independentlymodified and compiled to create a correspondingobject program file§ Linker program (software) is used to properlycombine all the object program files (modules)§ Creates the final executable program (load module)(Continued from previous slide..)220
  27. 27. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 27/59Chapter 12: Computer LanguagesRef Page§ Interpreter is a high-level language translator§ Takes one statement of a high-level languageprogram, translates it into machine languageinstructions§ Immediately executes the resulting machine languageinstructions§ Compiler simply translates the entire source programinto an object program and is not involved in itsexecutionInterpreterInterpreter220
  28. 28. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 28/59Chapter 12: Computer LanguagesRef PageInterpreter(translates andexecutesstatement-by-statement)High-level languageprogram(Source Program)Result ofprogramexecutionInput OutputRole of an InterpreterRole of an Interpreter220
  29. 29. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 29/59Chapter 12: Computer LanguagesRef PageIntermediate Language Compiler &InterpreterIntermediate Language Compiler &Interpreter§ New type of compiler and interpreter combines thespeed, ease, and control of both compiler andinterpreter§ Compiler first compiles the source program to anintermediate object program§ Intermediate object program is not a machinelanguage code but written in an intermediatelanguage that is virtually machine independent§ Interpreter takes intermediate object program,converts it into machine language program andexecutes it221
  30. 30. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 30/59Chapter 12: Computer LanguagesRef PageBenefits of Intermediate LanguageCompiler & InterpreterBenefits of Intermediate LanguageCompiler & Interpreter§ Intermediate object program is in compiled form and thus isnot original source code, so safer and easier to share§ Intermediate object program is based on a standardIntermediate Definition Language (IDL)§ Interpreter can be written for any computer architecture andoperating system providing virtual machine environment to theexecuting program§ Newer Interpreter compiles intermediate program, in memory,into final host machine language program and executes it§ This technique is called Just-In-Time (JIT) Compilation221
  31. 31. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 31/59Chapter 12: Computer LanguagesRef PageAdvantages of High-Level LanguagesAdvantages of High-Level Languages§ Machine independent§ Easier to learn and use§ Fewer errors during program development§ Lower program preparation cost§ Better documentation§ Easier to maintain222
  32. 32. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 32/59Chapter 12: Computer LanguagesRef PageLimitations of High-Level LanguagesLimitations of High-Level Languages§ Lower execution efficiency§ Less flexibility to control the computer’s CPU, memoryand registers222
  33. 33. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 33/59Chapter 12: Computer LanguagesRef PageObject-Oriented Programming LanguagesObject-Oriented Programming Languages§ Programming languages are used for simulating real-world problems on computers§ Much of the real world is made up of objects§ Essence of OOP is to solve a problem by:§ Identifying the real-world objects of the problem§ Identifying processing required of them§ Creating simulations of objects, processes, and theircommunications223
  34. 34. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 34/59Chapter 12: Computer LanguagesRef Page§ Stands for FORmula TRANslation§ Originally developed by John Backus and his team atIBM followed by several revisions§ Standardized by ANSI as FORTRAN-77 and FORTRAN-90§ Designed for solving scientific & engineering problems§ Oriented towards solving problems of a mathematicalnature§ Popular language amongst scientists and engineersFORTRANFORTRAN223
  35. 35. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 35/59Chapter 12: Computer LanguagesRef PageC FORTRAN PROGRAM TO COMPUTEC THE SUM OF 10 NUMBERSSUM = 0DO 50 I = 1, 10READ (5, 10) NSUM = SUM + N50 CONTINUEWRITE (6, 20) SUM10 FORMAT (F6.2)20 FORMAT (1X, ’THE SUM OF GIVEN NUMBERS = ’,F10.2)STOPENDA Sample FORTRAN ProgramA Sample FORTRAN Program224
  36. 36. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 36/59Chapter 12: Computer LanguagesRef Page§ Stands for COmmon Business Oriented Language§ Originally developed started under Grace Hopperfollowed by COnference on DAta SYstems Languages(CODASYL)§ Standardized by ANSI as COBOL-74, COBOL-85, andCOBOL-2002§ Designed for programming business data processingapplications§ Designed to have the appearance and structure of abusiness report written in English, hence often referredto as a self-documenting languageCOBOLCOBOL224
  37. 37. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 37/59Chapter 12: Computer LanguagesRef PageIDENTIFICATION DIVISION.PROGRAM_ID. SUMUP.AUTHOR. P K SINHA.* THIS PROGRAM COMPUTES AND PRINTS* THE SUM OF GIVEN NUMBERS.ENVIROMENT DIVISION.CONFIGURATION SECTION.SOURCE_COMPUTER. BURROUGHS_6700.OBJECT_COMPUTER. BURROUGHS_6700.INPUT_OUTPUT SECTION.FILE_CONTROL.SELECT DATA_FILE ASSIGN TO DISK.SELECT OUTPUT_FILE ASSIGN TO PRINTER.DATA DIVISION.FILE SECTION.A Sample COBOL ProgramA Sample COBOL Program(Continued on next slide)226
  38. 38. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 38/59Chapter 12: Computer LanguagesRef PageFD DATA_FILERECORD CONTAINS 80 CHARACTERSLABEL RECORD IS OMITTEDDATA RECORD IS INPUT_DATA_RECORD.01 INPUT_DATA_RECORD.05 NPICTURE 9(6)V99.05 FILLER PICTURE X(72).FD OUTPUT_FILERECORD CONTAINS 132 CHARACTERSLABEL RECORD IS OMITTEDDATA RECORD IS OUTPUT_RECORD.A Sample COBOL ProgramA Sample COBOL Program(Continued from previous slide..)(Continued on next slide)226
  39. 39. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 39/59Chapter 12: Computer LanguagesRef Page01 OUTPUT_RECORD.05 FILLER PICTURE X.05TITLE PICTURE X(25).05 SUM PICTURE 9(10)V99.05 FILLER PICTURE X(94).WORKING_STORAGE SECTION.77MESSAGE PICTURE X(25)VALUE IS “THE SUM OF GIVEN NUMBERS=”.PROCEDURE DIVISION.OPEN_FILES.OPEN INPUT DATA_FILE.OPEN OUTPUT OUTPUT_FILE.INITIALIZATION.MOVE SPACES TO OUTPUT_RECORD.MOVE ZERO TO SUM.A Sample COBOL ProgramA Sample COBOL Program(Continued from previous slide..)(Continued on next slide)226
  40. 40. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 40/59Chapter 12: Computer LanguagesRef PagePROCESS_LOOP.READ DATA_FILE AT END GO TOPRINT_PARA.ADD N TO SUM.GO TO PROCESS_LOOP.PRINT_PARA.MOVE MESSAGE TO TITLE.WRITE OUTPUT_RECORD.END_OF_JOB.CLOSE DATA_FILE.CLOSE OUTPUT_FILE.STOP RUN.A Sample COBOL ProgramA Sample COBOL Program(Continued from previous slide..)226
  41. 41. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 41/59Chapter 12: Computer LanguagesRef Page§ Stands for Beginners All-purpose Symbolic InstructionCode§ Developed by Professor John Kemeny and Thomas Kurtzat Darmouth College in the United States§ Standardized by ANSI as BASIC-78§ Designed to be an interactive language and to use aninterpreter instead of a compiler§ Simple to implement, learn and use language. Hence, itis a widely used language on personal computers§ Flexible and reasonably powerful language and can beused for both business and scientific applicationsBASICBASIC227
  42. 42. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 42/59Chapter 12: Computer LanguagesRef Page5 REM PROGRAM TO COMPUTE6 REM THE SUM OF 10 NUMBERS10 LET S = 020 FOR I = 1 TO 1030 READ N40 LET S = S + N50 NEXT I60 PRINT “THE SUM OF GIVEN NUMBERS = ”; S70 DATA 4, 20, 15, 32, 4880 DATA 12, 3, 9, 14, 4490 END;A Sample BASIC ProgramA Sample BASIC Program227
  43. 43. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 43/59Chapter 12: Computer LanguagesRef Page§ Named after the famous seventeenth-century Frenchmathematician Blaise Pascal§ Developed by Professor Nicklaus Wirth of Federal Institute ofTechnology in Zurich§ Encourages programmers to write well-structured, modularprograms, instills good program practices§ Recognized as an educational language and is used to teachprogramming to beginners§ Suitable for both scientific & business applications§ Has features to manipulate numbers, vectors, matrices,strings, sets, records, files, and listsPascalPascal228
  44. 44. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 44/59Chapter 12: Computer LanguagesRef PagePROGRAM SUMNUMS (INPUT, OUTPUT);(* PROGRAM TO COMPUTE THE SUM OF 10 NUMBERS *)(* DECLARATION OF VARIABLES *)VAR SUM, N : REAL;VAR I : INTEGER;(* MAIN PROGRAM LOGIC STARTS HERE *)BEGINSUM := 0;FOR I := 1 TO 10 DOBEGINREAD (N);SUM := SUM + N;END;WRITELN (‘THE SUM OF GIVEN NUMBERS=’, SUM);END;A Sample Pascal ProgramA Sample Pascal Program228
  45. 45. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 45/59Chapter 12: Computer LanguagesRef PageCC§ Developed in 1972 at AT&T’s Bell laboratories, USAby Dennis Ritchie and Brian Kernighan§ Standardized by ANSI and ISO as C89, C90, C99§ High-level programming languages (mainly machineindependence) with the efficiency of an assemblylanguage§ Language of choice of programmers for portablesystems software and commercial software packageslike OS, compiler, spreadsheet, word processor, anddatabase management systems229
  46. 46. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 46/59Chapter 12: Computer LanguagesRef Page/* PROGRAM TO COMPUTE THE SUM OF 10 NUMBERS *//* Directives to include standard library and header */#include <stdlib.h>#include <stdio.h>/* Main function starts here */void main ( ){/* Declaration of variables */float Sum = 0.0, N = 0.0;int Count = 0;for (Count = 0; Count < 10; Count++){printf(“nGive a number:”);scanf(“%f”, N);Sum += N;}printf(“THE SUM OF GIVEN NUMBERS = %f”, &Sum);}A Sample C ProgramA Sample C Program230
  47. 47. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 47/59Chapter 12: Computer LanguagesRef PageC++C++§ Named C++ as ++ is increment operator and Clanguage is incremented to its next level with C++§ Developed by Bjarne Stroustrup at Bell Labs in theearly 1980s§ Contains all elements of the basic C language§ Expanded to include numerous object-orientedprogramming features§ Provides a collection of predefined classes, along withthe capability of user-defined classes229
  48. 48. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 48/59Chapter 12: Computer LanguagesRef PageJavaJava§ Development started at Sun Microsystems in 1991 by ateam led by James Gosling§ Developed to be similar to C++ with fewer features tokeep it simple and easy to use§ Compiled code is machine-independent and developedprograms are simple to implement and use§ Uses just-in-time compilation§ Used in embedded systems such as hand-held devices,telephones and VCRs§ Comes in two variants – Java Runtime Engine (JRE) andJava Software Development Kit (SDK)231
  49. 49. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 49/59Chapter 12: Computer LanguagesRef PageC# (C Sharp)C# (C Sharp)§ Object-oriented programming language developed byAnders Hejlsberg and released by Microsoft as part ofMicrosoft’s .NET technology initiative§ Standardized by ECMA and ISO§ Syntactically and semantically very close to C++ andadopts various object-oriented features from both C++and Java§ Compilers target the Common Language Infrastructure(CLI) implemented by Common Language Runtime (CLR)of .NET Framework§ CLR provides important services such as, memorymanagement, exception handling, and security232
  50. 50. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 50/59Chapter 12: Computer LanguagesRef PageRPGRPG§ Stands for Report Program Generator§ Developed by IBM to meet customer requests for aneasy and economic mechanism for producing reports§ Designed to generate the output reports resulting fromthe processing of common business applications§ Easier to learn and use as compared to COBOL§ Programmers use very detailed coding sheets to writespecifications about input, calculations, and output232
  51. 51. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 51/59Chapter 12: Computer LanguagesRef PageLISPLISP§ Stands for LISt Processing§ Developed in 1959 by John McCarthy of MIT§ Designed to have features for manipulating non-numeric data, such as symbols and strings of text§ Due to its powerful list processing capability, it isextensively used in the areas of pattern recognition,artificial intelligence, and for simulation of games§ Functional programming language in which allcomputation is accomplished by applying functions toarguments232
  52. 52. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 52/59Chapter 12: Computer LanguagesRef PageSNOBOLSNOBOL§ Stands for StriNg Oriented symBOlic Language§ Used for non-numeric applications§ Powerful string manipulation features§ Widely used for applications in the area of textprocessing233
  53. 53. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 53/59Chapter 12: Computer LanguagesRef PageCharacteristics of a GoodProgramming LanguageCharacteristics of a GoodProgramming Language§ Simplicity§ Naturalness§ Abstraction§ Efficiency§ Structured Programming Support§ Compactness§ Locality§ Extensibility§ Suitability to its environment233
  54. 54. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 54/59Chapter 12: Computer LanguagesRef PageFactors for Selecting a Language forCoding an ApplicationFactors for Selecting a Language forCoding an Application§ Nature of the application§ Familiarity with the language§ Ease of learning the language§ Availability of program development tools§ Execution efficiency§ Features of a good programming language234
  55. 55. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 55/59Chapter 12: Computer LanguagesRef PageSubprogramSubprogram§ Program written in a manner that it can be brought intouse in other programs and used whenever neededwithout rewriting§ Also referred to as subroutine, sub-procedure, or function§ Subprogram call statement contains the name of thesubprogram followed by a list of parameters enclosedwithin a pair of parentheses§ Intrinsic subprograms (also called built-in-functions) arethose provided with the programming language§ Programmer-written subprograms are written and usedas and when they are needed235
  56. 56. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 56/59Chapter 12: Computer LanguagesRef Pagesqrt (x)Set of instructions that performthe intended taskSubprogram name ParameterSubprogram headerSubprogram bodyStructure of a SubprogramStructure of a Subprogram235
  57. 57. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 57/59Chapter 12: Computer LanguagesRef PageA program that callsthe subprogram twicesubprogram headersubprogram bodysubprogram call statementnext statementsubprogram call statementnext statementA subprogram Flow of control13726 4589Flow of Control in Case of Subprogram CallsFlow of Control in Case of Subprogram Calls236
  58. 58. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 58/59Chapter 12: Computer LanguagesRef PageKey Words/PhrasesKey Words/Phrases§ Assembler§ Assembly language§ BASIC§ Built-in function§ C§ C++§ C#§ COBOL§ Coding§ Compiler§ Computer language§ FORTRAN§ Function§ High-level language§ HotJava Interpreter§ Intrinsic subprogram§ Intermediate compiler andInterpreter§ Java§ Just-in-time compilation§ Language processor§ Linker§ LISP§ Load module§ Logic error§ Low-level language§ Machine language§ Macro instructions§ Object program§ Object-oriented programming§ Opcode§ Operand§ Pascal§ Programmer§ Programming§ Programming language§ Pseudo instruction§ RPG§ Self-documenting language(Continued on next slide)236
  59. 59. Computer Fundamentals: Pradeep K. Sinha & Priti SinhaComputer Fundamentals: Pradeep K. Sinha & Priti SinhaSlide 59/59Chapter 12: Computer LanguagesRef Page§ SNOBOL§ Source program§ Sub-procedure§ Subprogram§ Subroutine§ Symbolic language§ Syntax error§ Syntax rules§ Written subprogramsKey Words/PhrasesKey Words/Phrases(Continued from previous slide..)236

×