Thursday, August 29, 2013

Lesson 11 - Turtle Roy

Today our lesson took almost 45 minutes. We had no plan but we did cover a lot of topics. Not just computers, but Englis, Math and Geometry too.

We had been singing the (in)famous Head Toes And Knees And Toes song quite a bit today, so we chose to have the computer sing it for us. We started to write the lyrics into a file and had the computer speak it out load. We got as far as

    head

.. and she was exhausted with typing.

So, I took her to Turtle Roy, my little Logo-ish learning environment using the Roy programmin language. There was some issue with Chrome this time and I joked that the turtle must be sick, which made her a bit upset: "Is the turtle really sick?". But we opened it in Safari and it was ok.

We discussed pixels and used the Mac magnification feature (ctrl-two-finger-drag) to have a close look at them. Then we used "fd 50" to make the turtle move 50 pixels. It was not trivial that the number 50 is typed 5-0.

Then we discussed angles, and especially the 90° Right Angle. She was able to deduce how 90 is typed based on earlier experience with the number 50. So we did "lt 90" and the turtle turned left.

Now she was really determined that she wants to draw a Rectangle. And there we went, repeating the previous command until a perfect Rectanble was formed. She wanted to save it and was a bit disappointed that Vim commands don't work in Turtle Roy. But she was o.k. with being able to save it using a Web UI. And yes, the Rectangle is now saved for you to marvel at.




Now she wanted to make triangles, circles, suns, smiling faces and whatnot. I convinced here that they all can be done and we'll make them later, but she'll have to learn some English, Maths, Geometry and Programming first. I even showed here some of the aforementioned shapes and she was like "WOW". Now I'm her programming superhero:) 

Anyways, I think we've found a nice tool for learning to code.

Then we discussed Lists and Geometry a bit. The concepts of head, tail and empty list were surprisingly easy for her so I think she'll learn to write recursive algorithms very soon. Before that I think we need to refactor her Rectangle to adhere to the DRY principle.

Meanwhile I'll have to make Turtle Roy support some vim commands to integrate our editing and coding skills more nicely.

Monday, August 26, 2013

Mad Skillzz

This is what we've done so far, just summarizing for myself mostly. Most of this stuff she can do now, but needs some help with.

Vim 

- Start vim to edit a file: vim kissa
- Add new line with text, exit insert mode: p, <esc>
- Delete a line: dd
- Copy/yank a line, and paste it: yy, p
- Append to current position: a
- Save and exit: :wq

Files

- List all files: ls
- Print out file contents: cat kissa
- Count number of words: cat kissa|wc -w
- Speaking: cat kissa|say

Scripting

- Add any commands to a file using vim
- Make executable: chmod u+x nakki
- Run the script: ./nakki

Browser

- Search for stuff: click on location bar, type text, press enter
- Go to image search to see more pictures
- Scrolling with two fingers
- Saving a file: right-click, Save As, select home directory, enter file name
- Open saved file from command line: open perhonen.jpeg

What next? More practise on all of these areas of course, but should we set a goal or something?

Lesson 10 - Yank It!

The funniest thing today was the new reminder sound for adding a space between the program and the argument (filename). She forgot that a couple of times and I let out a huge O! She might remember next time.

We revisited the vkp file again, and pracised copying lines: yy to yank a line and then p to paste it on the next line. It seemed quite easy for her to understand that stands for yanking (making the computer "memorize" something) and yy stands for yanking the whole line. I explained that many commands in vim can be applied to the whole line by repeating the same letter. Like dd that we used before.

She wanted to do it again and again, so I teached her to use the period (.) to repeat the last command. We ended up with eight lines with 7 weekdays on each. I teased her to count the words and we came to the conclusion that the computer is better at it. She used vim quite fluently today.

    cat vkp|wc

That's how we made the computer count the words. She remembered both programs cat and wc and typed the pipe character like a boss. The output was something like

    8    56    456

... showing the number of lines, words and characters (I call them letters to her). The number eight was easy to read, but she couldn't interpret the larger numbers, so we practised them. She can count to a hundred now so the number 56 was graspable once I told her that 56 goes like viisi-kymmentä-kuusi.

