1 / 31

Computer Programming

Computer Programming. Putting the machine under our command. Definition of a Program. A collection of instructions that describe a task, or set of tasks, to be carried out by a computer. Types of Computer Programs. Firmware Systems Software Applications Software. Programming Languages.

linus
Download Presentation

Computer Programming

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 Programming Putting the machine under our command

  2. Definition of a Program A collection of instructions that describe a task, or set of tasks, to be carried out by a computer

  3. Types of Computer Programs • Firmware • Systems Software • Applications Software

  4. Programming Languages A programming language is an artificial language that can be used to control the behavior of a machine.

  5. Early Computer Programming The first computers were programmed by changing the wiring

  6. Programming Language Background • John von Neumann - stored program • Alan Turing - Turing Machine • Alonzo Church - Lambda calculus

  7. First Generation Languages • Machine level code • Binary • Univac & IBM 701 • Add reg 1 to reg 2 place results in reg 6 • 000000 00001 00010 00110 00000 100000

  8. Second Generation Languages • Assembly code • Mnemonic code to represent instructions • Move 61 to register named “al” • mov al, 061

  9. Third Generation Languages • Use English-like terms • Compiler to translate to machine level • Fortran, ALGOL, COBOL early examples • COMPUTE NET-PAY = GROSS-PAY - TOTAL-TAX

  10. Fourth Generation Languages • More oriented toward problem solving • State the problem, don’t care how it is solved. • Divided into categories • SQL - Structured Query Language • Select * from Employee where Last-Name = “Smith”

  11. Fifth Generation Languages • Set of constraints rather than steps to solve problems • Heuristics • Artificial Intelligence • Prolog • cat(tom) |- true

  12. Program Development Life Cycle Step 1 Describing the Problem Step 2 Making a Plan Step 3 Coding Step 4 Debugging Step 5 Finishing the Project

  13. Step 1 : Describing the Problem • The problem statement is: • The starting point of programming • A description of tasks the program is to accomplish • How the program will execute the tasks • Created through interaction between the programmer and the user • The program statement includes error handling and a testing plan

  14. Parking Garage Example

  15. Step 2: Developing an Algorithm Wake Up Check wallet for $ • Algorithm development: • A set of specific, sequential steps that describe what the computer program must do • Complex algorithms include decision points: • Binary (yes/no) • Loop (repeating actions) • Visual tools used to track algorithm and decision points: Do I have > $80 Yes No Head off to cafe Do I have my credit card? Yes No Go get gas Yes Go to the ATM for cash Buy textbook Did I get $80 from the ATM? Go to accounting lecture No

  16. Flowchart and Pseudocode Flowchart Pseudocode Bold terms show actions that are common in programming, such as reading data, making decisions, printing, and so on. 1. Ask the user how many hours they worked today 2. If the number of hours worked < = 8, compute total pay without overtime otherwise, compute total pay with overtime pay 3. Print total pay Underlined words are information items that appear repeatedly in the algorithm.

  17. Step 3: Coding • Coding is translating an algorithm into a programming language • Generations of programming languages

  18. Compilation • Compilation is the process of converting code into machine language • Compiler reads the source code and translates it into machine language • After compilation, programmers have an executable program

  19. Interpreter • Interpreter translates source code into a line by line intermediate form • Each line is executed before the next line is compiled • Programmers do not have to wait for the entire program to be recompiled each time they make a change. • Programmers can immediately see the results of changes as they are making them in the code.

  20. Step 4: Debugging • Running a program to find errors is known as debugging • Sample inputs are used to determine runtime (logic) errors • Debugger: Tool that helps programmers locate runtime errors

  21. Step 5: Finishing the Project • Users test the program (internal testing) • Beta version released: • Information collected about errors before final revision • Software updates (service packs): • Problems found after commercial release • Documentation created: • User manuals • User training

  22. Programming Languages Flash / XML • Selecting the right language: • Space available • Speed required • Organizational resources available • Type of target application ASP / JSP JavaScript VBScript Visual Basic HTML C / C++ Java

  23. The CPU: Processing Digital Information • CPU is the brains of the computer • Different types of CPUs • Intel and AMD chips: Used in most Windows-based PCs • Apple systems use different CPU design • Differentiating CPUs • Processing power • Clock speed and cache

  24. Instruction Set • All commands that the CPU can execute • Arithmetic • Logic • Data • Control flow

  25. Instruction Set Architecture • CISC • Complex Instruction Set Computer • Many different instructions • Intel - Windows • RISC • Reduced Instruction Set Computer • Fewer instructions • Motorola/Intel - Macintosh

  26. The CPU Machine Cycle • Fetch • The program’s binary code is “fetched” from its temporary location in RAM and moved to the CPU • Decode • The program’s binary code is decoded into commands the CPU understands. • Execute • The ALU performs the calculations. • Store • The results are stored in the registers

  27. The System Clock • Located on the motherboard • Controls the CPU’s processing cycles • Clock cycle • Pulse or tick • Clock speed • Number of pulses per second • Measured in hertz (Hz)

  28. The Control Unit • Manages the switches inside the CPU • Is programmed by CPU designers to remember the sequence of processing stages for that CPU • Moves each switch to its correct setting (on or off) and then performs the work of that stage

  29. The Arithmetic Logic Unit (ALU) • Part of the CPU designed to perform mathematical operations (addition, subtraction, multiplication, division, etc.) • Also performs logical OR, AND, and NOT operations • Is fed data from the CPU registers • Word size: Number of bits a computer can work with at a time

  30. Cache Memory • Small amount of memory located on the CPU chip or near it • Stores recent or frequently used instructions and data • Used for quick access by the CPU • Different levels of cache

  31. Software Horror Stories http://www.cs.tau.ac.il/~nachumd/verify/horror.html

More Related