Download presentation
Presentation is loading. Please wait.
Published byAsher Daniels Modified over 9 years ago
1
Introduction to Programming ICS2O Findlay
2
Learning Goals We will learn The definitions of a computer, program and programming language. The different types of programs. The difference between source code and machine code. The difference between an interpreter and a compiler.
3
Programming Robots Has anyone seen a robot or touched one? Does a robot really “hear” and “understand” what you say? Robots operate off “instructions”, specific sets of things that they have been preprogrammed to do. In order to accomplish a task, a robot needs to have a series of instructions (sometimes called an algorithm) that it can run. In groups of 3 you will build a program on paper that a robot will use to assemble a pattern of cups. Decide on two people in your group who will be your programmers, while the third will be your robot. You may only use the symbols to the right in your program. Teacher Example
4
Programming Robots
5
What is a computer? A program? A computer is a general purpose device that can be programmed to carry out a set of arithmetic or logical operations automatically. Since a sequence of operations can be readily changed, the computer can solve more than one kind of problem. A program is a plan that lays out actions to achieve a goal.
6
Which of the following is most like a program? 1) Buy cookie dough 2) Lay out cookie dough on tray in 5 cm diameter circular goodness 3) Preheat oven to 425 degrees Fahrenheit 4) Place cookie tray with cookies in oven for 15 minutes 5) Remove tray and devour 01001010101010010111101010101001010110100101101010010 10101010101010101011011011010100101010110101010101001 01010110111010010101010110011010101010101001101010101
7
Why was the recipe more like a program than the binary? It gave step-by-step actions starting from the beginning to the end. After finishing the program you achieve a desired goal: devouring delicious cookies! The binary is just a bunch of numbers, not a real program. Try this with a partner! Objective: To put on a jacket. What do we notice from this activity?
8
Types of Programs Application ProgramsSystems Programs Programs that people use to get their work done. Word Processors Game programs Spreadsheets Database systems Graphics programs Web browsers Programs that keep the hardware and software running together smoothly. Operating system Networking system Programming language software Website server Data backup
9
What is a programming language? A language that tells machines/computers how to perform computations. They can be used to control machines by defining the machine’s behaviour. Each language has a set of algorithms which provide the instructions of a program. What are some examples of programming languages?
10
Types of Code: Source Code What is source code? This is the code that you write. It usually looks like English words. Example put “Hello World!” Source code, like any language, follows a set of grammatical rules. In programming we call this set of rules the syntax. Breaking these rules will cause the program to not function. Like writing a poorly structured sentence.
11
Source Code Example What is it like? Telling someone in English to stop talking. Why is this like source code? We are giving instructions to do something. We are not physically doing the instructions. The instructions must be translated into physical actions.
12
Source Code Example Telling someone in English to stop talking. We don’t Tell them they have to close their mouth Tell them how to stop moving muscles, etc. Their brain should Translate the English words in to meaning That meaning should translate into brain signals going to muscles in mouth to stop moving, stop making sounds from throat, etc.
13
Source Code Source code is meant to be read by people Easy to understand for computer scientists, and mostly understandable to non- techies Source code itself cannot be run as a program by the computer It must be translated into machine code Why do we have source code? The alternative is machine code
14
Types of Code: Machine Code What is machine code? This is the code that the machine uses It is just binary (0, 1) Different processors understand different assembly instructions Most personal computers use x86 instructions New AMD processors also use AMD-64 New Intel processors also use IA-64 PlayStation3, Xbox 360, Wii, DS all use different assembly instructions That is why a Wii game doesn’t work on Xbox 360 That is why a PS3 game doesn’t work on Xbox 360 So how are some games released on multiple consoles?
15
Machine Code What is it like? The signals that your brain sends to your body to do something Brain goes through memory to find the meaning of “stop talking” It keeps on repeating the process until it finds it and then acts on the meaning It is not like: A vague description of what to do…it is exact Down to the bits of memory to use
16
Source vs Machine Code The source code that you write gets converted into machine code The source code put “Hello World!” The machine code 100010101011111011001000100100111110111 101011001011111101110101001010101010111 000001111111101101010101010101010101101
17
What is this “magic”? There are two types of programs that can be used to convert source code to machine code The “magic” Compilers A software program (or programs) that takes your entire source code file(s) and converts it to machine code all at once It results in files that can be converted into executable (exe) files that you run Interpreters A software program (or programs) that takes your source code file and converts it to machine code one line at a time You need to run your program inside of another program E.g., most Visual Basic code must be run from inside of the Visual Basic integrated development environment (IDE)
18
Compilers vs Interpreters Advantages of Compilers (over Interpreters) Advantages of Interpreters (over Compilers) The program runs faster You only need to compile it one time after you are finished Users do not need to install the code interpreter on their machine (try running your old interpreted Basic projects on someone’s computer) Programs start faster since they only need to look at one line at a time (no need to compile the entire program first then run) Finding errors is easy because you know exactly which line caused the error Turing is a compiled language
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.