14
Introduction to Programming

Introduction to Programming

  • Upload
    jagger

  • View
    21

  • Download
    0

Embed Size (px)

DESCRIPTION

Introduction to Programming. Programming. Process of implementing a solution to a problem in a computer language Writing Testing Debugging Maintaining. Central Processing Unit. MEMORY. 76. Register A. Instr Addr. 1: SET A,10 2: READ B 3: ADD A,B 4: WRITE A …. 1. 30. Register B. - PowerPoint PPT Presentation

Citation preview

Page 1: Introduction to Programming

Introduction to Programming

Page 2: Introduction to Programming

ProgrammingProcess of implementing a solution to a problem

in a computer languageWritingTestingDebuggingMaintaining

Page 3: Introduction to Programming

Central Processing Unit

CPU

1: SET A,102: READ B3: ADD A,B4: WRITE A ….

MEMORY1

Instr Addr

76

30

Register ARegister B

The CPU fetches an instruction using the instruction address register, and then executes the that instructions, and then prepares for the next instruction

Page 4: Introduction to Programming

Instructions Instructions to a CPU are simple

Must be “executed” by hardware Encoded as numbers Math: Add, subtract, compare values I/O: read, write Memory: load/store

Execution in hardware = designing a circuit using “logic gates” : AND,OR,NOT and combining them together in a circuit

This is done by Electrical and Computer Engineers

Page 5: Introduction to Programming

Sequential ExecutionProcessors execute instructions one-by-oneThe instruction address is updated to point to

the next instructionWhen we write code, we expect one instruction

to be followed sequentially by the next We can choose a different instruction to be next,

but to do so, we have to update the instruction register in a special way

Page 6: Introduction to Programming

State of the MachineThe state of the machine

The contents of the memory and machine registers at a specific point in time

Instructions change the state of the machine Instructions have a predictable change on the

state of the machine

Programming is about finding a sequence of instructions that will change from one state of the machine to a desired state of the machine.

Page 7: Introduction to Programming

Early ProgramsEarly programmers wrote in Machine Language

Instructions were manually encoded as numbers

Each instruction was dialed in by flipping switches, and connecting input and output of different units.

ENIAC (from Wikipedia)

Page 8: Introduction to Programming

Assembly LanguageAssembly Language

A human readable version of machine language Still writing code directly for the machine

Assembly still used forcertain critical sections of codewhere performance matters.

Requires years of training andexpertise to be a goodassembly language programmer.

Page 9: Introduction to Programming

Early LanguagesFORTRAN

FORTRAN was an early language (1950’s)

A Compiler converts the FORTRAN code into Assembly Language, and theAssembler converts to Machine Language.

Page 10: Introduction to Programming

Mid-Level LanguagesC Language

C is a mid-level language (1970’s)

Compiler still translates to machine language – but the compiler does more work thanin the older languages – so the source code is a little more readable.

Page 11: Introduction to Programming

High-Level LanguagesSQL is a high-level language

Instructions are interpreted as commands to a database engine – and one instruction in SQL can generate millions of machine language instructions.

The problem with high level languages is that they limit what we can do with the machine – if the language doesn’t support it we cannot do it.E.g. cannot display graphics with SQL commands

Page 12: Introduction to Programming

Object Oriented Object Oriented Programming (OOP)

A style of programming that organizes code and data together In languages like C, there is code, and there is data;

and they can be treated separately. Very difficult to maintain as the project grows large

OOP organizes things into classesclasses define the data that are stored thereclasses define the operations on the dataobjects are instances of a classThis concept helps to quickly organize code and

create high quality systems

Page 13: Introduction to Programming

OOP LanguagesC++ is an OOP language

Page 14: Introduction to Programming

Other Languages

LISP

Smalltalk

C#