visit
“Papa . . . What do you do for a living?”
It’s a question that comes out of nowhere and makes every parent proud. It’s one of the first signs that your child sees you as a person and not just a caretaker.“I’m a web developer.”
“What’s that?”
Let’s go back in time three years . . .My son was seven years old and the coding for kids movement was .
“I’ll teach him how to code!” I thought.
Parents like teaching their kids — it’s instinctual. We teach them language, values, skills, how to throw and kick a ball and many important life lessons as they grow up.What about computer programming?
It’s not as glamorous as building a house. It’s not as instantly fun as assembling a LEGO car, opening a fresh pack of , or experimenting with a classic . However, it is a form of creativity and expression — I can use computer programming to make something that wasn’t there before, using a set of tools.
He started with from MIT’s Lifelong Kindergarten group. For those unfamiliar, Scratch is a community for kids. It’s very fun and intuitive — like connecting LEGO bricks. Kids can quickly get started making games, stories, and animations then share their creations within the Scratch community (over 18 million projects have been shared on scratch.mit.edu). A big thank you to the Scratch Team for providing such an excellent platform! He spent at least two years “Scratching” — and still does today.
I also hosted a at his school a few years ago, posted a for teachers and mentored at .
Ah . . . The big moment! Moving from the warm and cozy world of Scratch visual programming to the stark, cold and unforgiving world of typing plain text, the command line and cryptic error messages. Where, in the time it used to take to build a something interactive in Scratch (complete with fart sounds), you can output “Hello World” to the console.
Moving from Scratch to Text. It’s a big change!
My first programming language was on an . I remember spending hours typing pages of code from magazines and books — and debugging all the typos — just to play simple dungeon games. The games weren’t even that fun and always seemed to crash with syntax errors, but it was the closest we had to actual computer games and that made it worth the effort!
I re-purposed an old laptop and installed Python and Sublime. (I actually took his mother’s laptop and gave her the old one. She only uses the web browser and Office anyway.)
His Scratch skills transferred well — control flow, variables, conditionals, loops and lists. It’s amazing how much he learned in Scratch, while having fun. All was going well — until he stopped.Looking back, I would still start with Python and the same book, since it was a great experience for both of us and I’m sure he will pick it up again in the future — Python has so many uses.
But I was determined . . .I decided to give HTML and Javascript a try and ordered the book from no starch press. The book covers the basics of Javascript (ES5), HTML and basic jQuery (even if it’s ). Little by little, he worked through the book — an hour or so on weekends. There were plenty of gaps, but he made solid progress. Great book!
VariablesNothing too exciting here. The “variable is a container” analogy worked very well.
“Variables in Javascript are like boxes that hold things. You give them names, just like labeling a box of Pokémon cards, so you can find it quickly. Use good names, so you know exactly what’s inside — like ‘Ultimate Pokémon Deck’.”
Arrays“A Javascript array is like your bookshelf (see header photo). It holds many different things in one place and makes them easy to access and find later. Your bookshelf has books, toys, drawings, photos, pencils, cards and more. If you ask me to find your Harry Potter book at the end of the bottom shelf, it would be easy.”
Objects“Most things around you are objects — people, cars, planes, trains. Objects have certain things that define who/what they are and things they can do. In Javascript, the things that give an object its identity are called ‘properties’ and the things they can do are called ‘methods’. Think about your class made up of Student objects: some properties of a Student are: name, age, school, class. Some methods of a Student are: talk, run, and jump.”
“Arrays can also hold objects. You can make an Array of your entire class that contains 30 Student objects then use a loop to print out all of the students in your class.”
Functions“Functions are like cooking recipes or the instructions that come with a LEGO set. Running a function goes through each of the steps until it reaches the end or is told to stop — like when we call you down for dinner!
A ‘bake-a-chocolate-chip-cookie()’ function includes all the steps required to bake a chocolate chip cookie — gathering and preparing ingredients, mixing, placing on baking tray, preheating oven and baking.”
Parameters “Parameters are like bits of information you share with your functions — giving them extra powers. Instead of having to write a separate ‘bake’ function for every type of cookie, you can write one ‘bake()’ function and tell it which type of cookie to bake as a parameter — bake(‘chocolate_chip_cookie’).”
*Don’t get too bogged down in the difference between parameters and arguments; it’s not worth it at this point.
ClosuresThis was fun! CodeSchool did a great job in , but it just didn’t click for my son right away. Closures still trip me up to this day.
My first explanation attempt:“A closure is like a dinosaur fossil — a snapshot from a moment in time preserved for millions of years. You can get still get information about the dinosaur from the fossil, even though the dinosaur itself has been gone for millions of years.”
Closures were starting to make sense, so I tried using cookies again . . .
“Let’s say I go to the same bakery every day and ask the baker for a cookie. The first thing he/she asks is, ‘What kind of cookie do you want?’ After a few days, the baker might already know what cookie I like and simply ask, ‘The usual?’. By saving my cookie choice in memory, he/she is able to reuse the same function from the previous day to get me the proper cookie without having to ask again.”
Eh… It was still a bit fuzzy, until my son asked me…“So, it’s like when we go to the barber and he just cuts our hair without asking what we want? He always asks new customers how they want him to cut, but never asks us anymore.”
Ding, ding, ding! He got it!!!
After finishing the remaining CodeSchool exercises, it all started coming together — for both of us.Learning computer programming takes time — not something accomplished in an hour of code (BTW: the is a great initiative and Code.org is an amazing organization — if you can).
Coding is a craft. Like any activity you sign your kid up for, it takes practice, patience and commitment—not always the easiest things for kids. We’re still at the beginning of the journey, but moving along. We attended an recently and he was inspired to make games. He starting watching some Unity videos, but that dropped off rather quickly. I try to not to limit his propensity to pivot and experiment with new things. I recently introduced him to , which is a great Javascript 2D game framework I’m also trying to learn myself — we’ll see how it goes.Now it’s time to start the journey with his younger sisters!