We were both very happy with the lesson and recapped it what was learnt this time. She remembered copying lines, and using yy.

Then we googled for pictures of scary ghosts.

Sunday, August 25, 2013

Lesson 9: Piping Like It's 1999

Today we had a nice little session. We used ls to list all the files again. This time she remembered that cat is the program we use for printing out a file. So we printed out the weekdays in the vkp file. Then she manually counted that there are 7 of them. 

I persuaded her to see if the computer comes to the same conclusion as she did. So I introduced the new tool wc (word count) the name of which was found very funny. We found out that the "-w" flag should be used. Then we did our first "double pipe":

    cat vkp|wc -w|say

This time she also remembered how to type the pipe character. The computer agreed with her and said "seven".

Then we googled for "monsters" as per her request, and saved a picture of a monster onto the hard disc, found it there using ls and opened it in vim to find out that it looked like garbage. She liked it a lot though. She remembered how to type vim and how to exit. Nice.

Saturday, August 24, 2013

Lesson 8 - Badgers

This one was a bit challenging, as we had the lesson just before bedtime and we were both very tired. Even though during her violin lesson a bit earlier she had said "I don't want to play violin, I want a computer lesson"...

So, we created a new file "vkp" (shorthand for viikonpäivät) and wrote all the weekdays there in Finnish. Vim was very easy this time, but typing all those words was challenging. Yet we triumphed. We used both the "o" (new line) and "a" (append) commands this time.

We used cat to print out the file contents, then piped the output to say to hear the computer speak out the weekdays. That was a bit disappointing, because the English voice is really really bad at speaking Finnish. I wish there was a way to get a Finnish voice on a Snow Leopard Mac. But I guess there isn't. Maybe we'll install Linux next time. I heard there's a Finnish voice there.

We googled for badger and watched the video. Then we practised the badger dance while brushing teeth.


Wednesday, August 21, 2013

Lesson 7 - Butterfiles

Today I was a bit unsure whether I can motivate her to do stuff on the command-line. So I reminded her that we'll play with colors and have a look at the Keijupeli source code to see that behind all graphical games there's a load of textual code.

When we started, she said "let's make a script", and I knew this is going to work. So we revisited the "nakki" script from the previous lesson. Script is a file and it's a program. You can run it and you can edit it. We chose to run it first, to hear the computer say "pitkätossu". She used tab-completion to get the name typed quicly and then the up-arrow to repeat the previous command many times. It was fun.

She remembered that the text-editor program is called vim. Typing vim was not hard either. For the first time she remembered to add a space between "vim" and "nakki".

We added a second line "cat kissa|say", revisiting the piping thing we've done a couple of times. So, our script now is like

    say pitkätossu
    cat kissa | say

She remembered how to exit insert mode and how to save and quit. Then we ran the script and she laughed most of the time the computer was speaking. The "kissa" file contains a huge load of random stuff.

We discussed the possibility to use alias to make the computer understand Finnish words instead of the English ones like "say". But she chose not to use alias this time. Maybe later then.

So that was the "boring command-line part" which turned out pretty interesting and fun again. Then we had a look at the Keijupeli source code and even had the computer speak the source code file aloud.

The last planned exercise was playing with colors. We found a webpage where you can increase/decrease the amount of each color RGB and found yellow, black, white and cyan.

But that wasn't enough. She wanted to search for photos of butterflies and so we did. The browser GUI proved hard to use with tiny hands. A right-click with a Mac trackpad is a bit tricky for adults too, ain't it?

That wasn't enough either. She wanted do more things. So I told her that the pictures on the screen are files too. To prove that we saved one in her home directory and learned a new command ls that you can use to list all files. And there it was! The "perhonen.jpeg" file was among "nakki" and "kissa". Permanently stored on her own hard disc. I explicitly asked her which part of the computer stores the files and she remembered that.




Then we used yet another new program open to open the image file. The pretty butterfly appeared in Preview. I promised her we'll get her a program that she can use to edit pictures too, but not tonight. Then, as a last funny thing, we opened the same file in vim to see that it actually contains just non-readable junk that only computers understand. Or more precisely, only computers running a suitable program.

