* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download SIT102 Introduction to Programming
Logic programming wikipedia , lookup
Falcon (programming language) wikipedia , lookup
Stream processing wikipedia , lookup
Functional programming wikipedia , lookup
Go (programming language) wikipedia , lookup
Programming language wikipedia , lookup
Abstraction (computer science) wikipedia , lookup
Object-oriented programming wikipedia , lookup
Parallel computing wikipedia , lookup
Assembly language wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
SIT102 Introduction to Programming After working through this session you should: • Understand the relationships between operating systems, their user interfaces, and programs; • Understand the difference between low-level and high-level code; and • Understand that code must be converted to machine code, by a compiler or interpreter, in order to run that code on a computer. SIT102 Introduction to Programming Lecture 1, Page 1 Computer and Computer Science: Definition A computer is an electronic device, which can input, process, and output data. input processing output • A computer is a machine that stores data, interact with devices, and execute programs (provides computing capabilities to its users). A computer Science is the discipline that seeks to build a scientific foundation for such topics as computer design, computer programming, information processing, and algorithmic solutions of problems. SIT102 Introduction to Programming Lecture 1, Page 2 Major Components of a Computer System A computer system consists of two main parts: hardware and software. Hardware is the electronic and mechanical parts of a computer system. Software is the data and the computer programs of a computer system. SIT102 Introduction to Programming Lecture 1, Page 3 1-3 Computer Hardware Computer hardware is divided into three major Components: 1. The Central Processing Unit (CPU) 2. Computer memory 3. Input/Output (I/O) devices Basic hardware components SIT102 Introduction to Programming Lecture 1, Page 4 CPU The CPU is the "brain" of the computer system. It does the fundamental computing within the system It directly or indirectly controls all the other components The CPU has a limited storage capacity. It relies on memory to hold data and programs and to save results. The CPU consists of: 1. The Arithmetic and Logic Unit (ALU). 2. The Control Unit (CU). 3. Registers. The CPU components are connected by a group of electrical wires called the CPU bus. SIT102 Introduction to Programming Lecture 1, Page 5 CPU The CPU is connected to memory and I/O devices by the System bus The System bus consists of: Address-, Control- and Data-buses. PC: Program Counter Register MAR: Memory Address Register MDR: Memory Data Register SIT102 Introduction to Programming Lecture 1, Page 6 Fetch Decode Execute Cycle The CPU continuously transfers data to and from the primary memory Data transfer is done in units called instructions or words When a computer is switched on, the CPU continuously goes through a process called fetch-decode-execute cycle: The Control Unit fetches the current instruction from memory, decodes it and instructs the ALU (Arithmetic Logic Unit) to execute the instruction. The execution of an instruction may generate further data fetches from memory The result of executing an instruction is stored in either a register or RAM SIT102 Introduction to Programming Lecture 1, Page 7 Fetch-Decode-Execute Cycle Instruction Cycle Control Unit 1 Fetch Decode 2 CPU RAM Execution Cycle Store 4 3 Execute Arithmetic/Logic Unit SIT102 Introduction to Programming Lecture 1, Page 8 Software • Software – a group of programs • Program – a specific set of instructions to the computer to perform a task • Programmer – a person who writes a program SIT102 Introduction to Programming Lecture 1, Page 9 Software Software is the programs and data that a computer uses. Programs are lists of instructions for the processor Data can be any information that a program needs: character data, numerical data, image data, audio data, etc. Both programs and data are saved in computer memory in the same way. Computer software is divided into two main categories: 1. Systems software 2. Applications software System software manages computer resources and makes computers easy to use. An applications software enables a computer to be used to do a particular task. SIT102 Introduction to Programming Lecture 1, Page 10 Computer Software Types of software Software SIT102 Introduction to Programming Lecture 1, Page 11 Software Application Programs Word processors Game programs Spreadsheets Data base systems Graphics programs Web browsers SIT102 Introduction to Programming Systems Programs Operating system. Networking system. Programming language software. Web site server. Data backup. Lecture 1, Page 12 Data representation • Represented by a combination of eight binary digits (1s and 0s) • ASCII – American Standard Code for Information Interchange SIT102 Introduction to Programming Lecture 1, Page 13 ASCII Table 14 ASCII representation • From 00000000 to 11111111; each assigned to a unique character. • An integer – is stored in memory in its binary equivalence – read as character using its ASCII character The number 1 can be stored in many ways depending on how the data is interpreted by a given program. Character 1 : 00110001 Integer 1 : 00000001 SIT102 Introduction to Programming Lecture 1, Page 15 Programming Languages • Computer program: data and instructions used to operate a computer and produce a specific result • Programming: writing instructions in a language that the computer can respond to and that other programmers can understand • Programming language: set of instructions that can be used to construct a program • Source programs/Source code: Programs written in a computer language SIT102 Introduction to Programming Lecture 1, Page 16 Three General Types of Programming Languages: • 1940s – Machine Languages • 1950s – Symbolic/Assembly languages • 1960s – High-Level Languages • Note: Machine and assembly languages are low-level languages because they both use instructions that are directly tied to one type of computer – A natural language of a computer, machine dependent – the only language that can be understood and processed directly by computer – use of a series of mnemonics to represent commonly used instructions – E.g. COBOL, FORTRAN, C, Java SIT102 Introduction to Programming Lecture 1, Page 17 History of languages SIT102 Introduction to Programming Lecture 1, Page 18 Machine Language • Executable program: program that can operate a computer • Executable programs are written with binary numbers, which is a computer’s internal language (machine language) – An example of a simple machine language program containing two instructions is: 11000000000000000001000000000010 11110000000000000010000000000011 SIT102 Introduction to Programming Lecture 1, Page 19 Assembly Language • Assembly language: uses the substitution of wordlike symbols for the opcodes, and decimal numbers and labels for memory addresses EG: z = x + y In assembly Mov ax, x Add ax, y Mov z, ax In C# z = x + y; SIT102 Introduction to Programming Lecture 1, Page 20 Assembly Language (continued) SIT102 Introduction to Programming Lecture 1, Page 21 Earlier high-level programming languages • COBOL (Common Business Oriented Language) – used primarily for business processing • FORTRAN (Formula Translation) – primarily perform mathematical calculations SIT102 Introduction to Programming Lecture 1, Page 22 Later High-Level Programming Languages • PL/I, BASIC, Pascal, Prolog, C, Ada • C++, Visual Basic, C# • HTML, Java SIT102 Introduction to Programming Lecture 1, Page 23 Writing, Editing, Compiling and Linking Programs • Step1 – Write and edit programs • Step2 – Compile programs – Translate source file into machine language – The output produced by the compiler is called an object program (machine language version of the source code) • Step3 – Linking Programs - combines additional machine language code with the object program to create a final executable program SIT102 Introduction to Programming Lecture 1, Page 24 Writing, Editing, Compiling and Linking Programs Type in a program The object code Editor Linker Language syntax The source program An executable program Compiler SIT102 Introduction to Programming Lecture 1, Page 25 Procedural and Object-Oriented Languages • Structured language: high-level procedural language (e.g., C) that enforces structured procedures • Object-oriented languages: languages with object orientation such as C++, Java, Visual Basic, and C# SIT102 Introduction to Programming Lecture 1, Page 26 The Making of A Quality Program 1. Readability • understandable, with comments and documentations, using conventions like name of variables and indentations 2. Modularity • problems divided into sub-problems and assembled in a logical order 3. Efficiency • runs faster and smaller size of program SIT102 Introduction to Programming Lecture 1, Page 27 The Making of A Quality Program (cont.) 4. Robustness • • Be able to handle all situations in a graceful manner Not to crash in unexpected situations or go to infinite loops 5. Usability • correct, meets the end-user requirement SIT102 Introduction to Programming Lecture 1, Page 28