CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.

Slides:



Advertisements
Similar presentations
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Systems Software.
Programming Types of Testing.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Programming Our First Java Program Yingcai Xiao. What to Do Set up for Java Programming Write our first Java Program with IDE Write our first Java Program.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Chapter 1 Introduction to C Programming. 1.1 INTRODUCTION This book is about problem solving with the use of computers and the C programming language.
Chapter 10 Application Development. Chapter Goals Describe the application development process and the role of methodologies, models and tools Compare.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Systems Software Operating Systems.
Computer Science 101 Introduction to Programming.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
1 Chapter-01 Introduction to Computers and C++ Programming.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Computer Software. Evolution of Programming Languages Machine Languages Assembly Languages High-Level Languages Fourth-Generation Languages.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Systems Software & Operating systems
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Tranlators. Machine Language The lowest-level programming languageprogramming language Machine languages are the only languages understood by computers.languagescomputers.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
CISC105 General Computer Science Class 1 – 6/5/2006.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 2.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Lecture (8) Programming Design Dr. Emad Elsharkawy Eng- Omar Salah Dr:Emad Elsharkawy 1 Saturday, 13 February 2016.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Chapter 1 An Overview of Computers and Programming Languages.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Computer Software.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Computer Software 1.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Chapter 1 Introduction 2nd Semester H
Topic 2: Hardware and Software
Chapter 1 Introduction.
Introduction to Compiler Construction
Operating System Interface between a user and the computer hardware
CSCI-235 Micro-Computer Applications
Chapter 1 Introduction.
Java programming lecture one
Unit# 8: Introduction to Computer Programming
TRANSLATORS AND IDEs Key Revision Points.
Translators & Facilities of Languages
Computers: Hardware and Software
Introduction CSC 111.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CMP 131 Introduction to Computer Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming language translators
Presentation transcript:

CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab

Outline of Topics Hardware/Software interface –Layers of the Machine –Kinds of Software Computer Languages Syntax, Semantics, Grammars What happens to your program? –Compilation, Linking, Execution –Program errors Compilation vs. Interpretation etc.

Software Categories System SW –Programs written for computer systems Compilers, operating systems, … Application SW –Programs written for computer users Word-processors, spreadsheets, & other application packages

A Layered View of the Computer Machine with all its hardware System Software Compilers, Interpreters,Preprocessors, etc. Operating System, Device Drivers Application Programs Word-Processors, Spreadsheets, Database Software, IDEs, etc…

Operating System (OS)  Provides several essential services: –Loading & running application programs –Allocating memory & processor time –Providing input & output facilities –Managing files of information

Programs Programs are written in programming languages –PL = programming language –Pieces of the same program can be written in different PLs Languages closer to the machine can be more efficient As long as they agree on how to communicate A PL is –A special purpose and limited language –A set of rules and symbols used to construct a computer program –A language used to interact with the computer

Computer Languages –Machine Language Uses binary code Machine-dependent Not portable Assembly Language –Uses mnemonics –Machine-dependent –Not usually portable High-Level Language (HLL) –Uses English-like language –Machine independent –Portable (but must be compiled for different platforms) –Examples: Pascal, C, C++, Java, Fortran,...

Machine Language The representation of a computer program which is actually read and understood by the computer. –A program in machine code consists of a sequence of machine instructions. Instructions: –Machine instructions are in binary code –Instructions specify operations and memory cells involved in the operation Example: OperationAddress

Assembly Language A symbolic representation of the machine language of a specific processor. Is converted to machine code by an assembler. Usually, each line of assembly code produces one machine instruction (One-to-one correspondence). Programming in assembly language is slow and error- prone but is more efficient in terms of hardware performance. Mnemonic representation of the instructions and data Example: Load Price AddTax StoreCost

High-level language A programming language which use statements consisting of English-like keywords such as "FOR", "PRINT" or “IF“,... etc. Each statement corresponds to several machine language instructions (one-to-many correspondence). Much easier to program than in assembly language. Data are referenced using descriptive names Operations can be described using familiar symbols Example: Cost := Price + Tax

Syntax & Semantics Syntax: –The structure of strings in some language. A language's syntax is described by a grammar. –Examples: Binary number = | = 0 | 1 Identifier = { | } = a | b |... | z <digit = 0 | 1 |... | 9 Semantics: –The meaning of the language

Syntax & Grammars Syntax descriptions for a PL are themselves written in a formal language. –E.g. Backus-Naur Form (BNF) The formal language is not a PL but it can be implemented by a compiler to enforce grammar restrictions. Some PLs look more like grammar descriptions than like instructions.

Compilers & Programs Compiler –A program that converts another program from some source language (or high-level programming language / HLL) to machine language (object code). –Some compilers output assembly language which is then converted to machine language by a separate assembler. –Is distinguished from an assembler by the fact that each input statement, in general, correspond to more than one machine instruction.

Compilation into Assembly L Compiler Assembler Source Program Assembly Language Machine Language

Compilers & Programs Source program –The form in which a computer program, written in some formal programming language, is written by the programmer. –Can be compiled automatically into object code or machine code or executed by an interpreter. –Pascal source programs have extension ‘.pas’

Compilers & Programs Object program –Output from the compiler –Equivalent machine language translation of the source program –Files usually have extension ‘.obj’ Executable program –Output from linker/loader –Machine language program linked with necessary libraries & other files –Files usually have extension ‘.exe’

What is a Linker? A program that pulls other programs together so that they can run. Most programs are very large and consist of several modules. Even small programs use existing code provided by the programming environment called libraries. The linker pulls everything together, makes sure that references to other parts of the program (code) are resolved.

Running Programs Memory Input Data Program Output Machine language program (executable file) Data entered during execution Computed results C P U Steps that the computer goes through to run a program:

Program Execution Steps taken by the CPU to run a program (instructions are in machine language): 1.Fetch an instruction 2.Decode (interpret) the instruction 3.Retrieve data, if needed 4.Execute (perform) actual processing 5.Store the results, if needed

Program Errors Syntax Errors: –Errors in grammar of the language Runtime error: –When there are no syntax errors, but the program can’t complete execution Divide by zero Invalid input data Logical errors: –The program completes execution, but delivers incorrect results –Incorrect usage of parentheses

Compilation Compiler Target Program Source Program Target Program InputOutput Compiler translates source into target (a machine language program) Compiler goes away at execution time Compiler is itself a machine language program, presumably created by compiling some other high-level program Machine language, when written in a format understood by the OS is object code

Interpretation Interpreter Source Program Input Output The interpreter stays around during execution It reads and executes statements one at a time

Compilation vs. Interpretation Compilation: –Syntax errors caught before running the program –Better performance –Decisions made once, at compile time Interpretation: –Better diagnostics (error messages) –More flexibility –Supports late binding (delaying decisions about program implementation until runtime) Can better cope with PLs where type and size of variables depend on input –Supports creation/modification of program code on the fly (e.g. Lisp, Prolog)

Mixture of C & I Translator Source Program Intermediate Program VM Intermediate Program Input Output Many programming languages implement this Interpreter implements a Virtual Machine (VM).

JAVA Compiler Interpreter Java bytecode ML For flexibility: Just In Time (JIT) compiler translates bytecode into ML just before execution For portability:

Homework/Contact While I’m learning to use the folder stuff, by tomorrow some time you will be able to find slides from this week attached to Look for the link to IIHEM at the bottom of the page. Read Chapter 1, Sections 1 & 2 of your textbook carefully. Think of 3 tasks you have encountered in your studies that you would like to write a program for. Send them mail to me, and questions you might have at: