a project by christian morrow. [take me back!]

BUILT FOR SCIENCE NIGHT @ MHE

Code_Lab

(how we used computers and science to make awesome things, and why you should too.)

By Ngan Phan and Christian Morrow

INTRODUCTION:

Computers are very fascinating machines. They can solve complicated math problems, they can answer any question you ask them, they can even think and learn by themselves. You might think that computers are very smart, but that's not true. Computers aren't very smart at all, but they are very good at following instructions.

Even still, you can't just tell a computer to solve a math problem or write a paper. The computer can't understand you. Computers speak in special languages, called coding languages. Different coding languages are all good at different things. Let's look at a couple:

These languages are used to make computer programs, a list of steps that a computer follows to do something. Here's what a basic computer program might look like:



Did you know?

Electronic computers were invented in the 1930's, but it was earlier in the 1800's when the first computer program was written.

The author of the first computer program, and the world's first computer programmer, was a woman named Ada Lovelace. She was a mathematician from England, who believed that computers would be used for all sorts of things, from writing, showing pictures, making music, and more.

Because of her unique understanding of computers, people nicknamed her "The Enchantress of Numbers". (I wish I had a nickname as cool as that.)

Ada's program wasn't written for a computer that plugs into a wall, or uses a battery. Back then, computers were cranked by hand to process information! It looked like this:


In fact, many women have shaped modern programming as we know it. A woman named Grace Hopper invented the first code compiler, a special program that turns coding languages into machine language. Without compilers, we'd all need to code in binary, that is, a lot of ones and zeroes in a specific order (10011011)

Because of her invention, programs are able to run on all different kinds of computers, and led way to JavaScript, a powerful coding language used on almost every website. Grace Hopper also invented the term debugging, for fixing problems inside a computer program. She came up with the name after removing an actual bug from a computer when it wasn't working.

She was so important to computers that she also got a nickname, "The Queen of Software". If you become a programmer, maybe you'll get your own cool nickname one day!

Programmers are people who use coding languages to make computer programs. It may seem scary, and it might seem very hard, but this is very wrong. In fact, many programmers don't know how to do a lot of the things they need to do. They learn as they go. Anybody can be a programmer, because a programmer's job is to solve problems using computer programs. Programmers figure out what steps they need to take to solve a problem, and then they learn how to turn that into code.

We made Code_Lab to help you think like a programmer! Today, we're gonna learn about three important things that programmers need to know, no matter what coding language they use. We'll teach you about:

We're gonna use Scratch to run our experiments. It's a free coding language built by teachers at MIT. It was designed to be really easy to use, so kids can start coding anything they can imagine! Instead of writing out your instructions, Scratch has blocks that snap together, kind of like Lego bricks, to make anything you want, like games, art, music, and more! Scratch makes it super simple to be a programmer, and we encourage you to try and make your own programs at home! Here are the three projects we built using Scratch:

Here's an example of a game somebody built in Scratch!

EXPERIMENT 01: AUTO ROCK-PAPER-SCISSORS

WHAT IS A SEQUENCE? HOW DO COMPUTERS FOLLOW INSTRUCTIONS?

In this experiment, we wanted to know what sequences were, and why they're important in code. Imagine you're making a cake. To do this, you need to:

You wouldn't put the ingredients in the oven before you mix them together. (That cake wouldn't taste very good.) You also wouldn't try to do all the steps at the same time. When you follow instructions, you do them sequentially. This means you do the first step, then the second step, then the third step, and so on. You follow the steps in order.

Computers do this too, they follow instructions in sequence, that is, step by step. If a computer did all the steps at once, it would overload and crash. If a computer did the steps out of order, things might glitch and go wrong. Let's look at how we used sequences in our rock-paper-scissors simulator:

This is a flowchart. We showed you one earlier. It's a diagram of a process. It keeps track of every decision, input, and action in a set of instructions. To read it, start at the green box, and follow the arrows. This is what it looks like for our program:

Click here to play the game!

IN THIS EXPERIMENT, WE LEARNED:

THINK LIKE A PROGRAMMER! What would happen if the computer followed these instructions in the wrong order?


EXPERIMENT 02: BALLOONS

WHAT ARE LOOPS? WHY ARE THEY IMPORTANT?

For this experiment, we wanted to learn why we use loops in code. To play the game, you pop balloons by waving your hand near them. But how does the computer do this? Using the camera built into the laptop, called a webcam, we tell the computer to:

We put those instructions in a loop. A loop tells the computer to do something over and over again, so we don't have to write it a bunch of times. After 30 seconds, the game stops and it shows you your score.

So, why would we use a loop? Imagine you're telling somebody to hop five times. What would you say? Would you say: "Hop! Hop! Hop! Hop! Hop!" or would you say "Hop five times!"? You would probably say "Hop five times!" because it's faster, and takes less words. This is exactly why we want to use loops in code. It makes our game run faster, and takes us less time to make. We call this "efficiency".

Click here to play the game!

IN THIS EXPERIMENT, WE LEARNED:

THINK LIKE A PROGRAMMER! What are some instructions you could put in a loop?


EXPERIMENT 03: TOPPLE TOWER

WHAT ARE VARIABLES? WHAT CAN WE DO WITH THEM?

Tower Topple is a game we made to find out more about variables. Variables are special numbers, special because they can change. Variables are good for keeping score in a video game, or, in our case, tracking how many blocks are remaining. Our game uses eight variables to make it work:

Here's what that looks like:
Without those variables to change the numbers, the game wouldn't work at all. In order for the movement and the score to work, we need these numbers to change!

Click here to play the game!

IN THIS EXPERIMENT, WE LEARNED:

THINK LIKE A PROGRAMMER! What else could you keep track of with a variable?


CONCLUSION:

DURING CODE_LAB, WE LEARNED:

We hope that you learned a lot, and had lots of fun doing it.
Many of the people who have shaped the digital world started out by coding, just for fun. Bill Gates, founder of Microsoft, wrote his first computer program when he was just 13. Years later, a young Steve Jobs would program an arcade game named Breakout, and later go on to create Apple, the largest tech company in the world.

They started coding because they enjoyed it. They never thought it would take them where it did, or that their companies would change the world. You could be the next. Coding is a great skill to know because it can be very exciting for your future. Or maybe, you just wanna start coding for the fun of it.

We encourage you to experiment with programming on your own, at home. It teaches you problem solving, critical thinking, and patience, all while you build things that will make you feel acomplished, excited, and motivated.

Have a parent help you log onto scratch.mit.edu to get started with building your own projects. Try these projects we've linked below:

But most importantly, remember that behind every great website, videogame, app, and computer, there's a programmer or two who solved all the problems, and made it all happen.