Jason Straughan

Teaching Kids to Code by a 13 year-old

Teaching programming to children is hard. Computer Science topics can be difficult to grasp using standard programming languages and tools. Using MIT’s Scratch programming platform, creating games and working software is simple and fun thanks to their drag and drop interface.

To prove that this is as simple as it sounds, this session will be led by a 13-year-old. What better way to learn how to teach kids how to code than by learning from a kid?

Portrait photo of Jason Straughan


>> Hello, everyone. My name is Michael. I'm a 13-year-old boy and I enjoy all things Pokémon, Lego, Star Wars, and now play video games and VR all day if you'll let me!

>> My name's Jason, his dad, CEO of a company called Codeup in the States, and we teach adults how to code. I know a little bit about Pokémon, and video games are all right. Before teaching kids to code and giving you tools to go back home? And teach kids to code. , let's talk about why teach kids to code? I think most people in the audience have some opinions about that, but I wanted to find out from a kid. Michael, why do you think kids should code?

>> Kids need a better understanding of technology. Most kids think technology is Google, YouTube, and Fornite. There's a not close to the possibilities. Coding makes you creative and makes you want to do amazing stuff, integrate and teach children logic, like if something happens, do something else.

You also learn how things work. You can learn how to send an mail, or learn how a computer works.

It's cool to build Lego and play games. It's cool and awesome to programme things. It's also really fun. I do on a daily basis.

>> Awesome. So before we get into the right way to teach kids how to code, we figured we would go over a few of the things we think are the wrong way to do it, and last summer, Michael was super excited to go to a camp where they were going to teach Minecraft mods learning Java and we learned a few things that are the things to avoid when trying to teach a code.

>> First thing to start with is a hard language, Java or C. During that camp, I used Java, and it was not fun. I don't know how it works to date. All I know is like C - I don't know. Make them learn to type.

I still use my four fingers, and using complicated tools like Eclipse. I have no idea how to go back to my previous projects. I have no idea how that even works. Vocabulary, like conkat ...

>> Concatenation?

>> I don't even know what that means. And they need you to learn maths first - a terrible way to start.

>> If you want to teach a kid a musical instrument, you would probably teach him a strong before you made them learn music theory or read music. I found as parent once Michael was out creating video games, all of the things in the slide he became more interested in. If this is where we start, then it's really heart to get them excited about writing code. That being side, we want to know what kids want to do?

>> This picture definitely shows what I want to do all day, every day.

>> All day long if I let him. Michael, what do you think the kids want to do when they are learning to codes?

>> They want to see results. They don't want to wait ten seconds -

>> You're telling me kids aren't patient?

>> I've been waiting for you to say that. And they like to create things that are fun, like game or Lego. They like to create things that they are interested in. And sharing that creation, again back to logo, they love to show it after they build the set, even I do, I like to show it to my parents showing what I'm capable of. To make new graphics, like doing artwork, or fan art, or anything like that, they love to do that, and building things that they love once again, Legos.

They love them, but last but not least, they like to play with the results. Guess what? Lego. They love to play with Lego before they put it on the shelf before letting it dust and rot.

>> Awesome. So, we've talked a little bit about the wrong way and why kids want to do it, and what kids are into, so we would like to present what we think is a great solution for teaching kids to code, and, in this solution that we want to show you, do you have to learn how to type?

>> No, it is drag and drop.

>> Took weeks?

>> No, it was easy learn, and I learned how make a game in the first day.

>> You're only a few of you online doing that?

>> There is a ginormous humungous community of users.

>> Why don't you write us a piece of software that you think you're being punished?

>> Almost fun to use, almost close to video games.

>> Was anybody able to help you?

>> Yes, it's pretty easy to learn, but if you do need help, anyone can help.

>> What about downloading games? Did you have to create special stuff?

>> No, I created one in the first hour without downloading.

>> What if you want graphics in there?

>> Graphic designs are included.

>> Awesome. We would like to show you the solution that's worked for us, and that scratch by MIT, it's super cool! Miming, tell us what is Scratch?

>> It's a programming language developed by MIT in 2003, it's for ages eight and up. I started around seven or eight. Right now, it has over 22 million users, and roughly around 25,000 new members join every day.

>> Wow.

>> And guess what? It's in German, it's in Spanish, it's in Japanese. There are over 70 languages it uses. And it only requires internet access, and, because of the recent 3.0 update, no Flash! [Applause].

>> Thank you, JavaScript community for saving us. Awesome. To get Scratch, it's super simple. You point your browser to scratch.mit.edu, and you're created with an IDE that looks like this. In the top-right corner is the stage.

>> That's where everything is going to happen where Sprites are going to be moving and changing president they are the objects on the stage that, as I said, they're going to change, move, do something. Those are the backdrops. Those are the stages of the stage - play on words there - and it changes, it can write the code, all that. In the middle, there's the coding area.

That's where you're going to be putting your code to make either the Sprites stage change. Next to that are the blocks.

