CS150 - Unit 1 - What Is Programming
CS150 - Unit 1 - What Is Programming
What Is Programming
Computers are so widespread in our society because they have three advantages over us humans.
First, computers can store huge amounts of information. Second, they can recall that information
quickly and accurately. Third, computers can perform calculations with lightning speed and
perfect accuracy.
The advantages that computers have over us even extend to thinking sports like chess. In 1997,
the computer Deep Blue beat the world chess champion, Garry Kasparov, in a chess match. In
2003, Kasparov was out for revenge against another computer, Deep Junior, but only drew the
match. Kasparov, while perhaps the best chess player ever, is only human, and therefore no
match for the computer’s ability to calculate and remember prior games.
However, we have one very significant advantage over computers. We think on our own, while
computers don’t, at least not yet anyway. Indeed, computers fundamentally are far more brawn
than brain. A computer cannot do anything without step-by-step instructions from us telling it
what to do. These instructions are called a computer program, and of course are written by a
human, namely a computer programmer. Computer programs enable us to harness the
computer’s tremendous power.
Programming is problem-solving
Essentially, a program tells the computer how to solve a specific problem. Because the world is
full of problems, the number and variety of programs that people can write for computers is
practically endless.
But to tell a computer how to solve one big problem, you usually must tell the computer how to
solve a bunch of little problems that make up the bigger problem. If you want to make your own
video game, for example, you need to solve some of the following problems:
Determine how far to move a cartoon figure (such as a car, a spaceship, or a man) on-screen
as the user moves a joystick.
Detect whether the cartoon figure bumps into a wall, falls off a cliff, or runs into another
cartoon figure on-screen.
Make sure that the cartoon figure doesn't make any illegal moves, such as walking through a
wall.
Draw the terrain surrounding the cartoon figure and make sure that if the cartoon figure
walks behind an object such as a tree, the tree realistically blocks the figure from sight.
Determine whether bullets that another cartoon figure fires are hitting the player's cartoon
figure. If so, determine the amount of damage, how it affects the movement of the damaged
cartoon figure, and how the damage appears on-screen.
The simpler the problem is that you need to solve, the more easily you can write a program that
tells the computer how to work. A program that displays a simple Ping-Pong game with two
stick paddles and a ball is much easier to write than a program that displays World War II fighter
airplanes firing machine guns and dropping bombs on moving tanks while dodging anti-aircraft
fire.
A microprocessor, which is the heart of a computer, is very primitive but very fast. It takes
groups of bits and moves around their contents, adds pairs of groups of bits together, subtracts
one group of bits from another, compares a pair of groups, etc. Inside a microprocessor, at a very
low level, everything is simply a bunch of switches, also known as bits - things that are either on
or off!
ASCII in in in in
Character Binary Octal Decimal Hex
Space 00100000 040 32 20
( 00101000 050 40 28
) 00101001 051 41 29
* 00101010 052 42 2A
0 00110000 060 48 30
1 00110001 061 49 31
2 00110010 062 50 32
9 00111001 071 57 39
A 01000001 101 65 41
B 01000010 102 66 42
C 01000011 103 67 43
Z 01011010 132 90 5A
A 01100001 141 97 61
B 01100010 142 98 62
C 01100011 143 99 63
Z 01111010 172 122 7A
This might look a bit strange but the main point you have to pick up from here is that the computer does
not store data as we do using different characters, rather everything is stored as a bit. You will learn more
about this fact in computer Architecture.
There is a difference between the language that a computer understands and the languages that we use as
humans. So then the question is in which language can we speak to the computer so that it can understand
us?
A program is a set of instructions used by the computer to carry out a task. The
instructions must be precise and specific.
Programming is the art of writing computer programs
Programming is problem solving
Computers do not understand the languages that used by humans. They use 0s and 1s to
represent data.
Programming is done using a programming language
EXERCISE