1 CPSC 185 Introduction to Computing The course home page

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Advertisements

Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
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.
Introduction to a Programming Environment
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Compiler Construction
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
Topic 1: Introduction to Computers and Programming
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Course: Introduction to Computers
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
1 Chapter-01 Introduction to Computers and C++ Programming.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 18: 0xCAFEBABE (Java Byte Codes)
PROCESSING Designing and developing a program. Objectives Understand programming as the process of writing computer instructions that achieve a goal Understand.
Programming Languages Generations
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Course Introduction C++ An Introduction to Computing.
THE PROCESS OF WRITING SOFTWARE Python: System Engineering 1.
1 Intro to Computer Science I Chapter 1 Introduction to Computation Algorithms, Processors, and Programs.
High-level Languages.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
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.
Laboratorio di Calcolo I Docente: prof. Berardi (Dip. Informatica) Lezione introduttiva su Computing ed esercitazioni di Unix/Linux tenute da Fabrizio.
Introduction CS 104: Applied C++ What is Programming? For some given problem: __________ a solution for it -- identify, organize & store the problem's.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Tranlators. Machine Language The lowest-level programming languageprogramming language Machine languages are the only languages understood by computers.languagescomputers.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Introduction to Computer Systems and the Java Programming Language.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Introduction to Computer and Programing Thanachat Thanomkulabut.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
© Calvin College, When we prepare a program, the experience can be just like composing poetry or music … My claim is that it is possible to write.
PROGRAMMING LANGUAGES
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
Introduction 1 (Read Chap. 1) What is Programming? For some given problem: design a solution for it -- identify, organize & store the problem's data --
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Sahar Mosleh California State University San MarcosPage 1 Assembly language and Digital Circuit By Sahar Mosleh California State University San Marcos.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Introduction to Computer and Programing Thanachat Thanomkulabut.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Compilers and Interpreters
Chapter 1 An Overview of Computers and Programming Languages.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Programming Languages
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
CSCI-235 Micro-Computer Applications
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
CS216: Program and Data Representation
Microprocessor and Assembly Language
C Prog. To Object Code text text binary binary Code in files p1.c p2.c
Introduction to Algorithm Design
Assembly Language Programming II: C Compiler Calling Sequences
Lecture 19: 0xCAFEBABE (Java Byte Codes) CS201j: Engineering Software
CMP 131 Introduction to Computer Programming
1.3.7 High- and low-level languages and their translators
Compiler Construction CS 606 Sohail Aslam Lecture 1.
Presentation transcript:

1 CPSC 185 Introduction to Computing The course home page

2 What is Programming? Programming: designing, writing and maintaining a program. What is a program? —a collection of statements that —specify the steps taken to solve a problem, and are —written in a programming language — a language that the computer can understand. Sec. 1.2

3 Start Repeatedly do the following: 1. This 2. That 3. The Next Thing 4. If it’s time to quit, stop this repetition Output the results of This and That Stop What About OOP (Object-Oriented Programming)? Object- oriented program: a collection of object interactions that solve a problem

Java is an OOP language —Uses objects to carry out the tasks —Sends messages to the objects to perform the tasks —Objects interact with each other to do the tasks —An actual object is called an instance of a class (the declaration of or blueprint for the object) Sec. 1.1: Brief History of OOP & Java

5 What kinds of statements do computers understand? A computer only understands a specially designed machine language. Machine language statements are: – Stored in a computer’s memory, which is a sequence of binary digits (bits): 0(a switch in the “off” position) 1(a switch in the “on” position) – Retrieved from memory and executed one at a time Sec. 0.3

6 Machine Language (ML) Example (hypothetical)

7 ML Example (hypothetical) instruction #1 OP-Codefirst operandsecond operand

8 ML Example (hypothetical) instruction #1 #4 #3 #2

9 A Real ML Example SPARC executable machine code … this goes on for another 1600 lines... Intel Pentium executable machine code … this goes on for another 74 lines... int main() { int x, y; x = 1; y = x + 2; return 0; }

Early Computers required a programmer to write in machine language: –It was easy to make mistakes. –The mistakes were hard to find. –The resulting program was not portable. As a result, programming in machine language was very difficult.

