A computer is just a machine (the hardware) for executing programs (the software)
Software
Rules the hardware
Programming
The process of creating software
Virtually, anyone can learn how to program computers
Programming
Requires only some grit
Why Learn Programming?
Computers have become commonplace in our modern life
Understanding the strengths and limitations of computers requires some understanding of programming
Programming can be loads of fun!
Programming develops valuable problem-solving skills, especially ones that pertain to analysis, design and implementation
Programmers are in great demand!
Fields where programming is applied
Gene Sequencing and Biotechnology
Smaller, Faster, Cheaper Sensors
Astronomy
Ubiquitous Computing
Hardware Basics
To be a successful programmer, you need to know some details of how computers work
Performance
Efficiency of a program
Memory
Where data and programs are stored
CPU-bound
When a program's performance is limited by the CPU
IO-bound
When a program's performance is limited by input/output operations
Functional View of a Computer
Input Devices
CPU
Main Memory
Output Devices
Secondary Memory
Secondary Memory
Where saved program and data reside, non-volatile storage
Main Memory
Much faster but more expensive than secondary memory, volatile storage
CPU
The "brain" of the computer, can perform arithmetic and logical operations, can directly access main memory but not secondary memory
Input and Output Devices
Keyboard and mouse
Monitor
Input and Output (IO)
Humans interact with computers via input and output devices, information from input devices is processed by the CPU and may be stored in memory, information to be displayed is sent from the CPU to output devices
Program
A sequence of instructions telling the computer what to do
Programming Language
A language that computers can understand, examples are Python, Java, C, and C++
Syntax
The exact form of a structure in a programming language
Semantics
The precise meaning of a structure in a programming language
Machine Language
The very low-level language that computer hardware can only understand
High-Level Language
Languages like Python, Java, C, and C++ that are more human-oriented than machine language
Adding two numbers in machine language
1. Load the number from memory location 2001 into the CPU
2. Load the number from memory location 2002 into the CPU
3. Add the two numbers in the CPU
4. Store the result into location 2003
c = a + b
How addition of two numbers is expressed in a high-level language like Python
Compiler
A complex software that translates a program written in a high-level language into an equivalent program in the machine language
Interpreter
A software that analyzes and executes the source code instruction-by-instruction (on-the-fly) as necessary
Compiling vs. Interpreting
Compiling is a static (pre-execution), one-shot translation
Interpreting is dynamic (happens during execution)
Compiled programs tend to be faster
Interpreted programs lend themselves to a more flexible programming environments (they can be developed and run interactively)
Portability
The advantage that high-level languages have over machine languages, a program written in a high-level language can be run on many different kinds of computers as long as there is a suitable compiler or interpreter
Python programs are said to be portable
Computer
A universal information-processing machine, which can carry out any process that can be described in sufficient detail
Algorithm
A description of the sequence of steps for solving a particular problem
Software
Programs that determine what the hardware (physical machine) can and does accomplish
Basic Functional View of a Computer System
Central Processing Unit (CPU)
Main Memory
Secondary Memory
Input Devices
Output Devices
CPU
The brain of the computer that performs simple arithmetic and logical operations
Main Memory
Where data and programs are stored
Secondary Memory
Where more permanent information is stored
Programming Language
A formal notation used to write programs, has precise syntax (form) and semantics (meaning)
Machine Language
The very low-level language that computer hardware only understands