Join thousands of grownups who get articles on teaching kids to love coding.
Back to Articles

Learning to code is like learning to cook

Learning to cook

When I think about teaching kids how to code, I remember how I learned to cook.

In college, I had a summer job working at a hiking lodge. In addition to trail maintenance, bunkhouse cleaning, and washing dishes for hours on end, I was also responsible for cooking two large multicourse meals per week for our guests. Before I took this job, my culinary skills consisted of adding sauce to pasta (and a solid baking repertoire). I could hardly manage to make a balanced meal for myself, let alone more than 100 guests!

Find a recipe—or a Bitsbox app

My first cook day, I was handed a torn and battered (literally, it had dried cake batter on it) "cookbook." It was a homemade binder of photocopied and original recipes that had previously been cooked and served at this same lodge.

Knowing that these recipes could be made with the ingredients and equipment on hand, I carefully selected my first recipe: Carrot Ginger Soup. I didn't know how to cook, but I did know how to read and follow directions. I started chopping onions and carrots, grating ginger, heating oil, adding salt, and later that evening served my first meal to our guests.

Learning to code with Bitsbox takes a similar approach. Every Bitsbox project is a recipe for making an app, and our Apper Keeper binders are cookbooks full of app projects. You select which app looks like fun to build and follow the instructions to type the code.

Big fan of dinosaurs that eat cupcakes? Feeding Time is the perfect app for you! Just go to bitsbox.com/code and start typing the code you see below. All you need to do is read and follow directions! In no time, you'll have a fun, if a bit odd, game of catch-the-cupcake with a T-Rex.

Feeding time app
Play this app here!

 1  fill('sunset jungle')
 2  rex = stamp('trex',700,200)
 3  food = stamp('cupcake3',0,random(1024))
 4  count = 0
 5  a = text(count,350,100,100)
 6  speed = 10
 7  
 8  function drag() {
 9    rex.move(rex.x,y,200)
10  }
11  
12  function loop() {
13    food.move(EAST,speed).rotate(RIGHT,20)
14    speed = speed + .2
15    if (rex.hits(food)) {
16      food.pop()
17      sound('chomp')
18      count = count + 1
19      a.change(count)
20      food = stamp('cupcake3',0,random(1024))
21    }
22  }

And the best part? Just like beginner cooks can still make real meals, beginner coders get to build real apps!

Change the ingredients—or the code

Eventually, over the course of my summer job, I began taking on more complex meals, trying out new recipes, swapping flavors and veggies, and placing special requests to my boss for unique ingredients.

With apps, changing the code can be like modifying a recipe and substituting ingredients. Your cupcake-eating T-Rex game is pretty fun, but it would be a whole lot more fun if a Game Over! screen appeared when you missed a cupcake. To do that, add these 3 lines of code after Line 21:

22    if (offscreen(food)) {
23      stamp('game over',700)
24    }

Now, you have a losing condition for your game. But what if you change the main character and the food? A bear eating raspberries may be more your style. With a few quick changes to the code, and you have a new app—Beary Berries. You're a game developer!

Beary Berries app
Play Beary Berries here!

Learn from your mistakes

When I was about 10 years old, my mom (perhaps ill-advisedly) left my sister and I alone while we were making chocolate chip cookies. She returned to the kitchen to witness us pouring a cup of salt into the bowl of ingredients. Turns out, we had misread 1t (teaspoon) as 1C (cup).

Mom shared that the only recipe that might ever use a full cup of salt is homemade Play-Doh; otherwise salt was usually measured in teaspoons or tablespoons. Our cookies that day were ruined, but there was no harm done (besides the wasted ingredients). And in making that mistake, I learned about salt, units of measurements, and double-checking instructions.

When you're learning to code, you're going to make mistakes. That's okay!

Sometimes, the best way to really learn that you always need to start and end your functions with { and } is to forget those curly braces over and over. Eventually you remember to include them!

It's also okay to take a break from a recipe or app that just isn't turning out the way you want. Maybe the humidity is too high for the cake to rise, or you need a day or two to re-approach the way you want to design your score-keeping function.

The best projects develop over time, with lots of mistakes along the way.

Keep practicing

When you learn to cook, you don't need to know why you add the carrots before the ginger or why a cookie recipe calls for baking powder. Learning how to code with Bitsbox is similar: You don't need to understand loops or arrays before you start coding with them.

In both cooking and coding, practicing and experimenting are fun and effective ways to learn. Can coconut oil really substitute for butter? What if we added poison berries for our Beary Berries character to avoid?

The more recipes you follow and tweak, the more you start to understand the intricacies of each ingredient. Even baking powder starts to make sense! And the more you code, the more loops, variables, and functions become natural to use. Confidence and competency increase in parallel in both practices.

Have fun sharing what you cook—or code!

Of course, you can learn to cook in many different ways. You can work in a restaurant and apprentice under a professional chef. You can attend a class or even a university dedicated to food and cooking. You can study from textbooks and reference manuals. If you decide to become a professional cook, you'll probably learn in all of these ways.

And if you decide to pursue coding as a vocation, you'll need to supplement your build-and-experiment style of learning with more formal learning, too.

In the meantime, the build-taste-tweak approach is incredibly satisfying. Anything you cook yourself tastes better than a store bought cake. And sharing a fun app with your friends, with the knowledge that you built it yourself? That's way better than reaching level 402 of Angry Birds.

Anastasia Miliano
About the author: Anastasia is a proud Maine native, mechanical engineer, and aspiring coder. As the Chief Cat-Herder at Bitsbox, she makes sure new coding fun arrives every month.
Join thousands of grownups who get articles on teaching kids to love coding.
Cute icons Stamp not found