Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Junior Perl

by Odud (Pilgrim)
on Jun 12, 2001 at 00:15 UTC ( [id://87639]=perlmeditation: print w/replies, xml ) Need Help??

To keep us occupied during the summer months my eldest daughter (aged 9) and I have decided it would be fun if I were to teach her programming. For obvious reasons Perl is my language of choice but the problem I have is in devising a syllabus that will both teach her the rudiments and keep both her and me entertained.

(Sadly) As I guess that most of the monks are closer to their childhood than I am I would be interested in any suggestions that you have on appropriate topics that will lead us from the basics through to more advanced topics.

It’s not that the teaching worries me – I’ve done lots of courses on lots of topics but mainly to “computer literate” people – and in general they understand what it is you are trying to teach them and why. But perhaps this is very difficult and very different to convey to a 9-year-old.

As a first shot I was thinking about something on the lines of:

Suppose you spend x at a shop and give a note of value y – how does the shopkeeper give you change?

Teaches: simple arithmetic, looping, lists, sorting, etc. – and also relates well to the real world.
The first “useful” program I wrote did ‘straight line of best fit’ - given a set of x,y coordinates it told you the mean x,y value and the intercept on the y axis. Historical Note: this was written in BASIC and ran using a dial-up connection to a time sharing company with an acoustic coupler (ask your parents!) – I later converted it to ALGOL. At the time this made sense to me as, in 1970, I was doing O-Level (I don’t know the US equivalent but it’s the exams you do at age 16) physics and chemistry. Then I got more interested in maths and the next program solved cubics – Newton-Raphson iteration to find the first root, synthetic division to turn the cubic into a quadratic solved by the usual means. And on and on but always with a practical basis.

So my background has been programming as an aid to solving problems rather than something in itself – my problem is how do I translate this into something that a 9 year old will be enthusiastic about and learn from? – and that both of us will enjoy and learn from>
You have lots of time to think about this and we can discuss suggestions – we are planning to start in July – if people are interested in this topic then I will be more than happy to provide regular feedback on how we are getting on.


Update: Thanks to everyone who has commented on this node - I'm very impressed with the feedback that has been provided - I'm now working slowly through them so that I don't miss any important points

Replies are listed 'Best First'.
Re: Junior Perl
by footpad (Abbot) on Jun 12, 2001 at 00:30 UTC

    I would say "keep it relevant." Consider a number of different scenarios important to her, things she can relate to and learn from. Some example applications:

    • A simple contact manager for tracking email addresses, phone numbers, birthdays, and other tidbits. This lets you lead into the rudiments of database theory, SQL, reporting, and so on.

    • A "wish list" application for tracking gift ideas, one that allows people to log in, locate an appropriate gift for a person, and then "reserve" it (to prevent multiple people from sending the same gift). This gives you authentication, cookies, and more database design opportunities. (Naturally, the recipient can't see who reserves a gift or even if it's been reserved.)

    • If she's into any form of competive sports, perhaps a stastistic tracking thing.

    • If she collects anything (comic books, glass figures, whatever), then a catalog system, perhaps, one with ties to the wishlist.

    • If she's into astrononmy, then perhaps a viewing log.

    • and so on...

    In other words, identify programs that she'd find useful, relevant, and interesting, and then design the course to lead to their development. Also, get her input. I'll bet she'll enjoy the collaboration. In turn, this should generate enthusiasm and additional commitment.

    In turn, make these deliverables, with milestones, requirements, documentation, and pay-offs for hitting the goals. These don't necessarily have to be monetary, but they should be tangible. Perhaps you do her chores for a week or something similar.

    In addition, make sure she knows your responsibilities and that you have milestones of your own.


      These are all good ideas – thanks. Currently she is into reading and borrows loads of books from the library. A simple program to record title, author, and her comments on the book would be a good start. This could be expanded to use databases for storage etc., and perhaps a simple web interface. I like the idea of introducing milestones and deliverables etc. at an early stage – it’s something that very good programmers often struggle with, probably because it is not learned at the same time as programming.
        And an automatic reminder (conditioned on weekdays, a few days earlier, possible vacations) to give them back.
Heresy Re: Junior Perl
by Zaxo (Archbishop) on Jun 12, 2001 at 08:06 UTC

    I have a radical suggestion, and a touch of disagreement with my esteemed brethren.

    Some observations about children: they pick up language and patterns easily. They dislike sustained projects (though they often are obsessive about an interest). To them, the real game is learning the rules, not making a product.

    What do you think of teaching text manipulation and regexes? Start with tr///, a Secret Decoder Ring. She can have fun with literals: s/Fido/Gimlet-Eyed Guardian/; s/Father/Couch Creature/; s/cat/dog/ .. hehe dogalog. Hmm.. can we avoid that? Time to find out about word boundaries

    I think she needs no relevant project, just to learn the syntax and enjoy making lots of tiny programs. Like any other language, she will soon stitch together what she's learned into programs you never dreamed of.

    Even experts like to do their learning on tiny irrelevant programs -- hence golf, obfu and poetry.

    After Compline,

      I guess you are saying to introduce lots of small building blocks and see what she can build from them. It sounds good and I think I’ll try to do that. I wasn’t planning on keeping the difficult stuff for last but rather to introduce it when it appears natural. s/// in its simple forms shouldn’t be too hard to understand and the more complex use can be built up gradually as the need arises. Simple text processing should be introduced from the start. I always found this to be hard in the languages that I first learned – because they didn’t have the features that make it easy.
Re: Junior Perl
by shotgunefx (Parson) on Jun 12, 2001 at 00:49 UTC
    My start in computing was totally driven by games.
    There's not many computational problems that you won't hit eventually, so game programming would be a good start to hold her interest I think.

    I'd keep it real simple at first. Since vanilla perl isn't graphics oriented I would stick with maybe a simple game like blackjack to start perhaps or maybe even a MadLibs type of program. The both would cover input, conditional logic etc. I don't think you want to go to far, right off the bat.

    I don't know if anybody here remembers Gorilla that shipped with QuickBasic but that might be a good second project. It's simple but fun.


    "To be civilized is to deny one's nature."
      Games sound good – I remember a program that guessed what animal you were thinking of by asking a series of questions (has it got four legs?, wings etc.) – it also had the ability to learn about new animals and would fit them into its classification tree. I guess something like that would introduce all the programming concepts pretty quickly and yet still be fun
Re: Junior Perl
by pmas (Hermit) on Jun 12, 2001 at 01:01 UTC
    I understand that perl is your language of choice. But is it the best language for solving tasks relevant for your daughter?

    I believe perl is good language for many tasks, but sure not for all tasks.

    I have also son, 10 years old now, and am also thinking about introduction to programming. But I was thinking about something different:

    LOGO is excellent, because Jr. can have visual clue what is going on, and what might be wrong. Visual clue is rather important, at lest on the cognitive level of my son (he is reading sfi-fi Foundation series now)...

    Also, it is simple to define subroutines in LOGO, to extent language where you want to. You can do a lot of things without even begin to worry about variables.

    My another choice is some language for programming adventure games, to program simple game. I want to research it little more...

    Yet another choice might be "Baltazar the Wizard" from Czech republic. My older son played with it a lot on DOS couple years ago (I just recalled this - no idea if it is still avalable). I was impressed how smart animations were pssible in it - with custom graphics.

    I'll bookmark this node. Insight of fellow monks is sure much appreciated.


    LOGO is language oriented to 'turtle graphic': To give comands to draw shapes. For your 'feeling' about Logo, here is how to define a procedure to draw a square:


    Then, SQR 20 will draw square. You get the idea.


    To make errors is human. But to make million errors per second, you need a computer.

      I don’t yet know what her school are planning to do – if they are going to introduce LOGO or something similar I don’t want to clash with what they are doing – however thanks for the links and I will explore them as I am sure they will have many ideas that I can use even if I don’t use the language directly.

      Looks like Baltazar is now called Baltie.

      We'd like to help you learn to help yourself
      Look around you, all you see are sympathetic eyes
      Stroll around the grounds until you feel at home
         -- P. Simon in Mrs. Robinson

Re: Junior Perl
by Xxaxx (Monk) on Jun 12, 2001 at 10:53 UTC
    In addition to the many good comments in the above material I'd like to suggest a deliberate use of XtremeProgramming. That's just a fancy schmancy phrase for two people working at one computer on a program of mutual interest.

    If you daughter happens to be a fanatic on any given subject, such as a singing group or favorite cartoon it might be possible to create a useful script which would serve her keen interest. A database of all known Pokemon might be good for some kids. Or perhaps for a young girl a Barbie's Diary program. For an introduction to programming it might be great fun to do a project with you. But the results will need to be very inspiring.

    If you want to get a youngster interested (and capable) at solo programming it might be a good idea to look into something such as Legos robots. They have a fun interface. You can "write" programs to make the robots do things, then download the program into the robot. While this is not a highly developed language it is one you can quickly turn a youngster loose with. This is very similar to the old Turtle program from Pluto (Plato?) days.

    For a rather young programmer I think the best approach is to infect them with the delight in having the environment do stuff based on commands written into a "program". For this the loop (and frustration cycle) between command and "cool stuff happening" should be minimal. Later when they are a trifle more developed Perl is excellent.

    Have a fun and productive summer,

      I was reading about XP a few weeks ago - lots of the ideas will translate well into teaching a youngster I think: stories rather than specifications, incremental changes, testing first etc. From the start I wanted this to be a joint exercise rather than just sit her in front of the screen and let her get on with it - we should both gain from it - she learns to program and I learn to teach at a much lower level than I'm used to.
Re: Junior Perl
by dragonchild (Archbishop) on Jun 12, 2001 at 01:35 UTC
    I remember back to my first programs (in Apple Basic). They were very simple things, like "Whodunit" or "Twenty Questions." Things that take input, parse it, make decisions, then give output.

    Once I got to school and started learning in a structured fashion, most of the first semester's assignments were like that as well. "Write a program that will solve arithmetic problems." "Write a program that will check spelling in a given file." "Write a program that counts the number of XYZ."

    I think most of the respondents have the right idea - give her problems that are relevant to her life. Perl may not be the best language for this. Personally, I plan on starting my kids (when I have them) on Turtle-Logo or VB - languages that are graphically oriented. That way, they can write stuff that they can get immediate results out of.

    Then, once s/he comes up to me and says "How can I do X?" and Perl is better, I'll introduce him/her to a more structured language, like Perl. Or, maybe, just leave them in VB for a while.

    Now, this may sound like heresy, but the point is to teach good programming practice, not advance a religious belief. I learned good programming habits in PASCAL on a VAX/VMS. C was this really neat thing upper-level students used ... until I got to learn it that summer. Then, I realized it was just PASCAL with funny syntax and new operators, but allowed you a lot more leeway to make mistakes. Once I realized that every third generation language is essentially the same, I realized it didn't matter what language I wrote in, so long as it was appropriate for the task. (It just so happens that Perl is most appropriate to the types of stuff I tend to work on!) Teaching a child to code in XYZ isn't a bad plan, just cause it's XYZ. Teaching a child good programming habits and style is a good plan, regardless of language. A younger child will benefit from the easy graphical coding that VB or Turtle-Logo has. Then, let them decide when that language doesn't have enough tools. They're learning the language, not you.

      Oh Perl wasn't any sort of religious choice - it was just to avoid "now the way I'd do it ..." issues. Since she hasn't done any programming already at school I felt free to pick any language - and Perl provides a huge amount of power and flexibility without (very) complex syntactic effort - or at least that's how I see it, but then it's so long since I had to learn any language from the ground up what do I know. I appreciate your suggestions for first programs however, I'd forgotten the delights of such simple programming tasks.
Re: Junior Perl
by xphase_work (Pilgrim) on Jun 12, 2001 at 01:22 UTC
    I know that when I firsted learned BASIC, I was interested in the
    choose your own adventure books(This was 4th grade back in '90)
    So my classmates and I would program little choose your own adventure
    text games. In general you either died at the end, or turned into a
    girl(died, this was 4th grade). Writing the programs was fun, and
    we'd plop it on a disk, and trade with each other.

    So now that I'm done with memory lane, what you might want to do is
    pick something that interests her... Music = make a music catalog,
    something that you can expand upon and increase the challenge throughout
    the entire learning process.

    I was going to say more, but while writing this, my boss came and spent
    20 minutes telling me nothing at all


Re: Junior Perl
by mattr (Curate) on Jun 12, 2001 at 15:49 UTC
    I can tell you about a project I did which was a lot of fun. I was somewhere between 11 and 13, with my Apple II. That should tell you when it was, since it came with only Integer Basic (no floating points) which didn't get fixed until I added a 16KB Language Card for Pascal and Floating Point Basic (Applesoft).

    Anyway my Dad had this amazing collection of National Geographic magazines, you know with the yellow spines, going back for years. It was in a cabinet in the basement and we would often go down and search the several keywords which were on the spine of each one of the magazines. We'd be talking about something and suddenly my father would say, let's check out the National Geographic, or maybe it was let's see what the Encyclopedia says. I do remember reading a couple sets of encyclopedias but Geographic was great because of all the maps inside.

    Well maybe the best of all was a year end compilation of the World Book encyclopedia set we had, because one edition had a fantastic description of Smalltalk and how you could control an actor on a stage (well that's Director and Lingo now.. maybe another good avenue for you to check). Images of this incredible personal, programmable environment danced in my head for years. I dreamed it existed inside an infinite digital watch, etc. I think my dreams were better than those space invaders watches they came out with. Anyway, next best is probably the map of the Moon in Geographic. Point is, these things stick with you. I took two classes at a high school on Saturdays, fortran with punch cards (it was fun but horrible since we had no idea what we were programming or how) and astronomy (which was plain great, this high school had a mini planetarium!). Now, I program and I'm into astronomy.

    Anyway I got this idea to build a system to organize them and in the end you could input the keywords, date, and article names in each issue and run a search. This was in Basic but it would be similar in Perl. The interface was a plain text terminal display, maybe ANSI and curses would be good.

    I also remember once doing a school art project that consisted of an animated drive through a vector graphic drawn desert, you drove with a game paddle. These were ideas I came up with after learning some of the basic things that were possible.

    Anyway to go on about the Geographic system, I think if you have a similar collection at home and use it similarly this would be great since your child likes reading. Or maybe if you have dinner time discussions that turn educational like we did, you could assign something to look up (all us kids would get picked on one night or another to run up the stairs and come back with the right encyclopedia entry for example).

    You need to keep it very simple, relevant, and hopefully rich in the sense that you can keep using the same system to work out different things to try in the future (if she is still exploring and not bored with it). So you might just start with hard coding the names of some tv shows and printing them out. Then you could sort them. Then maybe what time they start, and then you could print everything on Friday Night, and so on.

    If there is an analogue now, maybe the first place to start is learning how to draw colored bars on the screen in vertical or horizontal orientations using commands like "color=xxx" and "line a,b to c,d". You can draw pictures together easily and if you have thick bars (maybe they are one character thick) you can fill the screen with impressive designs in no time. This was a lesson that sunk in. If you are on a budget or want to keep everything in the same programming environment so the tools are always at hand, you might even create Perl packages for your daughter, I'm thinking of something that uses Readline and maybe curses to provide a prompt and mimic some of that great Apple visual feedback from minimal inputs. Maybe you would separate the prompt from the plugins, and provide another plugin which draws each letter she types as big as the screen. Maybe you could have it print a page for each letter. This kind of thing is easy for kids to understand and is fun, but an explanation of how it works is always possible too.

    One possibility that is quite easy is for you to get an Apple II simulator like Catakig. I love it not just for nostalgia but because it has less clutter and more meat. You can also get software for free, one I recommend is Infocom's Zork, a text adventure (like unix adventure) but with a very good natural language parser. "Go North" and "Examine Lamp" are the kinds of commands that would get her used to a keyboard, creating her own imagery based on detailed descriptions, and getting her used to navigation in virtual spaces.

    The other thing is, Perl is wonderful but there are lots of interesting things out there for kids to learn programming. I tried Logo but didn't like it. To clarify that since there is a related comment above, Logo is great for some things but once you get the basics, I at least felt constricted by a sandbox, which is exactly where you are. You don't get dirty. The Apple and Basic was just right for me since I could do graphics, mess with the modem, even mess up the monitor's frequency by blitting values to the framebuffer from 6502 assembly code. So while I do know Perl will grow with your child for a long time, I'm not sure she will be able to do visually exciting things unless you help her.

    I think you might want to supplement your Perl lessons with use of other visual programming methods (if there are any which aren't actually harder to use than Perl). I'm thinking of my 150 in 1 electronics set, which was a blast even though I got stumped by most of the poorly documented schematics in its manual. I still wish I had had more help with electronics at that age, I just remember being stuck with the schematics and then a heavy tome on logic and gates.

    Maybe a visual music synthesis environment would be good. I'm thinking of MAX which lets you wire components together on a screen and actually control external devices or generate tones. It is professional but I think kids appreciate that. However it can get pretty technical so you will have to answer a ton of questions. The neat thing about both MAX and Perl is that you could purchase things to attach to your computer so that your child can control physical things with it, for example lights, speakers, cameras, and so on. One friend I know is a digital artist who used MAX, Perl, and the web to wire up a seismograph in California with an exhibit space in Tokyo.. and with MAX the data sent over the net drove all kinds of great bass rumbles on a 5 speaker system in a cave-like environment. You could lie down on the floor over the bass speaker and feel the rumble intensify as the Earth released the stress in tons of rock. I'm sure that sort of experience, and understanding how it all works and being able to tweak it, is wonderful for giving creativity free reign and learning concepts with all the senses. At least I know I would have been pretty impressed as a 9 year old!

    One last idea is Sim City. I have always remembered a trip to the Toronto Science Museum where they had a few color displays built into podiums with touch screens that showed a fire fighting simulation. You could start fires, dig trenches, spread foam from helicopters, and so on over a map of a forested area. It was very fast, interactive, and had great sound effects. It was similar to the exhibits in the Franklin Institute I saw once too, which had a button for almost every exhibit which you could use to make things move. A simulation gives you a good tactile feeling of dynamics, and all of the three systems above are transparent and to some degree conducive to hacking. There is a little known title called Sim Tunes by a friend named Toshio Iwai. There is a demo here. This and other related titles (he has done one for the playstation) let you compose your own music in a wild animated environment in which you draw your composition.

    If you can keep things simple and let your daughter think up her own ideas while shielding her from the daze we sometimes get from information absorption overload, you both will have a lot of fun and she will have a great head start in whatever field her interests end up taking the two of you.

Re: Junior Perl
by busunsl (Vicar) on Jun 12, 2001 at 11:05 UTC
    I'm thinking about that too.
    One of the problems I face is the lack of good books for children in german, though here is a good reading about that.

    Another point is keeping the tasks interesting. footpad made some good points here.
    25 years ago I was happy programming space invaders in ASCII but times have changed.
    Kids like to do something graphically and that's not easy in perl, so I even considered switching to java.

    Further reading: Perl as a first language, Not-So-FAQ about learning Perl

Re: Junior Perl
by hsweet (Pilgrim) on Jun 12, 2001 at 05:50 UTC
    Interesting idea. I'd be interested in how you go about it and how well it works. I am the father of a 9 year old and have taught (none too successfully) a VB course in a high school. Next year I'm planning on switching to perl and looking for good beginner projects.
Re: Junior Perl
by hsweet (Pilgrim) on Jun 14, 2001 at 06:06 UTC
    Just tonight I sat down with my 7 year old daughter and we wrote this snippet and had a lot of fun with it. (Just prints words backwards) We might add a bit to it to print a whole story backwards. print "Type a word\n"; $word=<STDIN>; chomp $word; $backward=reverse ($word); print $backward; Anyhow, I think this is about the right speed for a kid. Language things are fun, and it was easy to explain that $word is a kind of noun, print a kind of verb, ; is like a period at the end of a sentance. The idea of algorithm will kick in as problem solving if we try to work with whole (English) sentences, since we will have to reverse the words first, then the letters in each word to keep the whole thing in order. Plus you would be using Perl as a text processing language which it is real good at. I figure it should be possible to do simple s///'s at some point to screw up certain words.
      That looks just the right sort of thing to do - it's fun, silly, and instructive all at the same time. As long as s/// is approached simply at first it shouldn't be too difficult to introduce and can do fun things. I was planning on something similar to start with. You could probably do something good with splitting a sentence into words and then printing them out in random order - introducing split, lists, etc. Then perhaps have a hash that holds replacements for words etc...

      The only thing that concerns me is the lack of graphics as I'm not sure how long simple word games will hold her attention. I might look at doing something with Tk - perhaps create a very simple interface that lets you do things with colors and text, it should be possible to package away most of the complexity - I'll post it if it works out.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://87639]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-05-22 05:24 GMT
Find Nodes?
    Voting Booth?

    No recent polls found