1 / 14

Chapter 4

Chapter 4. Software. Generations of Languages. Each computer is wired to perform certain operations in response to an instruction. An instruction is a pattern of ones and zeros stored in a “word” of computer memory. A “word” of memory is the basic unit of storage for a computer

dragon
Download Presentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Software

  2. Generations of Languages • Each computer is wired to perform certain operations in response to an instruction. An instruction is a pattern of ones and zeros stored in a “word” of computer memory. • A “word” of memory is the basic unit of storage for a computer • When a computer accesses memory, it usually stores or retrieves a word of information at a time. Chapter 4: Software

  3. Generations of Languages • A “word” of memory is the basic unit of storage for a computer • 8 bits = 1 byte • A 16-bit computer has a word size of 16 bits, or two bytes • A 32-bit computer has a word size of 32 bits, or 4 bytes • A 64-bit computer has a word size of 64 bits, or 8 bytes Chapter 4: Software

  4. Generations of Languages • First-Generation • 0110000001000000 (Load the A-register from 64) • Second-Generation – assembly language • LDA 100 (Load the A-register from 100 octal = 64) Chapter 4: Software

  5. Generations of Languages Third-Generation • FORTRAN – first third-generation language • x = y + z • Statements look something like English and mathematical statements. Easier to read and write. • C, C++, Java, BASIC, Visual Basic, COBOL Chapter 4: Software

  6. Compilers and Interpreters • A compiler is a program for creating machine language from a high-level programming language. • The job of the compiler is to translate the source code into machine code. • The result of compiling a program is a file of object code, which is a binary file of machine instructions that will be executed when the program is run. Chapter 4: Software

  7. Compilers and Interpreters • Interpreters translate source code to machine code one source code line at a time and they do this every time the program runs. Unlike • Compilers translate all lines of source code at once and only once. Compilers do not run when the program runs. Chapter 4: Software

  8. Compilers and Interpreters • Compiled programs run faster but it’s harder to find and fix errors. • Interpreters run slower, however, it’s easier to find and fix errors because interpreters usually provide better error messages and it’s quicker to rerun an interpreted program because the program doesn’t have to be compiled first. Chapter 4: Software

  9. Virtual Machines • Generally describes an additional layer of abstraction between the user and the hardware. • It is also used to describe software that makes one type of computer appear to be another. Chapter 4: Software

  10. Virtual Machines • Java Virtual Machine (JVM) • Java is both compiled and interpreted • The Java compiler (javac) translates Java source code into “bytecode” which is platform-independent intermediate code. When the Java program runs the JVM interpretes the bytecode into machine code. Chapter 4: Software

  11. Procedural Programming • A list of instructions to be executed in order. • The code for a specific job is contained in a named procedure also known as a subroutine. This is called structured/modular programming. • The subroutines can be reused throughout the program. • Write once, use many. Chapter 4: Software

  12. Object-Oriented Programming • Instead of subroutines, OO programming relies on software objects as the unit of modularity • Objects are called “classes” • Classes have attributes and behaviors • Attributes are defined using instance variables. • Behavior are defined using subroutines aka methods • Automobile class • Attributes: four wheels, a motor, seats…etc. • Behavior: change speed, park, turn, refuel. Chapter 4: Software

  13. Object-Oriented Programming • Encapsulation – reliable operation even as things change. If the creator of the class decides to make a change, the interface will remain the same. • Inheritance – ability to create a class by inheriting attributes and methods from another class. • Polymorphism – A method of a given name may be different depending on the class of the object for which the method is invoked. Chapter 4: Software

  14. Summary • The machine instruction sets themselves constituted the first generation programming languages. Programs were conceived as sequences of machine operations, and programmers worked directly with the hardware, often entering code in ones and zeros directly through the front panel switches. Assembly languages, using mnemonic character strings to represent machine instructions, made up the second generation of programming languages. Beginning with FORTRAN in 1954, third-generation languages allowed programmers to work at a higher level, with languages that were much more independent of the computer hardware. • Programs can be compiled or interpreted. Compilers generate machine instructions that can run directly on the computer, independent of further availability of the compiler program. Interpreters, on the other hand, are programs that read and execute source code a line at a time. Java is an environment that uses both. Java source code is compiled into machine-independent bytecode, and the Java Virtual Machine interprets the bytecode at execution. Many JVM implementations today also compile bytecode to machine instructions. Chapter 4: Software

More Related