You Already Know How

 Zoom Name:
RoadMap: You will begin today programming something you already know how to do in a language you already know. Then you will do some "real" programs in the same language, then the same programs in Java (because you already know how they work), and finally some of the same programs with full graphics. Then you will be ready to write anything you want. You can do this, but it will take time. Stay with us and we will get you there at your own pace.


Video Introduction  (10 minutes) <<--- Watch this video first, then

English IDE<<--- Click this link and write your first program here.

When it runs correctly (without errors or warnings) click the yellow Done button.
Then come back here and click this Next link to skip down to the next video.

If it's not a link yet, you might need to refresh your browser, or else click this button to call a mentor:

If you are like me and prefer to read at your own pace instead of whatever pace set in some video, You can read the transcript (and probably come out ahead of the non-readers).

Additional discussion, not in the video.

Video Transcript: 1. You Already Know How

All programmers know -- and some of us even admit -- that computers are an imperfect mirror of the real world we live in, so programming computers similarly reflects what you already know how to do IRL. Let me prove it.

Not everybody eats peanut butter & jelly sandwiches, but it's reasonably healthy (balanced protein) and pretty much everybody knows how to make a PBJ, even if you have more fun things to eat most of the time. So it's a program that you can write and another person -- or (today) a computer -- can run to make a PBJ.

The most important part of programming is understanding -- in English (or Spanish or Chinese, whatever language you think in) -- what the program does. Start with one line, like a title:

Make Peanut Butter and Jelly Sandwich


There, in one line is our program. It doesn't say how to make a PBJ, only what it is you want to do. The computer still needs to know how, which (today) we do in English. Later we will do some of the same programs in Java. But thinking comes first.

So let's talk about how. It involves a sequence of steps, which we do in a "Integrated (Program) Development Environment" (IDE). Click this button to open our "Integrated Development Environment" in a new window, which you can position to one side or above or below the instructions in this page:

At the top is a place for you to type in your Zoom name. If you do that, then this IDE will save your program for you from day to day, and eventually (not today) it will be able to automatically summon a Mentor to help you if you get stuck. Until that happens, you need to click the MentorAlert button (here below or in the IDE, but it needs your Zoom name) or the "Ask" button on the Zoom window. But saving your work is a good thing, so put your name there now.

On the left side is a panel for you to type program lines into. On the right side is where the output happens. At the bottom is an alphabetical list of what you can tell the computer to do in making a PBJ. The program panel is blank -- if not, your Zoom name is already used by another student, click the New button to add some digits guearanteed to make it unique -- Anyway, the program panel comes next.

A computer program -- and our program to make a PBJ -- is a sequence of steps. First you walk into the kitchen (where the food is)... This computer doesn't walk, but it can (let you) see:

see the kitchen
Start by typing this line into the program panel, then click Run. It opens up a view into the "Kitchen Computer" that will run your sandwich program. This doesn't make a sandwich, it just shows you what the kitchen looks like.

OK, we saw the kitchen, we can delete that line. It will automatically show the kitchen when we do anything there, like making our sandwich.

When you tell somebody how to make a PBJ, you might give them a long list of instructions, but they will understand you better if you start off simple. Start with the name -- we put it quotes to tell people (and in this case, the computer) that this is the name of what we are about to do:

"make pbj"


Then you get the necessary stuff out of the cabinets or wherever it is, then you put it together. Like this:

"make pbj"
  get stuff
  put it together
  done


This is how you make every program you will ever write: first you tell the computer the name of what to do, and then you tell the computer how to do it! It's called "Top-Down Design" and it's so important, we will repeat it a lot. Now, let's repeat our two steps process again: What do we want to do? Get the stuff. That becomes the name of the part of the program to tell the computer how to get the stuff:

"get stuff"


Then we fill in how to get the stuff. In this case we need the ingredients and the utensils, followed by the rest of the program we already have, plus a line to get it started:

"get stuff"
  get ingredients
  get tools
  done

"make pbj"
  get stuff
  put it together
  done

do make pbj


So how does the computer (or person) get the ingredients for a PBJ? This computer knows what it needs, but when you graduate to Java later this term, the computer knows nothing at all, except what you (or somebody else) told it. That's true of the Sandwich computer too, except I already told it how to make a PBJ. Now you get to replace (some of) what I did with your own program. Did you see what it did? It got out bread and jam and peanut butter. Let's make it more computer-ish:

"get ingredients"
  get bread
  get jam
  get PB
  done

"get stuff"
  get ingredients
  get tools
  done

"make pbj"
  get stuff
  put it together
  done


I bet you can do the same thing with the utensils -- I mean tools: In English we have a lot of words that mean the same thing (and the Sandwich computer knows some of those synonyms), but when you give a name to something in your program, you must spell it exactly the same everywhere. It doesn't even need to be a real English word, once you tell the computer what the name is, it's like you invented a new word, and it means exactly what you tell the computer it means, nothing more, nothing less.

So why don't you do that? You want to write a new piece of the program to get the tools we need (the knife and plate). It will look something like the "get ingredients" except it will have a different name is quotes, and get different things. Keep everything we did above, just add one more subroutine. [Then after you see that it still makes a PBJ, click the Done button.]

[2023 February 1]