1 / 10

What is a computer program?

Discover what a computer program is, the concept of programming languages, software languages, CPU instruction sets, and the role of algorithms in implementing programs. Learn how to describe algorithms and unleash your creativity in computer programming.

greggv
Download Presentation

What is a computer program?

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. What is a computer program?

  2. What is a Computer Program? • A solution to a problem? • A confusing mess? • A sequence of computer instructions?

  3. What is a Computer Program? • A computer program is a sequence of statements written in a formal language and executed in sequential order • There are some statements that can jump to another position in the sequence

  4. Languages • Languages have • syntax (the way in which words can be combined) and • semantics (roughly, the meaning; the relation between the language and the world) • Natural language • Languages we speak: English, Spanish, Chinese, Finnish, etc • Can grow (infinitely?) • Can be redundant and ambiguous • Pronouns • Formal language • A language we invent for some particular reason (like a programming language) • Some might be meant to be machine interpretable • Can grow but slowly and not infinitely • Can not be redundant or ambiguous • Pronouns • Programming languages are formal languages

  5. Software Languages • High level language • Highest level of abstraction • C#, Java, Python, C++ • Mid/Low level language • Less abstraction – closer to the hardware • C • Assembly language • No abstraction • Mnemonics for instructions, memory location names • Machine code (hardware) • These are the binary op codes (instructions) that execute on the hardware

  6. Software Languages "Vaporators? Sir, my first job was programming binary loadlifters—very similar to your vaporators in most respects."

  7. CPU Instruction Set • The instructions that the computer understands are its native Machine Language instructions (assembly language programs are written using these instructions directly). • 8008 Instruction Set

  8. Assembly Language A very small assembly language program to add two numbers from memory and place the result back in memory would look like this: LAM    5E00     ; Load data from address 5E0016 into ALBM    5E01     ; Load data from address 5E0116 into BADB             ; Add A and B and put result in ALMA    5E02     ; Move data from A to address 5E0216 HLT

  9. What is a CPU Good At? • Remembering things • Moving values to/from memory • Computer moves things from CPU bus to display or network • Simple math operations • Add, subtract • Multiply, divide are sometimes provided in separate floating-point processor • Repetition • Over, and over, ….. and over again • Low level decision making • Compare two values, jump on condition • The job of the programmer is to implement an algorithm using these simple instructions to do the job that needs to be done • Think about long division – step by step process (algorithm) to divide two numbers

  10. Exercises in Describing an Algorithm • What are the steps to? • Make a peanut butter and jelly sandwich • Sort playing cards • Sort cards by • suit (spades, hearts, diamonds, clubs) and • Rank (A, K, Q, J, 10 – 2) • Count Legos by color • Counts of each color of Legos • Long division • These processes must described in simple steps and must be complete so that someone else (even a computer) could follow them • Think about how you would tell another person (or a computer) to do this • Write down the steps • Computer programming is a written form of art

More Related