What Is Computer Programming?
Introduction
Writing software, computer programs, is describing how to do something. In its simplest form, it is a lot like writing down the steps it takes to do something - aprocess. But, if what you need to do is not obvious or it involves multiple objects (each with their own process) writing the program will challenge you like when you are solving puzzles. So, writing a computer program can be like composing music, like building a house, like creating lots of stuff. It has been argued that in its current state, it is an Art, not engineering.An important reason to consider learning a bit about how to program a computer is that the concepts underlying it will be valuable to you, regardless of whether or not you go on to make a career out of it. One thing that you will learn quickly is that a computer is very dumb. It does exactly what you tell it to do, which is not necessarily what you wanted. Programming will help you learn the importance of clarity of expression.
A deep understanding of programming, in particular
the notions of successive decomposition as a mode
of analysis and debugging of trial solutions,
results in significant educational benefits in
many domains of discourse, including those
unrelated to computers and information technology
per se.
(Seymour Papert, in "Mindstorms")
Computers have proven immensely effective as aids
to clear thinking. Muddled and half-baked ideas
have sometimes survived for centuries because
luminaries have deluded themselves as much as
their followers or because lesser lights, fearing
ridicule, couldn't summon up the nerve to admit
that they didn't know what the Master was talking
about. A test as near foolproof as one could get
of whether you understand something as well as
you think is to express it as a computer program
and then see if the program does what it is
supposed to. Computers are not sycophants and
won't make enthusiastic noises to ensure their
promotion or camouflage what they don't know.
What you get is what you said.
(James P. Hogan in "Mind Matters")
But, most of all, it can be lots of fun!!!Inside Computers - All Ones and Zeroes
Today, most people don't need to know how a computer works. Most people can simply turn on a computer or a mobile phone and point at some little graphical image on the display, click another button, and the computer does something. An example would be for it to get weather information from the net and display it. This is all the average person needs to know about using a computer (or any device that's computer based).But, since you are going to learn how to write computer programs, you need to know a little bit about how a computer works. Your job will be to instruct the computer to do things. These lists of instructions that you will write are computer programs, and the stuff that these instructions manipulate are different types of objects.
Basically, computers perform operations on objects. A microprocessor, which is the heart of a computer, is really primitive but very fast. It takes groups of binary numbers representing parts of objects and moves them around, adds pairs together, subtracts one from another, compares a pair, etc... - that sort of stuff.
Computers manipulate numbers, symbolic information (think characters), visual things (images), sound (heard of MP3?), and sets of instructions (the computer's native language).
As an example, computer displays consist of a bunch of colored points called pixels. A pixel is an object. It has a position which consists of the row and column it is in. Its color is specified as three numbers - called RGB (Red, Green, Blue) values. Play with the following Java applet which lets you see what number values generate which colors. What color do you get if you set red to 170, green to 85, and blue to 255? What's the RGB value for your favorite color?
So, like pixels are used to compose graphics and images, there are also standard representations for the other things: numbers, characters, sound, and the computer's instructions. At the lowest level, they everything is a bunch of ones and zeros!
Binary Representation of Stuff
There are only 10 different kinds of people in the world:
those who know binary and those who don't
- Anonymous
As you explore how computers work, you'll hear more about numbers expressed in octal and hexadecimal; these are just more manageable representations of binary information. Table 1.1 shows some numeric and symbolic values for you to check out...

Programming Languages (The Microprocessor's Language)
So, what is a programming language?Just like we have many different languages in use throughout the world for us humans to communicate with, there are different languages that we use to communicate with a computer. Computer languages are used to tell the computer what to do, you instruct it.If you instructed a computer in its native language (machine language), you would have to write instructions in the form of (yes, once again) binary numbers. This is very, very hard to do. Although the pioneers of computers did this, no one does this these days.
One step above machine language is assembler language. In assembler, the operations that the microprocessor knows how to do are given names. Addresses in memory can also be given meaningful names. This is a big step over binary, but still very tedious to do any large software program with. It still has its place for little pieces of software that need to interact directly with the microprocessor and/or those that are executed many, many, many times. Table 1.2 is an example of DECsystem-10 assembler language that:
- adds two numbers together,
- adds in a third number if it is greater than zero, and
- stores the result in a third location.
OpCode | Accumulator | Operand |
MOVE | T1 | number1 |
ADD | T1 | number2 |
SKIPLE | number3 |
ADD | T1 | number3 |
MOVEM | T1 | result |
Programming Languages (High-Level Languages)
Most software written today is written in high-level languages. There are many and some are quite old. COBOL, FORTRAN, and Lisp were written in the 1950s!!! Higher-level languages make it easier to describe the pieces of the program you are creating. They abstract away the specifics of the microprocessor in your computer. Most come with large sets of common stuff you need to do, called libraries.In this introduction to programming, you will work with two computer languages: Logo and Java. Logo comes from Bolt, Beranek & Newman (BBN) and Massachusetts Institute of Technology (MIT). Seymour Papert, a scientist at MIT's Artificial Intelligence Laboratory, championed the computer programming language in the 70s. Java is one of the newest programming languages. It appeared in 1995 just as the Internet was starting to get lots of attention. Java was invented by James Gosling, working at Sun Microsystems. It's sort-of a medium-level language.With Logo, you will be able to write computer programs quickly and easily since it is a very simple language. Once you have some experience with it, you will move to writing programs in Java.
One of the advantages of learning Java is that there is a lot of software already written which will help you write graphical programs that run on the Internet. You get to take advantage of software that thousands of programmers have already written. So, you are not limited to working with numbers and characters; you get to work with window objects, canvas objects, string objects and thousands of others. You will not be limited to simple operations like adding two numbers; you will use operations like create a new window, draw a line, display some text in a window, and much, much more.
Programming Using the English Language
Remember what I said in the Introduction to this lesson?Writing software, computer programs, is a lot like writing down the steps it takes to do something.
Before we see what the Logo computer language looks like, let's use the English language to describe how to do something as a series of steps. A common exercise that really gets you thinking about what computer programming can be like is to describe a process you are familiar with.
Objective: Students will write specific and sequential steps
on how to make a peanut butter and jelly sandwich.
Procedure: Students will write a very detailed and step-by-step
paragraph on how to make a peanut butter and jelly
sandwich for homework. The next day, the students
will then input (read) their instructions to the
computer (teacher). The teacher will then "make" the
programs, being sure to do exactly what the students
said...
This lesson is excellent at demonstrating how careful you need to be, how detailed you need to be, when writing a computer program. Hierarchy of Computer Languages
Application-Specific Language (4GL) Examples: Mathematica, SQL |
High-Level Language Examples: Logo, Smalltalk |
Low-Level Language Example: C |
Assembler Language Example: Intel X86 |
Table 1.3 |
Exercise
I want to combine exposing you to more details about how a computer works and the "programming in english" lesson. Let's learn more about binary numbers. Get a piece of paper and write the following binary addition problem on it: 1100
+ 1010
------
Now let's add them together.- The first column, 0 + 0 = 0; is easy.
- The second column, 0 + 1 = 1; that's easy too.
- The third column, 1 + 0 = 1; this is cake...
- The fourth (last) column, 1 + 1 = 2; NOPE... We don't have a 2 in binary numbers. 2 is written as 10, which is a zero with a carry of 1. Since this is the last column we're adding, we just write in the 10.
1100
+ 1010
------
10110
For a second problem, let's just swap the ones and zeros. Solve this one as a group... 0011
+ 0101
------
Now your turn. Write down the steps you've used, generalized for adding ANY two binary numbers together. I'll get you started.
- Start with the rightmost column. If both of the numbers are zeros, write a zero underneath them and go on to work on the column to the left of the current column.
- If one of the numbers is a one and the other is a zero, write a one and go on to work on the column to the left of the current column.
- ?...
"News Powered by "
No comments:
Post a Comment