Administrivia First pieces of assignment 5 Comments about assignment 5 Assignment 6 Labs 5 and 6.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Semantics of Hoare Logic Aquinas Hobor and Martin Henz.
FORTRAN Short Course Week 1 Kate T-C February 17, 2008.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Chapter 8 Representing Information Digitally.
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
CPSC Compiler Tutorial 9 Review of Compiler.
Writing a Program in a High- level Language Figure out what you want to do –Understand the rules that guide the process you are automating Make sure that.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
The Analytical Engine Module 6 Program Translation.
Programming November 13, Administrivia From Thu Nov 8 12:05: Date: Thu, 8 Nov :04: (EST) From:
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
1 Lab Session-IV CSIT-120 Spring 2001 Lab 3 Revision and Exercises Rev: Precedence Rules Lab Exercise 4-A Machine Language Programming The “Micro” Machine.
What makes a good language Does the task you want Keeps you from making mistakes Supports debugging when you need it Has a strong tool kit.
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Programming Languages Structure
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Machine Languages Different types of CPU’s understand different instructions Pentium family / Celeron / Xeon / AMD K6 / Cyrix … (Intel x86 family) PowerPC.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Computer Science 101 Introduction to Programming.
© Paradigm Publishing Inc Chapter 12 Programming Concepts and Languages.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
USS Yorktown (1998) A crew member of the guided-missile cruiser USS Yorktown mistakenly entered a zero for a data value, which resulted in a division by.
1 Software Development Topic 2 Software Development Languages and Environments.
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Programming. What is a Program ? Sets of instructions that get the computer to do something Instructions are translated, eventually, to machine language.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Programming Languages: History & Traditional Concepts CSC 2001.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Computer Science 101 Introduction to Programming.
Software Overview. Why review software? Software is the set of instructions that tells hardware what to do The reason for hardware is to execute a program.
1 Overview of Programming and Problem Solving Chapter 1.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
Robert Crawford, MBA West Middle School.  Explain how the binary system is used by computers.  Describe how software is written and translated  Summarize.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
5.0 PROGRAMMING Duration: 10 weeks Prepared by Ong Lay Peng Copyright © 2007.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Last week: We talked about: History of C Compiler for C programming
Component 1.6.
CSCI-235 Micro-Computer Applications
Getting Started with C.
Application Development Theory
The Top 10 bugs
Chapter 11 Introduction to Programming in C
Topics Introduction Hardware and Software How Computers Store Data
Principles of Programming Languages
Tonga Institute of Higher Education IT 141: Information Systems
Computer Organization COMP 210
Tonga Institute of Higher Education IT 141: Information Systems
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
WJEC GCSE Computer Science
Programming Logic and Design Eighth Edition
Presentation transcript:

Administrivia First pieces of assignment 5 Comments about assignment 5 Assignment 6 Labs 5 and 6

Some bytes e 0a0d 0a1a d c d ccda 79fd 24d e 0a0d 0a1a d c d d4da 61fd 648c

Object oriented programming Figure out characteristics of your data –objects Figure out operations you will want to perform –Methods Modern idea in programming.

Objects Traffic light at intersection involves –Lights in each direction Call them red, yellow and green and not 0,1,2 –Sensors in each direction –Timing (rate of change in each direction) Timings needn’t be the same –Neighboring Lights May affect change as much as sensors

Methods Method of querying color of light Method of changing color of light Method of scheduling a color change later …

What happens to the program? Compiled or interpreted –Eventually it gets translated into machine language If compiled –Can store executable and run again If interpreted –Interpret each time it is executed

What does the compiler do? Identifies variables (need space in RAM) –Uses stores and loads to get values to registers Parses commands –Turns each command into a string of machine language commands Sets things up for execution

Steps in compilation Lexical analysis –Identify all keywords –Identify all operators –Identify all variables –Make everything into tokens Parsing –Turn the tokens into operations –Build a computation tree Code generation –Generate machine code

Lexical analysis Keywords –If … Then.. End If –If.. Then.. Else … End If –Do While … … Loop –Private sub …. –End sub –Dim … as Integer Operators –= (in 2 contexts) If (Light = 0) Light = 1 –+ - * / - also in 2 contexts (unary or binary)

Simple code fragment Sub print_ftoc(low As Integer, high As Integer) Dim fahrenheit As Double, celsius As Double For fahrenheit = low to high celsius = 5 / 9 * (fahrenheit - 32) print fahrenheit, celsius Next fahrenheit End Sub

Simplified code fragment Dim low As Integer, high As Integer Dim fahrenheit As Double, celsius As Double For fahrenheit = low to high celsius = 5 / 9 * (fahrenheit - 32) print fahrenheit, celsius Next fahrenheit End

Code fragment (lex’ed) Dim low As Integer, high As Integer Dim fahrenheit As Double, celsius As Double For fahrenheit = low to high celsius = 5 / 9 * (fahrenheit - 32) print fahrenheit, celsius Next fahrenheit End Keywords, variables, constants, operators, functions, separators

