Tom's Kitchen Computer

(The Reference Manual)

[Some Parts Still In Development]
(Jump dirctly to Tom's "Kitchen Computer")


People make programs all the time. They just don't run them on a computer. A program is a sequence of operations done in a particular order to accomplish some task -- like making a peanut butter sandwich or eating a bowl of breakfast cereal. We -- meaning Steve and Tom -- thought this was such a good idea, we think you can teach people to program a computer by showing how it's really what they already know how to do. In English.

Except computers mostly don't understand programs written in English. But Tom's speciality is telling computers to understand some other language besides the ones and zeros that is the computer's native language, so Kitchen is a special-purpose computeer that knows how to run programs written in English. A very small subset of English, but enough to let you see how easy it can be to program a computer.

For you computer geeks out there, Kitchen is Turing-complete. In principle, anything you can do in Java or C you can do in this computer, although a lot slower and less convenient. And your browser window is its only output. But it's a good start, or at least we think so.

The Kitchen Computer is still in development and some parts may not work properly yet. Those we know about are marked here in pink. If you try something and it doesn't work, please tell us so we can fix it.


Error Messages, Why and How to Get Past Them
The Kitchen Program
Kitchen Objects (Nouns)
Kitchen Commands (Verbs)
Variables & Expressions
Input & Output
Regression Tests

Error Messages, Why and How to Get Past Them

When I wrote this, these were the messages (in alphabetical order) that could show up in the blank space below the counter when your program is running. More messages get added to the program as I make it better, and I try to keep this list up to date, but I don't always succeed. For each message, I tried to tell you why it happens, and (usually) what you can do to get past it. If you can't get past it, you might need to get help from the instructor.

Assume get <spread> on knife

You told the computer to spread something, and there's a knife in view, but you didn't tell it to get the spread (jam or PB or whatever) on the knife to do that, so it assumed that's what you wanted.
Assume line <nn> is a comment
Comments (notes to be read by people, rather than instructions for the computer) in Tom's Kitchen computer are normally enclosed in (parentheses) but if your command doesn't make any sense, it might be assumed to be a comment. If you intended this line to do something, try simplifying your language.
Assume Next for open repeat
If you start a repeat (iteration), and you indent the lines you want repeated, and if you didn't put a Next command at the end of that indentation, it assumes you meant to do that and inserts it for you. If that wasn't what you iuntended, you might try making the indentation match your intended iteration.
Assume open <object>
If you tell the computer to get something out of a closed container or a space like a cabinet, it might figure out and assume that you wanted it open (which it must be to do that).
Assume repeat begins here
If you indented a portion of your program, and the indented part ends with something resembling a Next command, but there is no corresponding repeat command at the front of that indentation, the computer assumes that it should be there. But it's better if you put it in yourself.
Assume repeat ends here
If you indented a portion of your program, and the indented part begins with something resembling a repeat command, but there is no corresponding Next command at the end of that indentation, the computer assumes that it should be there. But it's better if you put it in yourself.
I can't <verb> <object> unless it's open
You need to open a jug or box of cereal before you can pour it into your breakfast bowl. Sometimes the computer can figure it out and do it for you, but apparently not this time.
I can't spread <object> there
Kitchen computer knows how to spread jam and peanut butter on bread. If you get too creative, the computer will just get confused.
I don't know how to <verb>
The computer recognized that this is a verb, but it has not yet been programmed to do that. Maybe next week.
I don't know how to <verb> a <object>
The computer recognized this verb, but it has not been programmed to do it to that object.
I don't know what <word> means
There are over a 100,000 words in the English language, but Tom's Kitchen computer only knows a couple dozen or so. This word is not one of them.
I don't know what color <object> is
Some objects obviously have a color, and the Kitchen computer knows what color they are. Others are plain, so Tom didn't tell the computer what color they are. I guess white is still a color, but we had to stop somewhere.
I don't know what to do
Each line of your program (unless it's a comment, a note to yourself inside parentheses) each line should begin with a verb that Tom's Kitchen computer knows (see the list below).
I don't know what value <object> is
Some objects can have a numerical value, like how much cereal there is in the bowl, and the Kitchen computer knows what that value is. Most objects have no metric that can change value (apart from location), so if you ask for it in some way that implies you want a value, the computer complains.
I don't know where to <verb> <object>
You can move an object somewhere, or pour a liquid or cereal into a container, or else dip the spoon into a bowl of cereal, but if it's not obvious where you want this to happen, you need to tell the computer. Maybe what seems obvious to you is not obvious to the computer. Most programming languages, nothing is obvious, everything must be spelled out explicitly.
I don't see a <object> to <verb>
You can move an object somewhere, or pour a liquid or cereal into a container, or else dip the spoon into a bowl of cereal, but if the object is not out where you (and the computer) can see it, it's not possible.
I don't see anything to <verb>
Tom's Kitchen computer knows how to eat a few things (like some cereal on a spoon), but some things you might know how to eat, the computer does not.
I don't see bread to spread <object> on
Kitchen computer knows how to spread jam and peanut butter on bread, but it needs to see a slice of bread out in the open to do that.
I don't see two pieces of bread to put together
The computer thought you tried to tell it to put two pieces of bread together to make a sandwich, but it doesn't see two pieces of bread on the same plate, or maybe it just got confused trying to do it.
I need a knife to <verb> <object>
The computer only knows how to spread jam or PB on bread using a knife, but there's no knife visible to use for that purpose..
I need a variable for <verb>
If you use one of the commands for giving a value to a variable, then obviously you need to give it a variable name. Variable names start with a letter and come immediately after the command name.
I need an object to <verb>
Most of the things (verbs) you can tell the Kitchen computer to do, you need to tell it what to do it to. The computer did not see anything in your command that looked like something this verb can act on.
I'm all confused about line <nn>
This is a catch-all failure of the computer to make any sense of your command. Try saying in a different way whatever it is you wanted the computer to do.
I'm not ready for different dishes at the same time
Some things (like make a sandwich) the Kitchen computer does on a plate, and other things (like eat cereal) it does in a bowl, but it gets confused if you try to use both in the same program.
Line <nn> is getting too complicated for me
This happens if you try to do something with a piece of bread that you didn't get out of the loaf wrapper, or if it already has something spread on it, or something like that.
Please do things one at a time
If you build a command that has several different words that say order things are done, the computer gets confused. Try to break your command into smaller parts.
There is no loop to do <more> here
You can restart an iteration before its next command in the Kitchen computer with a more command. You cannot go back to the front of a loop that is not currently active, so the more command only works inside an iteration.
There is no repeat for the <next>
An iteration in the Kitchen computer starts with a repeat command and ends with a next command. Sometimes the computer can figure out where the repeat belongs by your indentation, but apparently not this time. It works better if you are explicit about where your iteration begins and ends.
There is nothing to <exit> here
The exit command drops you out of an iteration before the number of iterations has run out, or from somewhere in the loop other than the end. But it doesn't make any sense outside an iteration.
There isn't any <object> there
You can tell the computer to get some things "from" a location (like the cabinet or fridge), but if it's not there, it can't do it. This is how it says that it can't.
We ran out of bread
There are eight slices of bread in the load. If you make too many sandwiches, or if you waste the bread, it will run out.
You count different than I do
If you get several slices of bread out, you can refer to them by number (first, second, etc), but if you ask for a slice that isn't out of the loaf, what can it do?

The Kitchen Program

The program is what you write, in a very limited subset of the English language. Like all natural languages, English can do some very subtle nuances of meaning, but the Kitchen computer will not understand you if you try that. Keep it simple. You can edit your program in the edit panel below the Kitchen image on the web page, or you can use some other text editor and just paste it into the edit panel.

If you number your lines sequentially, then if you make a mistake that the computer can tell you about, the line numbers will match. Or you can leave the line numbers off, because the Kitchen computer ignores them. The Kitchen computer also ignores whether you capitalize your commands or not. When you get into Java you must be much more careful about those kinds of things.

The Kitchen computer knows how to make a peanut butter sandwich (with a few variations), and it knows how to prepare and eat a bowl of cereal. It's not much, but it gives you an idea how computer programs work, a sequence of steps done in order, operating on objects and values, where the steps may be repeated and/or based on testable conditions. You can also give a name to a part of your program, then call it up as a subroutine from other places in your program.

Generally, your programs should consist of a sequence of commands, one line each, where each command begins with a verb, what you want the Kitchen computer to do when it gets to that line. We recommend you number your lines, but it's not necessary.

Most commands tell the computer what to do to an object, which can be one of the common things you might find in a kitchen, but you can also do things with numbers and give names to values (variables). It is more limited than a real programming language, but it gets you started.

You can add comments (notes to yourself) in {curly braces, shift-[bracket] on most keyboards} (parentheses sometimes work as in some of Steve's example programs, but not on variable assignment lines).

Your best bet is to start with one of Steve's examples, then modify it to do what you want, or use it as an example to try something different.

The next two sections list the objects (nouns) the Kitchen computer knows about, and the commands (verbs) that it knows how to do to those things.

Kitchen Objects (Nouns)


[left or rightdish or pantry] cabinet or cupboard or shelf
The dish cabinet is to the left, the pantry cabinet is to the right. If you don't specify which cabinet you want, the Kitchen computer will make a guess.

refrigerator or fridge for things best kept cold

(silverware) drawer

Normally you do not need to tell the Kitchen computer to put something on the counter, it assumes that's where something goes if you didn't say where.

The Kitchen computer needs to be able to see what you are asking it to do something to, and if you can't see it on the screen, it probably can't see it either.


We have three plates and three bowls. Normally you would use only one of them at a time.

Although the drawer appears to be full of silverware, the Kitchen computer only knows about one knife, one spoon, and one fork.

Pantry Items

We have one box of "Cheery Oats" cereal, one loaf of bread, one jar of peanut butter (PB) and (for now) one jar of jam. There are eight slices of bread in the loaf.

Fridge Items

There is a jug of milk and a butter dish and a jar of mayonaise in the fridge. Some deli meats and cheese are on the way, but they haven't arrived yet.


In English the pronoun "it" generally refers to the most recent object referred to by name. Sometimes that also works in the Kitchen computer, but it's better if you tell the computer exactly what you want it to do. If you choose or see an object, then it refers to that object until something else gets the focus latewr in the program.

Kitchen Commands (Verbs)

You can open the locations to get out the items stored there, and you can open the food containers to get a serving. I think you can also close them when you are done.

You can get or take or remove an item from its location (which moves it to an available location on the counter), and you can get or take or remove some jam or PB from its jar. Milk and cereal should be poured. You can put a slice of bread on a plate, and you can spread jam or PB on it, then you can put (two slices) together  or flip one slice over the other to finish your sandwich. You can dip or put the spoon into the bowl of cereal to get some cereal, then lift it into the air to eat it.

You can choose or see an object and then refer to it using it.

There is a message line below the Kitchen image, which reports program assumptions and problems the Kitchen computer cannot resolve on its own (see the list here). You can also put your own message on that line with the message (msg, print, say, show) command and a quoted string or defined variable with the text to display.

Other commands are described in the following three sections.

Variables & Expressions

The Kitchen computer can do simple math on numbers and store the results in variables, or print them on the message line. Numerical values can be combined with the four arithmetic operators ( + - * / ) and parts of the calculation grouped with parentheses as in any programming language (don't worry about it, we will explain this when we get to it, later). You can also put pieces of text together using the concatenation operator #. Here is an example:
Message "The sum of " # 1 # " plus " # 2 # " is " # 1+2
You can put values (numbers or text) into named variables, but put can mean several different things (and the computer might guess wrong which you wanted, and mostly put doesn't work yet), so the best way to do it is using the Let (or variable) command, like this:
Let myVar = 12
Variable calc = myVar*3+27 (=63 in calc)
The variable name is always a single word with only letters and digits (except it must begin with a letter). The value you put in a variable stays there until you put something else there, or your program ends. If this is too complicated, don't worry, we'll learn about variables in detail when we get to Java.


You can repeat one or more lines of your program. The best way to do this is to start with a repeat command and finish the part to be repeated with a next command. If you use only one of those keywords but indent the repeated portion, the Kitchen computer will assume the indented part is to be repeated, as in Steve's Breakfast program. You should put on the same line with the repeat command a number of times you want it to repeat. If you don't know, use a large number -- or just leave the number off and the Kitchen computer will assume 99. If your program decides to end the iteration early, you can use the exit command, perhaps in a conditional.


After your program has calculated a value, you can later test that value and do different parts of your program depending on the result. The command to do this is if followed by a variable or calculation that can be true or false, such as when you compare two values (variables or numbers) to see if they are equal or greater or whatever:
if myVar < calc message "less"
After the value to be calculated, you should put a command to be executed if the result is true. You can put it on the same line or the next line. In this example, if myVar is equal to calc, the condition being tested (less) is false, so nothing is printed on the message line.

You can also test whether a bowl or spoon is empty and certain parts of the date or time, like what day (Sunday is 1, Monday is 2) or month or year it is, like Steve's

If it's Saturday choose the Strawberry jam

The Kitchen computer does not (at this time) know how to do more than one command line in connection with an if-condition, but that one command can be a repeat 1 (do it only once) and then everything between the repeat and its final next happens only when the condition is true:

if calc=3 repeat 1
  msg "Do this first"
  if myVar < calc exit
  msg "then this, but not if myVar is less than 3"
  msg "none of this happens if calc is not equal to 3"
  next (done, the repeat is finished and so is the conditional)
msg "this happens immediately if the first condition is false"

Input & Output

Output is obvious: it's the message (or print) command, and it displays your message on the status line below the kitchen image. If your program makes no mention of any kitchen objects, but does some lines of output, part of the kitchen image will be covered over with a panel that displays the last 15 lines of your output. If you are doing things to kitchen objects, then obviously you want to see what is happening, so the panel does not cover them.

Input uses the command input followed by a variable name that you want the input text or number to be loaded into, and an optional number specifying how long it should be limited to. If that number is negative, then the input value must be a number (anything else the user types will be ignored). If you give it a length 1, then the input must be a single letter. Unless the user types in the whole maximum size, they need to end their input with the Enter key. Or they can wait until it times out, which is the same thing. The computer will flash instructions to the user on the input line, including a warning when the timeout is approaching.

Subroutines [TBD]

Not yet, but You can designate some part of your program by name to be a subroutine by giving it a name (in quotes, on the first line), and then run it from some other part of your program. The subroutine ends with the command done, or the beginning of another subroutine, or else by default at the end of the program. The command do with the name is used to activate a subroutine:
do part1
do part2
do part2 (again)

let x=23

msg "x=" # x
let x=x+1

This displays two messages, first "x=23" then "x=24".

[Note to Steve: I'm thinking of some tutorials to explain these things to the novices, after they have done the PBJ and Breakfast programs]

[2021 April 10]