1 / 38

Computer Programs and Programming Languages

Computer Programs and Programming Languages. What are low-level languages and high-level languages?. Low-level language. High-level language. Machine-dependent runs only on one type of computer. Often machine-independent can run on many different types of computers.

fathia
Télécharger la présentation

Computer Programs and Programming Languages

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. Computer Programs and Programming Languages • What are low-level languages and high-level languages? Low-levellanguage High-level language Machine-dependentruns only on one type of computer Oftenmachine-independentcan run on many different types of computers Machine and assembly languages are low-level

  2. Generations of programming languages

  3. The evolution of programming paradigms Imperative or Procedural Declarative Functional Object Oriented

  4. Low-Level Languages • What is machine language? • Only language computer directly recognizes

  5. Low-Level Languages • What is assembly language? • Instructions made up of symbolic instruction codes, meaningful abbreviations and codes • Source program contains code to be converted to machine language

  6. Second-generation:Assembly language • A mnemonic system for representing programs • Mnemonic names for op-codes • Names for all registers • Identifiers = descriptive names for memory locations, chosen by the programmer

  7. Assembly language characteristics • One-to-one correspondence between machine instructions and assembly instructions • Programmer must think like the machine • Inherently machine-dependent • Converted to machine language by a program called an assembler

  8. Machine language156C166D505630CEC000 Assembly languageLD R5, PriceLD R6, ShippingChargeADDI R0, R5 R6ST R0, TotalCostHLT Assembly language example

  9. Third generation language • Uses high-level primitives • Similar to our pseudocode in Chapter 5 • Machine independent (mostly) • Examples: FORTRAN, COBOL • Each primitive corresponds to a short sequence of machine language instructions • Converted to machine language by a program called a compiler

  10. Procedural Languages • What is a procedural language? Programmer writes instructions that tell computer what to accomplish and how to do it Uses series of English-like words to write instructions Often called third-generation language (3GL) Most widely used are BASIC, COBOL, and C

  11. Procedural Languages • What is a compiler? • Program that converts entire source program into machine language before executing it

  12. Procedural Languages • What is an interpreter? • Program that translates and executes one program code statement at a time • Does not produce object program

  13. Procedural Languages • What is COBOL? • Designed for business applications • English-like statements make code easy to read, write, and maintain • COmmon Business-Oriented Language

  14. Procedural Languages • What is C? • Powerful language originally designed to write system software • Requires professional programming skills

  15. The composition of a typical imperative program or program unit

  16. Variable declarations in C, C++, C#, and Java

  17. Control structures and their representations in C, C++, C#, and Java

  18. The for loop structure and its representation in C++, C#, and Java

  19. The flow of control involving a procedure

  20. The procedure ProjectPopulation written in the programming language C

  21. Executing the procedure Demo and passing parameters by value

  22. Executing the procedure Demo and passing parameters by reference

  23. The translation process

  24. A syntax diagram of our if-then-else pseudocode statement

  25. An object-oriented approach to the translation process

  26. Object-Oriented Programming Languages • What is an object-oriented programming (OOP) language? Used to implement object-oriented design Major benefit is ability to reuse existing objects Event-driven—checks for and responds to set of events C++ and Java are complete object-oriented languages Objectis item that contains data and procedures that act on data Eventis action to which program responds

  27. Object-Oriented Programming Languages • What is C++? • Includes all elements of C, plus additional features for working with object-oriented concepts • Used to develop database and Web applications

  28. Object-Oriented Programming Languages • What is Java? • Developed by Sun Microsystems • Similar to C++ but uses just-in-time (JIT) compiler to convert source code into machine code

  29. Object-Oriented Programming Languages Visual programming environment (VPE) allows developers to drag and drop objects to build programs Programmer writes and implements program in segments • What is a visual programming language? Provides visual or graphical interface for creating source code Sometimes calledfifth-generation language Often used in RAD (rapid application development) environment

  30. Object-Oriented Programming Languages Step 1. The programmer designs the user interface. Step 2.The programmer assigns properties to each object on the form. Step 3.The programmer writes code to define the action of each command button. Step 4.The programmer tests the application. • What is Visual Studio .NET 2003? • Suite of visual programming languages and RAD tools • .NET is set of technologies that allows program to run on Internet • Visual Basic .NET 2003 is used to build complex object-based programs

  31. Objects and Classes • Object = active program unit containing both data and procedures • Class = a template for all objects of the same type • An Object is often called an instance of the class.

  32. Components of an object • Instance variable = variable within an object • Method = function or procedure within an object • Can manipulate the object’s instance variables • Constructor = special method to initialize a new object instance

  33. The structure of a class describing a coin public class Coin { private final int HEADS = 0; private final int TAILS = 1; private int face; // Sets up the coin by flipping it initially. public Coin () { flip(); } // Flips the coin by randomly choosing a face value. public void flip () { face = (int) (Math.random() * 2); } } Instance variable constructor Method

  34. Nonprocedural Languages and Program Development Tools • What are nonprocedural languages and program development tools? Nonprocedural LanguageThe programmer writes English-like instructions or interacts with a visual environment to retrieve data from files or a database Program Development ToolsUser-friendly programs designed to assist both programmers and users in creating programs

  35. Nonprocedural Languages and Program Development Tools • What is RPG (Report Program Generator)? • Nonprocedural language used for generating reports, performing computations, and updating files

  36. Nonprocedural Languages and Program Development Tools • What is a fourth-generation language(4GL)? • Nonprocedural language that allows access to data in database • Popular 4GL is SQL, query language that allows users to manage data in relational DBMS

  37. Nonprocedural Languages and Program Development Tools • What is an application generator? • Program that creates source code or machine code from specification • Consists of report writer, form, and menu generator • Form provides areas for entering data

  38. Nonprocedural Languages and Program Development Tools • What is Visual Basic for Applications (VBA)? • Macro programming language • Macro—series of statements used to automate tasks

More Related