So, we ended up having a very exciting lesson and it lasted half an hour or so. She could hardly keep her eyes open but always wanted to do more things. Could you believe?

Tuesday, August 20, 2013

Hot Air Balloons

We were going to have a lesson today before bedtime but the girls were so tired that it would've been a disaster, so it's good we just discussed the subject while eating oatmeal.

She was very anxious about getting to write "proper" games instead of the boring text things. She said she's ready to do that already, and she doesn't want to write anymore. Just real games with pictures and all.

So I used some analogues. Like imagine you're a small baby who cannot even crawl yet and you want to learn to run. We went through the steps that have to been taken before learning to run. Still, she wanted to get to the business of writing real games. Then we discussed how cool that would be. She found it quite unbelievable that some people make games for living. What a cool job! But, alas, to make these games you have to write a lot of code. We agreed that I'll show her the amount of code required for our little Fairy Game. So, we'll have a code review on that shitty codebase probably tomorrow. I hope it convinces her that you cannot make graphic games without resorting to textual editing.

Once again, just before bedtime, she wanted to talk about Vim and computers. Once again, she remembered just one computer component, i.e. the hard disc.

She wanted to know how the keyboard works. We discussed electric circuits and how the key presses are converted into digital signals that the CPU then processes. And so on. 

She also wanted to know how the LCD panel works but I had to divert her to the fact that there are three colors of pixels on it and using a combination of RGB, you can make up any color. We agreed to try mixing those colors as a bonus after the next lesson.

And hot-air balloons. She wants to see how many people die when one of those lands.

Monday, August 19, 2013

Lesson 6 - Scripting

Today we wrote our first script. This kinda patched together all the tricks we've done so far:

- Open a new file in vim. Walking in her father's tracks, she chose to name it after one of her favorite foods, "nakki" (wiener). She struggled with typing vim again, and had a hard time concentrating on the task. Maybe a bit too close to bedtime this lesson?
- Append a new line
- Write a familiar command. We decided we should use the say program again, so she wrote "say pitkätossu".
- Save and exit (she totally mastered this again)
- Run the script: "./nakki". She remembered that she has to use the shift key to enter the slash character, the keyboard position of which we had to find together.


She was quite excited to see what happens.

    ./nakki: Permission denied

That happened. I had forgotten file permissions! I offered to fix the permissions quickly but she refused the offer and insisted on doing it herself to learn it. So we spent some time typing and discussing "chmod u+x nakki". I taught her that she can use the tab key to auto-complete file names.

Back to running the script. She used the tab key to auto-complete the file name.

And the script worked. She learned that you can add any commands into a file and run the file as a script! A script is a file and it's a program too. Whoa!

Now she demanded that I teach her how to write children's games immediately and promised to listen hard. I promised she'll be able to do that when she's five, if we keep on with these sessions for a year.

The last line in the screen shot was typed by the non-vim-user kid.


Sunday, August 18, 2013

Scripting, meh

Today we discussed what we should do next. I suggested we should create a script, and explained that a script is a file and it's also a program and you can run it. You can put any of the commands we've used so far into the script file and run them all at once.

But she didn't want to have a lesson today. A bit disappointing that, I think it's best not to push this. So, we'll have the next lesson tomorrow.

Oh and yesterday I made some helpers to make Haskell programming easier, so that you can make ridiculously easy programs like

    say "what's your name" >> i >>= say . ("hello, " ++)

In the picture below, I'm sure you can guess which one of the girls uses vim.

Saturday, August 17, 2013

Lesson 5 - Slash and Search

Another lesson done.

She still needed some help typing `vim kissa`. Remembering that a space is required between the command and the filename is hard. On the other hand, she remembered that the program that we use for editing is Vim.

She totally mastered Vim today! Adding new lines was easy. She even typed `:wq` herself without any help.

As a bonus, we learnt how to search for images on the Web. Her first picks were "kala" (fish) and "robot".  She's typing "musta talo" as I'm writing this report. Searching seems to be a nice way for learning to write.

Thursday, August 15, 2013

A Goodnight Story

No lesson today, due to tight schedule.

