Programming Languages
- Binary
- We use decimal, or base 10
- Each digit in the system represents a power of 10.
- 486.23 = 4 * 100 + 8 * 10 + 6 + 2/10 + 3/100
- 486.23 = 4 * 10 2 + 8 * 101+6*100
+ 2 * 10-1 + 3 * 10 -2
- This requires 10 digits (0,1,2,3,4,5,6,7,8,9)
- This is diffacult to represent electronicaly
- So in computers, we use base 2, or binary
- Each digit represents a power of 2
- The only digits are 1 or 0
- 11010 = 1 * 16 + 1 * 8 + 0 * 4 + 1 * 2 + 0
- 11010 = 1 * 24  + 1 * 23 + 0 * 22 + 1 * 21 + 0 * 20
- We encode, or represent in binary, all data used in the computer.
- Characters are encoded using ascii (a = 01010001).
- Integers are their binary representation.
- Floating point (real numbers) are much more complicated.
- We won't have to worry about this too much at this point.
- But that is why we always encounter powers of two (1024)
- Levels of programming languages
- Machine Language
- Assembly Language
- High Level Language
- Interpreters
- Compilers
- Source Code
- Machine Code
- Executable
- Portable
- Just like a with human language, each programmer develops their own
style.
- Based on the rules
- And the norms (what people tell us we must do, but can't enforce)
- What we see others do.
- What can a computer do?
- Move data around
- Receive input, and produce output
- Compare two values and see if they are equal or not
- Perform arithmatic.
- A programming language supports these features.
- Just like following a recipie, we must do some things in order.
- This is the flow of control or sequence.
- Sometimes we break a recipie down
- To make a pie, make a crust and make the filling
- We do this with programs as well, they are called subprograms
- Sometimes we repeat things
- kneed the dough for 5 minuets
- We do this with programs as well, we call it a loop
- Decisions
- If the dough is too stickey, add more flower
- This is called selection.
- These in general are called control structures.
- Consider balencing your checkbook:
- We have a starting balence
- We have a series of deposit slips and checks
- What do we do?