Those are the chunks of code that we are going to be sticking together and making your thing work. Above that are the tabs. Pretty simple code. I just told you what that was. Costumes is where either Sprites or backdrops can change, and sounds describes itself.

>> So what we would like to do is a typical Hello, World using Scratch. Michael will come over and do live coding for you today in Berlin. Scratch Cat is the Sprite that is default. How about you show us a hello world script.

>> First, we go to events and grab the winflag. You need this for every piece of code we do. Then we go to looks. Grab a hell.

Make that a simple hello, world. Still using my pointy fingers. Going over to motion with ten steps.

>> Let's blow it up and hit play. That kid that you're trying to kitchen to code can have the hello world script not learning how to type or having all of those things that kind of get in the way, so the next what we would like to do is create a game for you live, right here, and Michael already went to the background and used the graphic tools, created all of us own graphics and what we see there is Jeff staying at an airport holding a beer. Tell us the premise of the gale, Michael?

>> So Jeff is German dude, and I'm not going to do anything weird. He is there, and he's going to be throwing wiener schnitzel off bearded dads coming off 48 aeroplanes with only three hours of sleep, and he's going to be super angry. He has to throw beers and schnitzel to make him happy. Angry bearded glasses dads..

>> Where did you get this idea?

>> With Grey Beard.

>> We want Jeff our main character moving around. Show us how we can make Jeff move left when you hit the left arrow button?

>> First, of course, we have to go events and grab the click block. Again, you're always going to need this. Go to control and grab a forever and an if. It's forever going to be asking the question: if something happens, then do whatever is in the loop. The thing we are going to be asking is going to be keyspace press, but it's not going to be left, it's going to be left arrow.

Go to motion. We are going to point in the direction left, which is negative 90. And then move ten steps.

>> All right, so we hit the flag. We hit the left arrow button.

>> Wait, wait. There's something wrong.

>> Do we have internet?

>> Do we have internet?

>> Okay. What's going on here?

>> I'm on the wrong Sprite.

>> Live coding is always fun! Every Sprite is its own object. We headed in the wrong piece of code. Now Jeff moves left! All right, good job! Thank you.

>> Thank you very much.

>> So now we've got Jeff moving left but I think he needs to move right as well. How do we go in there and make him move right?

>> Easy. You right-click and duplicate, something amazing about Scratch. You go right arrow and make that right.

>> Perfect.

>> Zoom.

>> And so we've got moonwalking Jeff.

>> Yes, Michael Jefferson!

>> Let's make him move in the other direction, pointing in the direction he's supposed to be moving.

>> Before that, I would like to show you the costumes. I have a right and a left costume. These will be important to make it move. We go back to code. You go to "looks".

We go down here and switch costume to right. Put that there as well, with this left. It's in place.

>> So that when he moves left and right, he will be facing that direction. Jeff can't move up and down. How hard would it be to add that?

>> Not very. Just expand, and right-click. Boom! There we go.

>> Duplicate two more if statements, so four nested if statements in there checking to see if it's going up, down, left, or right. Michael's going to get all of those set up. We will remove the Switch costume for the up and down. Accept the directions to down and up. And when we click Play, we should have a fully moving Jeff.

He moves everywhere, even diagonal. Check that out. In a few minutes, you're able to get the basics of a 2D game going but right now, it's just Jeff running around on a stage. Let's bring in one of the aeroplanes and see if we can't get some of the angry dads to come off.

>> "Aeroplane Michael coming in for landing".

>> All right. Now we have another Sprite, this is the aeroplane Sprite, its own object. Michael will start having angry dads coming off the plane and chase down Jeff trying to get that beer and schnitzel.

>> Of course, go over to events, when the flag is clicked. Go to control, do "forever". Wait one second. And so it's going to wait one second and then create a clone of myself.

>> That's quick.

>> It's a bit too short.

>> Let's make that a little more random.

>> Let's go to operators, pick random one to ten. Expand. Make it 2, 2, 6.

>> Every to two six seconds, this Sprite will create a clone of itself and Michael will show you what we can do with that clone.

>> When I start the clone, and you're also going to grab a "repeat until", go to motion, you're going to point towards a Jeff. And move ten steps. There you about.

>> So let's see what happens here. And we wait two to six seconds randomly, and angry dad!

>> Dad!

>> That's another aeroplane! All right. So how can we fix that? Instead of aeroplanes coming out of aeroplanes, we have angry dads.

>> First, I like the costumes. There is plain and there is Jason.

>> He looks a little familiar. So let's find a way to get him off the plane.

>> So go back to code. Go to looks. The plane is not going to be plane.

>> Every time a clone is created, it should of angry dad. Jeff's going to run around. Here they come. Angry dads coming off the aeroplane, chasing down Jeff. I have never run that fast in my life? You can't convince me that was based on me.

>> Let's make it six, then.

>> We will make him run a little slower. When they are catching Jeff, should they not disappear?

>> If you want.

>> Let's show how we could do that?