Code fragment (cont.) Dim As Integer, As Integer Dim As Double, As Double For = to = 5 / 9 * ( - 32) print, Next End Replace variables by tags these are really locations in RAM How things are defined determines how much RAM they need how operations on them work

Code fragment (cont.) For = to = 5 / 9 * ( - 32) print, Next The instructions in the loop must be unwound = = 5 / 9 * ( - 32) print, = + 1 If > go back

= = 5 / 9 * ( - 32) print, = + 1 If > go back The unwound loop can be translated into machine language Store 32 in R3 Store 5/9 in R4 Store 1 in R5 Load into R1 ***Store R1 into Load into R2 Subtract R3 from R2 and store in R2 Multiply R4 by R2 and store in R2 Store R2 in Print R1,R2 Add R5 to R1 and store in R1 Store R5 in Load into R6 Subtract R6 from R5 and store in R5 Go back to *** if R6 > 0

Parsing Language is defined by a grammar Grammar is defined by production rules Parsing is done by unwinding

How do we specify a grammar? 2 aspects to a language –Symbols –Rewriting rules Simple language for generating numbers –Symbols Non-terminals –,,, Terminals –

Simple rewriting rules .  + | -  | |   digit   

An example .  + | -  | |   digit    .  …

Simplifying the rules .  + | -  | |   digit    . |  +|-  |  0|1|2|3|4|5|6|7|8|9

Parsing . |  +|-  |  0|1|2|3|4|5|6|7|8|9 What rules were applied to get ?

What about real languages? The complete grammar for C –around 400 lines long –58 tokens (based on keywords) –65 basic productions (each with many options) –Only a few complex situations

Programming language tradeoffs Branching vs. locality –Should the program be in blocks or look like spaghetti Type declarations –If you Dim something as an integer and then try to make it hold a double, what should happen? Verification –How do you tell if your specification is right? –How do you tell if your program meets your specification?

History of Programming Languages Fortran (1954) for scientific Cobol (1959) for business Algol (1958) more universal Fortran Lisp (1958) string/concept oriented APL (1960) formula oriented

History of Programming Languages PL/1 (1964) from Algol + Fortran Basic (1964) for everyone to use Simula (1967) combines with Algol to yield Smalltalk (1969) – object oriented BCPL  B  C (1971) Algol  Pascal (1971)  Modula 1,2,3,

History of Programming Languages C++ (1983) C with object oriented features –Often C is still used Awk (1978)  Perl (1987) report generators –Web programming language Java (1991) object oriented and portable –Web applets, devices Visual Basic(1991) macros and programs –Core of Microsoft systems

What makes a good language Does the task you want Keeps you from making mistakes Supports debugging when you need it Has a strong tool kit

Big number bug On June 4, 1996 an unmanned Ariane 5 rocket launched by the European Space Agency exploded just forty seconds after its lift-off from Kourou, French Guiana. The rocket was on its first voyage, after a decade of development costing $7 billion. The destroyed rocket and its cargo were valued at $500 million. A board of inquiry investigated the causes of the explosion and in two weeks issued a report. It turned out that the cause of the failure was a software error in the inertial reference system. Specifically a 64 bit floating point number relating to the horizontal velocity of the rocket with respect to the platform was converted to a 16 bit signed integer. The number was larger than 32,768, the largest integer storeable in a 16 bit signed integer, and thus the conversion failed.

Pentium II bug Software bug encoded in hardware Division algorithm uses a lookup table of 1066 entries Only 1061 of the entries are downloaded to the PLA (programmed logic array from which the data are used) Intel had to recall all versions of the chip

NASA Mariner 1, Venus probe (1992) Intended to be the first US spacecraft to visit another planet, it was destroyed by a range officer on 22 July 1962 when it behaved erratically four minutes after launch. –The alleged missing `hyphen' was really a missing `bar'. –(period instead of comma in FORTRAN DO-Loop)

AT&T long distance service fails for nine hours (Wrong BREAK statement in C-Code, 1990) January 15, 1990: 70 million of 138 million long distance customers in the US lost long distance service. Cost to ATT was between $ 75 Million and $100 Million (plus the loss of good will).

buffer overflow (1998) Several systems suffer from a "buffer overflow error", when extremely long addresses are received. The internal buffers receiving the addresses do not check for length and allow their buffers to overflow causing the applications to crash. Hostile hackers use this fault to trick the computer into running a malicious program in its place.

Everything has bugs Bug lists

Summary Programming is hard –Have to thoroughly understand the task –Have to anticipate all possibilities –Code is written at a fairly primitive level –Is impossible to anticipate what users might do Programming languages allow the user to use tools to build things The cost of a bug can be very large There is no Moore’s Law for software.

Where are we We’ve built a computer We’ve looked at operating systems We’ve looked at the network We’ve built programs –And looked under the hood

What’s next One more piece of networking –Sharing files, sharing cycles, distributed computing Algorithms –Ideas of how to design processes Complexity theory –Undecidable problems –Unsolvable (in practice) problems Applications of hard problems Social impacts –Digital rights management –Artificial intelligence