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?

No comments:

Post a Comment