>> Okay, fine. Go over to sensing and do touching mouse pointer, change that to touching Jeff.

>> How we have a until loop like a "do while". Go to ...

>> Go to control again. Delete this clone.

>> So once that loop completes, the clone will be deleted.

>> Yes. So now let's go back in.

>> All right, so Jeff's out running around the airport. Every two to six seconds, there comes angry dads off the plane. When they click Jeff, they go away. Wouldn't it be great if we could get them beer and schnitzel before they caught Jeff?

>> Indeed. Let's go to food and drink. We have a beer. We have a schnitzel. I like the beer better than the schnitzel!

>> When we click on this third Sprite now, we see there's no code there for that object. We say whenever the game starts.

>> When the flag is clicked, whenever the game starts, we are going to go to control. Forever. If also grab while we are here. Then we go to our sensing.

We keep it there. Go back to control, grab it here.

>> We are creating a clone every time the space bar key is pressed.

>> Then we go to random position and we go to Jeff, and then - grabbing so much stuff while I was here. "Repeat until", and then we are going to have the motion, move ten steps. There you go.

>> So now every time he hit the space bar, a clone should be made of the food object and it should start moving ten steps from where it originates.

>> Like CSS you have show and hide for your Sprites. Now we need to show. Perfect. Awesome.

Wait! But that's like an endless supply of schnitzel, and they're sticking to the end. Let's make it where you have to let go of the space bar in between?

>> I want you -

>> Let's clean that up a little bit.

>> There come the angry Jasons. Shall we fix first machine-gun?

>> Let's make it where you don't have machine-gun schnitzel.

>> Okay. So we go over to Control, wait until, putting on the operators. Grab a "not duplicate this" so now it's going to repeat saying if the key space is pressed, make clone but you can't repeat until the key space pressed is not being pressed.

>> You've got to let go of the space bar every time. Let's see how that is working?

>> I'm holding it.

>> Perfect. But they are sticking to the edge of the screen there. We should probably make them disappear when they get to the edge of the stage.

>> So we are making it, we are touching the edge. We are going to make it where it deletes the clone.

>> So, when it falls out of the repeat loop, the while loop, they won't stick to the sides. That's perfect, but what I what I noticed is when the angry dads come off the aeroplane, they keep coming, so we should make that angry dad disappear as soon as he gets that beer and schnitzel.

>> Let's go back to plane one. We're going to operators. Grab an or. Duplicate Jeff. And boop.

>> So it's going to repeat until it's either touching the food and drink Sprite or the Jeff Sprite, and then they should disappear, and we should have angry dads coming off, getting ready to get that German beer and schnitzel, and there it is. Able to feed them and make them happy. [Applause].

>> But, it's only schnitzel coming out.

>> Yes, the game's a little easy right now. You can stand in front of the plane and spam angry dads. What if we had a expected plane?

>> Easy. So you cannot just copy code, you can also duplicate Sprites.

>> If you notice, when he duplicated the Sprite, all the code duplicated as well. When you hit play, we have a video game that is twice as hard and fast.

>> I forgot something: aeroplane Michael coming into landing.

>> It's only shooting schnitzels to the left.

>> We need a variable. If you don't know what they are, you're at the wrong talk!

>> It's going to be our direction variables. It's variables in Scratch or global. Any Variable you create can be accessed from another Sprite. Michael's going to set those variables to whatever Jeff is pointing left or right.

>> It's either negative 90 or 90. Right or left.

>> You can see for debugging that the variable is visible on the stage but you can uncheck it if you don't want it to be there.

>> Real quick drag a dir.

>> So we are back on the food and drink Sprite.

>> So point direction dir.

>> Choosing that variable, whichever way Jeff is pointed, that's the way the schnitzels are coming. I thought we said beer and schnitzels?

>> I can fix that. There you go. Now we go on to looks. And do switch costume to beer, and to the beer, we are going to go to the operators, and switch it to pick random one to two. If you look in the costumes, it's numbered one and two, so if I do this, -

>> So now randomly shooting beer and schnitzels. They want to get that beer from Jeff but he's able to deliver one for them before they get to him. We have the basics of a 2D video game in about 15 minutes, written by a 13-year-old. This is something you can all go home and do! [Cheering and applause].

Thank you. If you give him 30 or 45 minutes, he can build out a fleshed-out video game.

I want now to show you the final version of angry dad and Jeff. On the bottom right-hand corner, it will be the beer mug, the life of Jeff. Let's watch him play around. So it's the same game that you saw, except this time when angry dads come off and they drink Jeff's beer from him, he starts running out, and so we can see that when they do catch him, his life meter goes down -

>> But there is a keg which refills your beer meter.

>> As long as he is shooting beers at other people, they stay unhappy. They drink all of his beer! Game over!

>> It didn't go to End Screen. That's what we were looking for. Thank you.

>> We would love you to get in touch with us. You can contact me on Twitter.

>> Thank you all for coming to our talk!

>> Good job.

>> Yes! See you guys later.

>> [Cheering and applause].