Assembly Language To make programming easier, you can: Devise a set of abbreviations (mnemonics) corresponding to the machine language instructions. Create a program to translate them into machine language MOVx,ACC ADD2,ACC STOACC,y Assembler

12 The Real Example Intel Pentium assembly language: _main: pushl %ebp movl %esp,%ebp subl $24,%esp call ___main movl $1,-4(%ebp) movl -4(%ebp),%eax addl $2,%eax movl %eax,-8(%ebp) xorl %eax,%eax jmp L2.align 4 L2: movl %ebp,%esp popl %ebp ret SPARC assembly language: main: save%sp, -120, %sp mov1, %o0 st%o0, [%fp-20] ld[%fp-20], %o0 add%o0, 2, %o1 st%o1, [%fp-24] mov0, %i0 b.LL2 nop mov0, %i0 b.LL2 nop.LL2: ret restore

13 The Real Example Intel Pentium assembly language: _main: pushl %ebp movl %esp,%ebp subl $24,%esp call ___main movl $1,-4(%ebp) movl -4(%ebp),%eax addl $2,%eax movl %eax,-8(%ebp) xorl %eax,%eax jmp L2.align 4 L2: movl %ebp,%esp popl %ebp ret SPARC assembly language: main: save%sp, -120, %sp mov1, %o0 st%o0, [%fp-20] ld[%fp-20], %o0 add%o0, 2, %o1 st%o1, [%fp-24] mov0, %i0 b.LL2 nop mov0, %i0 b.LL2 nop.LL2: ret restore Intel Assembler Sun Assembler

14 Using mnemonics is more natural than binary. +Much easier to read programs +Much easier to find and fix mistakes –Still not portable to different machines –Still hard to write, read, and debug programs

15 High Level Languages To improve on assembly language: Devise a set of statements that are closer to human language and methods of writing expressions called a high level language (HLL) and Create a program to translate them into ML: –Compiler –Interpreter

16 Compilers (Note that an assembler translates one AL seatement into one ML statement; a HLL compiler translates one HLL statement into multiple ML statements.) A compiler translates an entire program into machine language x = 1; y = x+2; Compiler

17 The Real Example int main() { int x, y; x = 1; y = x + 2; return 0; } Intel C++ compiler Sun C++ compiler

Interpreters An interpreter decodes each individual instruction and then executes it: –development is easier –execution is slower helloPRINT “hello” Interpreter

Compilation + Interpretation Languages can combine compilation and interpretation. Compiler class intro { public static void main (String args[]) { int x, y; x = 1; y = x + 2; return; } Interpreter for UNIX Interpreter for Windows Interpreter for MacOS class intro extends java.lang.Object { intro(); public static void main(java.lang.String[]); } Method intro() 0 aload_0 1 invokespecial #1 4 return Method void main(java.lang.String[]) 0 iconst_1 1 istore_1 2 iload_1 3 iconst_2 4 iadd 5 istore_2 6 return javac program.java java prog program.java program.class execution Java bytecode

History & Advantages of HLLs History of high-level languages: –Fortran (1957) - the first compiled language –Lisp (1957), BASIC (1964) - interpreted languages –Java (1991) - a compiled/interpreted hybrid With programming in high-level languages: +The programs were much easier to read. +Mistakes were much easier to find and fix. +The programs were (or could be) portable. –Not so simple that just anyone can use them (otherwise this course wouldn't exist)!

21 Virtual Machines Levels: –machine language –assembly language –high-level language Each level is built upon the previous level. You can work at one level of abstraction without understanding the implementation of the lower levels.

22 Objectives in Programming A program should solve a problem: correctly (it actually solves the problem) efficiently (without wasting time or space) readably (understandable by another person) in a user-friendly fashion (in a way that is easy for its user to use).

23 Fredrick P. Brooks, Jr. (1931- ) The joys of programming: We enjoy designing things because we are created in the image of God. The computer is a powerful and rewarding tool to use. The woes of programming: The “mindless” details can be excessively tedious. Products become obsolete too quickly.