BFOIT - Introduction to Computer Programming
Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Operators & Expressions
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Turtles As Actors
- Arrays
- File Input/Output
- AI: Pitcher Problem Solver
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
Updates
- December 13, 2008
- January 6, 2012
- March 15, 2013
- January 20, 2014
- February 13, 2014
- July 29, 2014
- January 18, 2016
- January 29, 2016
Lastly
What's Computer Programming
Screencast
Screencast
Welcome to BFOIT's Introduction to Computer Programming website.
This is a short screencast overview of the first lesson:
What is Computer Programming?
Computer programming is composing/authoring of a process/procedure
for doing something, BUT IN INCREDIBLE DETAIL.
proc-ess / Noun:
A series of actions or steps taken to achieve an end.
pro-ce-dure / Noun:
A series of actions conducted in a certain order or manner.
In a more advanced world (science fiction today) it will be possible to
teach the computer to do something by describing what it is that you want
in your native language, English in my case.
But, as of now, this is pretty much fantasy. Why? This lesson contains
an experiment that you can perform which demonstrates why. Participants
in the experiment write procedures for How to Make a Peanut Butter and
Jelly Sandwich. Then, someone plays the part of a computer and tries
to perform the procedures. When this is done properly it demonstrates
how much information is assumed in normal human communications.
Think about it... computers have absolutely no common sense.
So if we can't program a computer in our native language, how is it done?
Almost all of the computer programming these days is done with high-level
programming languages. For BFOIT's introductory lessons, we start with
the Logo programming language.
Logo has early ties to MIT and a scientist named Seymour Papert. It has
a "low floor and high ceiling" which means it can be learned easily, but
is quite capable. It is a derivative of the LISP programming language
which itself has been around since the 1950s and is still used today to
explore very complex stuff, as an example research in the area of
artificial intelligence.
Let's look at some examples of programming a computer in Logo.
-------------------------------------------------------------------------
The first program simply introduces itself - it prints out "Hello world!"
A slightly more complex program prints the result of multiplying a
random number in the range of 0 - 14 by 10.
And, if we get Logo to perform this program again you'll see we get
different results.
Finally a program that is complex enough that we have to create it in
the Editor provided. It's a function named getMax. It outputs the
largest number from a list it is given.
When I invoke this procedure in the CommandCenter, it produces the
proper results.
As you can see, the Logo programming language is sort-of like English
but not quite... It's got square brackets and colons where you don't
expect them. And, the ordering of the words seems a bit strange...
These differences are important... they make it easier to translate
what we want done into the language of a computer...
-------------------------------------------------------------------------
Below the level of programming languages, one step above a computer's
native language is what is known as assembler language where everything
is given human-friendly names. A programmer works with operations that
the microprocessor knows how to do but they have names. The
microprocessor's registers and addresses in the computer's memory can
also be given meaningful names by the programmer.
Remember our Logo getMax example? Table 1.1 contains a similar program
in assembler; it locates the maximum number in an array (a group of
numbers in sequential memory locations). Take note of the "Comment"
column; the remarks in it are only for humans, the computer ignores
them.
-------------------------------------------------------------------------
Before I can show you what a computer's native language looks like, lets
look at what it contains - bits.
[A] computer successfully creates the illusion that it contains
photographs, letters, songs, and movies. All it really contains is
bits, lots of them, patterned in ways you can't see.
Think of bits as light circuits like the ones in Figure 1.1. A bit is
either off, which means it is a zero, or it is on which means it's one.
its and a light circuit - ones and zeros.
-------------------------------------------------------------------------
Since a single bit is quite limited computers manipulate groups of bits.
In the next three sections of this lesson I go into detail describing
how bits are used to represent
numbers (Integers),
ASCII characters, and
Pixels.
-------------------------------------------------------------------------
So... a computer's native language must also be bits. How?
Well, each instruction a computer can perform is identified by an
opcode (which is short for operation code). An opcode is just a number.
Instructions and the things they operate on are in memory and each
location in memory has an address - which is simply a number.
Like your brain has working memory, microprocessors have registers
for quick access to stuff. They are also addressed in instructions
by groups of bits.
Yes, the language a computer understands is just bits.
Here is a robot computer simulator you can explore if you are
interested.
-------------------------------------------------------------------------
Summary
As I said at the start of this lesson, programming is just describing
how to do something. But since computers don't understand our native
language and we would go crazy trying to describe something with just
ones and zeros, which is what the computer does understand, we use
computer programming languages.
In the following eighteen lessons you will learn the basics of computer
programming. We will work together, writing programs in the Logo
programming language. It should be fun.
-------------------------------------------------------------------------
When was the last time you got to play a game as an exercise?
Here is a game that will help you get good at working with
binary numbers.
-------------------------------------------------------------------------
Blown to Bits - check it out!