But before going to sleep I asked her if there's anything she'd like to talk about. Guess what she said

- Dad, I want to talk a about vim

A moment of victory in the history of the School of Nerds! So we discussed files and text editors for a while, then moved to the topic of what parts the computer is made of. A bit later, just before good-night, I asked her what she remembered about the computer parts. I expected the Keyboard or Mouse, but it was indeed the Hard Disk that she remembered. 

- And what's on it dear? 
- Files, daddy
- And what's the name of your file?
- Kissa.

I think she already know more about computers that, say, 30% of adults. I bet we can reach 90% in a year. It's all about motivation.

Wednesday, August 14, 2013

Lesson 4 - delete

We repeated all the previous stuff. She remembered how to add a line and exit insert mode in vim, so at least some progress has been made! 

Piping was something she remembered too: she wanted to pipe the file contents to say to hear the funny mumbo jumbo recited by Alex the Default Voice. Typing the pipe character was easy but remembering alt-7 will take some more practise. 

The new thing this time was deleting rows in vim (type "dd"). It was fun and many rows were deleted.

Still, remembering the names of the commands vim, cat and say is hard. More practise needed.


Tuesday, August 13, 2013

Lesson 3: Revisiting vim, Piping

As I suspected, she had forgot almost everything about using vim. So we revisited the basic commands (open, add new line, exit insert mode, save, quit). In the end she was able to enter multiple lines on her own. We practised saving and quitting a few times. Maybe next time she'll remember at least one command...

The next thing was "cat kissa|say" which served to demonstrate the power of the command-line: you can chain simple tools like cat and say together to form new tools. This time we built a tool for reading her own file "kissa" and speaking it out loud. It was great fun to listen to the computer speaking through multiple lines of random characters. She recognised the word "OK" that she had accidentally typed somewhere between the random chars.

That's it. Baby steps. Repeat repeat repeat. Another lesson in before bedtime, maybe.

Monday, August 12, 2013

Lesson 2 : vim

We had another lesson today. We agreed that at the start of each lesson we'll recap the previous topics. So we did. She still struggles with entering the space between "say" and the thing to say. Otherwise she did very well.

Then we spent some time learning how to change the colors of the terminal window. Not surprisingly, she chose a red background.



The actual topic of lesson 2 was vim, which happens to be my favorite editor. Not sure if it's a good decision to go with vim, it having a relatively steep learning curve for typical computer users. In our case however, there's no bias, as she has no experience with editors, and does not expect to be able to move around with the arrow keys and mouse. So, vim it is.

What we did was

- "vim kissa" (we spent a relatively long period of time discussing what would be the optimal name for the first file)
- "i" to enter insert mode
- Random text
- "esc" to exit insert mode
- ":w" to save
- ":q" to exit
- repeat opening the same file again and celebrate the fact that the same text still lives in the "kissa" file!

Now let's see if she remembers any of these commands on the next lesson. I'm quite sure she'll be surprised and delighted by the fact that her file still exists and contains the same stuff.

Btw, How come Blogger defaults to Times New Roman?

The First Lesson

Today I started a new project with my 4-year old daughter, partly inspired by the "Kids cant' use computer" article. Also decided to blog it, partly to generate some pressure to keep the project going on.

I'll teach my girl to Use Computers. Like, use command-line tools, editors, understand the OS and the file system. And to Code. I'm sure it'll pay off. Right?

We are starting from a rather challenging position: she can't read or write properly yet. Fortunately, she recognises letters and is able to type them on the keyboard, albeit very slowly. Every keystroke requires a "full table scan" so to speak. 

Today I asked her if she'd like to learn to code and use computers with daddy. I was expecting a negative or neutral response, but she was actually quite enthusiastic to get started. So, why the hell not?

So we had our first lesson. What we did was

  • Learn to open the Terminal for command-line magic
  • Learn to use the "say" command as in "say mila", "say daddy". It was cool to have the computer speak. The real reason for this was of course to get some practice on using the keyboard and finding the keys.
  • Learn to type the special characters !:.
  • That's it!


We both enjoyed the first lesson. She said wants to have yet another today, so I deem it a success.