In this introduction, you will work with two computer programming 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, and co-workers championed this computer programming language in the 70s. More research of its use in educational settings exists than for any other programming language. In fact, the fairly new Scratch Programming Environment (also from MIT) consists of a modern graphical user interface on top of Logo-like functionality.
Java is a fairly recent programming language. 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. One of the big advantages of learning Java is that there is a lot of software already written ( see: Java Class Library) 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. Java is used in a variety of applications, from mobile phones to massive Internet data manipulation. You get to work with window objects, Internet connection objects, database access objects and thousands of others. Java is the language used to write Android apps.
So, why do these lessons start with the Logo programming language? No other language has the depth of research devoted to its use in educational settings. Hundreds of books and research papers have been written regarding its use in the classroom. Cynthia Solomon, who started MIT's Logo Group with Dr. Papert, has put together a comprehensive website on Logo: logothings.wikispaces.com.
I like using the Logo language to teach introductory programming because it is very easy to learn. The faster you get to write interesting computer programs the more fun you will have. And... having fun is important! But do not let Logo's simplicity fool you into thinking it is just a toy programming language. Logo is a derivative of the Lisp programming language, a very powerful language still used today to tackle some of the most advanced research being performed. Brian Harvey shows the power of Logo in his Computer Science Logo Style series of books. Volume 3: Beyond Programming covers six college-level computer science topics with Logo.
Both Logo and Java have the same sort of stuff needed to write computer programs. . They have the ability to manipulate objects including lots of arithmetic functions, you can compare objects and do different things depending on the outcome of the comparison, and they provide ways to control the order in which instructions get performed. And... that's what programming is really all about... as you will see.
Just to give you a feel for what programming is like in a high-level language, here's a program that greets us, pretending to know English.
print [Hello world!]This is one of the simplest programs that can be written in most high-level languages. PRINT is a command in Logo When it is performed, it takes whatever follows it and displays it. The "Hello world" program is famous; checkout its description on Wikipedia by clicking here.
In addition to commands, Logo has operators that output some sort of result. Although it's a bit contrived, here is a program that displays the product of a constant number (ten) and a random number in the range of zero through fourteen.
print product 10 (random 15)In this source code, the PRINT command's input is the output of the PRODUCT operator. PRODUCT multiplies whatever follows it by whatever follows that and outputs the result. So, PRODUCT needs two inputs. RANDOM is an operator that outputs a number that is greater than or equal to zero (0) and less than the number following it. So, PRODUCT gets its second input from the output of RANDOM. Confusing? Figure 1.1 shows a plumbing diagram, how all these procedures fit together. Still confusing? Don't worry, we will get into the details of Logo operators in lesson 8.
to getMax :maxNum :numList if empty? :numList [output :maxNum] if greater? (first :numList) :maxNum [output getMax (first :numList) (butfirst :numList)] output getMax :maxNum (butfirst :numList) endAgain, do not worry if you do not understand exactly what this procedure does. It will be a while before you will be writing anything like this. But, I want you to see that the words that make up the program's instructions and the instructions themselves are similar to English sentences, e.g., the first line and a half in the procedure are similar to the sentences:
If the list of numbers to process is empty then output the maximum number processed.
If the first number in the list is greater than the maximum number processed so far then ...
So, a high-level programming language is *sort-of* like English, just one step
closer to what the language a computer really understands looks like. Now
let's move on to what a computer's native language looks like when it is given
a symbolic representation.