530 likes | 670 Views
Introduction to Programming. Objectives. Look at why we write programs Describe some things it takes to learn to be a programmer Discuss some important programming tools Investigate how the computer works as it executes a program Describe the steps involved in creating and running a program .
E N D
Objectives Look at why we write programs Describe some things it takes to learn to be a programmer Discuss some important programming tools Investigate how the computer works as it executes a program Describe the steps involved in creating and running a program
Why would you want to learn to program? • The sheer joy of making things – being creative • The pride in making something that is useful to other people • The fascination of solving complex problems • Figuring out how to do something you’ve never done before • Making a dumb machine do smart things • Earning a lot of money • This class is required …
Comment from a student … “I want a career, not just a degree”
“I love those moments, often wee quiet hours of the morning, when you begin to see what is forming... It is like being there at the wheel with the clay in your hands. It is the joy of creating something beautiful, something purposeful, something delightful, something to share... Sharing in the joy of creation, software development can be a means of self-expression where we give substance to our abstract thoughts, ideas, and feelings.”
Learning to program requires • Time • Patience • Good language skills • The ability to think abstractly • Good math skills • The ability to solve problems • Practice – Program, program, program • A sense of curiosity
Learning to Program Takes Time Researchers have shown that learning to do anything well (playing the piano, painting, playing tennis, etc) takes about 10 years. Learning to be a good programmer is no different. To become proficient at programming Practice Practice Practice …
Math Skills are Important The rise of mathematics is heating up the job market for luminary quant's, especially at the Internet powerhouses where new math grads land six-figure salaries and rich stock deals. Tom Leighton, an entrepreneur and applied math professor at Massachusetts Institute of Technology, says: "All of my students have standing offers at Yahoo! and Google. Top mathematicians are becoming a new global elite. It's a force of barely 5,000, by some guesstimates, but every bit as powerful as the armies of Harvard University MBAs who shook up corner suites a generation ago. Business Week Cover Story January 23, 2006
What do Programmers Do? They talk to their customers They talk to their peers They discuss problems They think a lot They write a lot They design solutions to problems They write code They debug code They refactor code They test code They document code They fix code . . .
Programming Tools The computer The operating system The code editor The compiler The debugger Integrated Development Environment Problem solving skills Language skills
The Computer Data Segment CPU Program Counter Code Segment Instruction Register Memory General Purpose Registers Status Registers Stack Arithmetic and Logic Unit Heap
The Computer Data Segment Program Counter Code Segment Instruction Register General Purpose Register Status Registers Stack Arithmetic and Logic Unit Heap
The Computer Watch how the computer adds two numbers together … Data Segment Program Counter Code Segment Instruction Register General Purpose Register Status Registers Stack Arithmetic and Logic Unit Heap
The Computer The program to be executed is stored in the code segment. The data is stored in the data segment. The program counter points to the next instruction to be executed. address 24 28 32 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 60 Code Segment Instruction Register Register r1 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 60 Code Segment Instruction Register Register r1 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 ld r1, 24 Program Counter 60 Code Segment Instruction Register Register r1 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 60 Code Segment Instruction Register ld r1, 24 Register r1 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 64 Code Segment Instruction Register ld r1, 24 Register r1 10 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 64 ld r2, 28 Code Segment Instruction Register ld r1, 24 Register r1 10 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 12 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 64 Code Segment Instruction Register ld r2, 28 Register r1 10 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 68 Code Segment Instruction Register ld r2, 28 Register r1 10 12 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 68 Code Segment add r1, r2 Instruction Register ld r2, 28 Register r1 10 12 Register r2 Stack Arithmetic and Logic Unit Heap
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 68 Code Segment Instruction Register add r1, r2 10 Register r1 10 12 12 Register r2 Stack 22 Heap Arithmetic and Logic Unit
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 68 Code Segment Instruction Register add r1, r2 Register r1 10 12 Register r2 Stack 22 Heap Arithmetic and Logic Unit
The Computer address 24 28 32 10 10 12 -- Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 72 Code Segment Instruction Register ld r1, 24 sto r1, 32 Register r1 22 12 Register r2 Stack Heap Arithmetic and Logic Unit
The Computer address 24 28 32 10 10 12 Data Segment 60 64 68 72 ld r1, 24 ld r2, 28 add r1, r2 sto r1, 32 Program Counter 72 Code Segment Instruction Register sto r1, 32 22 Register r1 22 12 Register r2 Stack Heap Arithmetic and Logic Unit
The Operating System Manages the memory in the computer Manages how and when programs are executed Manages the devices attached to the computer and lots of other stuff …
The code editor provides a way for The programmer to create and edit the source codetext for his or her program. Editors provide tools to cut and paste source Code text, move between source code files, and do many other editing tasks.
The Compiler static void Main( ) { int a = 5; int b = 27; . . . source code compiler
Xvnvyi Lklil Hjfkkfol98 Op09kij Plollk Etc … source code compiler Intermediate Language
code segment data segment stack segment Interpreter source code compiler Intermediate Language Xvnvyi Lklil Hjfkkfol98 Op09kij Plollk Etc … .exe
program C code segment data segment stack segment program A program B loader the heap is left over memory, not being used by any program. It is managed by the O/S. the heap reserved for operating system