How To Encourage a Young Teen To Learn Programming?
Anonymous Hacker writes "I'm in a bit of a bind. My young teenage son is starting to get curious about computers, and in particular, programming. Now, I'm a long time kernel hacker (Linux, BSD and UNIX). I have no trouble handling some of the more obscure things in the
kernel. But teaching is not something that I'm good at, by any means. Heck, I can't even write useful documentation for non-techies. So my question is: what's the best way to encourage his curiosity and enable him to learn? Now, I know there are folks out there with far better experience in this area than myself. I'd really appreciate any wisdom you can offer. I'd also be especially interested in what younger people think, in particular those who are currently in college or high school. I've shown my son some of the basics of the shell, the filesystem, and even how to do a 'Hello World' program in C. Yet, I have to wonder if this is the really the right approach. This was great when I was first learning things. And it still is for kernel hacking, and other things. But I'm concerned whether this will bore him, now that there's so much more available and much of this world is oriented towards point-n-click. What's the best way to for a young teen to get started in exploring this wonderful world of computers and learning how to program? In a *NIX environment, preferably."
Whether or not you have suggestions for generating interest or teaching methods, there was probably something that first piqued your curiosity. It seems like a lot of people get into programming by just wondering how something works or what they can make it do. So, what caught your eye?
Teach him python (or ruby, or whatever else that is high-level and easy).
It's the same as basic was twenty years ago, just much more powerful, easyer to learn and more fun.
Tie two birds together: although they have four wings, they cannot fly. (The blind man)
I'll second that. Many of us learned on 8-bit home computers, where you could understand everything that was going on, and we made games. Brilliant self education.
The best way of doing that now is with the Hydra console. The hardware is completely documented and described at the beginner level in the book. And there is no OS or APIs to deal with, disguising what's really going on. You code straight to the bare metal.
Get him on a typing tutor first. It'll come in handy regardless of whether he sticks to programming. As he's learning to type, print out some interesting program listings (or get a book). Have him type in the programs (don't let him just cut and paste). Once he has the programs entered and debugged, have him modify or customize them.
Once he's done a few of these, he'll have experienced the rewards and tedium of programming and should be able to decide if this is the right path for him.
No, really. That way he can share his games or whatever with his classmates, simply by sending them a link.
Of course it'll be a longish road to get to that point, but it might be a goal he can relate to - and I know I simply wouldn't learn anything unless I could see the point. Still don't at 34, come to think of it :)
I started programming when I was about 12, and I am completely self taught. My parents knew nothing about computers, and still know nothing now despite my efforts. Anyway, i started with javascript, html, and php. (This was around 6 years ago). I think it was much easier to start learning the basics of this kinda stuff when you don't have to deal with all the boring (to a 12yo) details of memory management, libraries, and compilers etc. Web programming is something were you can get the instant results and action, you can just keep tweaking the source file and hitting F5 until you get something that works and looks vaguely like what you're after; this is especially useful when you don't know what you're doing. :)
I had a few books which taught me the basics, a javascript book and a html book. They only covered simple things, (I think the js book was a For Dummies..., actually), but it was enough to get me started. After that I found the php.net docs and a friend showed me loads of his php code and i picked that up fairly quickly.
Being a website, it's something easy to show off too, it was kinda cool to be like "dude, the whole world can see my webpage!". Following that theme, i got started on irc bots, eggdrops are written in C, and you can script em with tcl. Be careful tho, tcl is kinda quirky and weird (at least, that's how i remember it). But it's great for simple stuff, get the bot to parse some text and reply etc. This might also be a good time to learn some networking stuff. Also since eggdrops can also have C modules written, this is a possible path into C, although I didn't go that way so I don't know how good it is.
I eventually learned C(++) from some online tutorial, http://www.cplusplus.com/doc/tutorial/ I think. And I wrote a load of code for manipulating some large binary files (game resource files, from Halo). I certainly don't recommend letting anyone learn C solely from some tutorial, since I had rather large gaps in my knowledge at this point (that code i wrote is terrible), but it was some great experience anyway. I played around with some .NET (ugh!) gui stuff, because I didn't know how else to make a gui program at the time (seriously, I don't know how I was meant to know about qt, gtk, or win32 etc at this point) and a program that just prints text on the command line got boring real fast.
Hacking at computer games was what really drove my interest in C at that time. Reverse engineering of the file formats was fun! Even if I did kinda suck at it and just found most of the info on the web.
Looking back, I'm thinking I probably would have liked someone to show me python (and maybe perl) much earlier than when i eventually discovered them. php sucks as a general purpose scripting language and C gets tedious for those little tasks.
Sorry that was all probably a little incoherent, I spent the time I was meant to be doing english homework programming ;)
Not NetHack! It was written by the evil Wizard of Yendor with help from his idiot minion Eric S. Raymond; consequently, the source is a horrifying abomination worthy only of the renegade god Moloch. It is not a good learning example. You should be at least a level 20 Kernel Hacker to venture inside.
Can I suggest instead that you look for a simple game written in Python or Ruby. They are likely to have source that is possible for level 1 Noobies to understand.
As a teenager I liked the simple putpixel to draw on the screen.
You can see immediately what changes you are doing by changing x and y position and/or color. And ofcourse create your own line/circle/polygon routines.
When you can see what you are coding it makes it more fun.
Just my two cents.
... and let him learn on his own. Many of us learned programming from reading books and tutorials, and most of all from just trying stuff.
So if he doesn't have it on the machine, install a compiler or interpreter for the language he tries to learn, give him a link to a good tutorial, and then just wait and answer his questions.
If his geeky farther isn't available, it might be good to know where to contact the community for help (relevant web forums (like perlmonks if he choses perl), mailing lists or the like).
If he (or you) doesn't know which language to start with, be sure to pick one where he doesn't have to bother about memory management first. That kills the fun at first, and segfaults are hard to debug.
Personally I got into programming after reading those strange books you used to have as a kid where depending on the decision you made you had to switch to a certain page in the book.. I tried to program my own story-game that way. Basically it was just a load of simple IF statements, but it is what got me into programming.
I also made a few simple scrolling graphics projects. Mostly huge "spaceships" which scrolled across the screen, made with ASCII blocks hehehe..
This was when I was about 10 I think.
I can't tell you how to teach, but I can tell you how I started to learn.
My father bought a MicroBee with a tape recorder. He bought games, and I played games. I wasn't interested in programming. He did however code together some small text games, from magazines.
I played those too.. we solved adventure games together, and when we couldn't progress any longer, we looked at the code.. but neither of us understood it.
Ofcourse this didn't teach me to code.. what it did was to teach me that there were code, and that computer programs was code.. and could be reed, modified at choice.
Then I got my own computer, a Commodore 128, with basic.. I didn't touch basic for a long time.. I played games.. but when I got stuck in a game, I did know.. that the games code somewhere did hold the solution for my problem.. I coded a few hundred lines of basic on that machine..
I got an Amiga, and with that came AMOS, a basic. It was coding in a secure environment. You couldn't touch the hardware (well maybe you could). And I started to do some coding for fun in it.. After all I did know what all computer programs was code :-)
After that I was self going, and installed Linux and reed C manual pages. I bought a C++ book and started to learn how to really code.
--
I guess that todays version of this would be to show him games, and from his age I guess you already have.. So I would get him VisualBasic. Powerful for the beginner, yet no need to peek and pook memoryaddresses :-)
I've seen a few other people mention story writing, and I'd second that whole-heartedly. My friend and I first got hooked on programming when we started writing simple 'Choose-Your-Own-Adventure' style branching games in Q-Basic (complete with sqealing PC speaker musical soundtracks).
My friend even got more sophisticated and started creating simple RPGs - random number generators with modifiers for the attacks, variables for vital character stats, etc. They were alwasy *very* simple, but we had a great time, and learned a lot as a result of it.
Doesn't matter if it's a simple text game.
It's better if it is. Fewer moving parts, much easier to see what's going on.
A pretty good one to start with is a number guessing game. Teaches about control structures, IO, state and validation of input. Go from there on to something like the Animal Game. You can use that to teach about decision trees and persistence. And that covers a very large fraction of the foundation of computing.
"Little does he know, but there is no 'I' in 'Idiot'!"
My first (memorable) program was written with my dad on the C64. He's not a programmer, but we got a C64 when I was about 4 or 5 and I was keen to know all there was to know about it.
He started reading magazines and got some books that taught him the basics then we'd spend time together building basic (pun intended) things. The first one that did anything memorable was a christmas tree on the screen complete with a flashing light on the top.
It was all downhill from there. Once the basics are in place more and more advanced things follow. Soon you've outgrown your interpreted language and are sitting at the machine level to make it do things fast enough.
Of course, back then it was all very easy. The 8-bit machines only had a handful of opcodes and a small amount of unmanaged memory (well the C64 had a ROM bank that you could cut out if you needed the RAM it shadowed). To make graphics it was a simple matter of poking in a few registers and then writing to the graphics memory directly.
There was no pesky OS or memory management getting in your way. The machine also wasn't very fast, so to do cool things you had to learn about interrupt driven events, 'multi tasking', and designing for optimisation from the start.
These days learning programming like that is nigh-on impossible. The OS hides the machine from you and presents a not-so-neat interface to all the hardware. The machine is fast so there is never any real desire to optimise and programmers aren't learning good principles for it.
If the GP's teenage son is really interested in learning programming perhaps a small microcontroller project would be a good place to start. PICs and AVR cores are quite simple to implement and program. Investigate a development kit instead of diving into programming the PC.
I drink to make other people interesting!
Try Alice. It's the 21st century version of turtle:
Back when I first learned PERL people were still using it as a Practical Extraction And Report language. A replacement for Sed & Awk. I was taking snippets of Perl from the web, futzing with them, and searching instrument logfiles and pushing the output to comma separated text files and then to excel. I don't remember if they were one line scripts but I do remember frequently using snippets that I wasn't really sure why or how they did what they did but only that I wanted the output they provided. Wow! I remember the first time I really had that going... it was like effing magic.
Nothing in the world is more dangerous than sincere ignorance and conscientious stupidity.
IMHO, if he has already started teaching C, then that is what he should use. Not because C is superior language, but because teaching multiple languages will certainly confuse the student.
I think that C might actually be pretty good language to start with. You have to do a little more work to write something you might be able to write less lines in e.g. Java, but then again it is pretty logical how things work. E.g. first you initialize SDL, then you get the surface where to draw. Then you draw into it, then you display it.
In Java, you initialize by creating certain classes inherited from certain classes, get the drawing surface as a method parameter for a method, which name must be something special then you draw to it and then it is automatically displayed. Then you have to study API to find out how is it updated.
I'm not saying that Java is hard to use for experienced programmer, I think it is very easy. A lot easier than C. But IMHO it is harder to understand for someone new to programming. Or even someone new to Java programming.
No job prospects?
At his son's age I learned to program in Pascal and was grateful for the privilege. I even had to compile in the snow uphill both ways. See if I put that on a resume.
Python is a great language to learn on, and there are more and more serious projects that use it especially in the scientific community. If he enjoys python, he'll move on to more powerful and commonly used languages lick Java, C++, and how could I not mention Fortran. (Actually Fortran wouldn't be a bad language to learn on if he's a math nerd. I'm not entirely joking with that.)
For most people programming is a long road of breaking your head against a problem until it gets solved. Long hours spent tapping away at the keyboard and honestly "normal" people think we're all out of our minds.
And then most of them go back to driving a truck, or waiting on tables, or shuffling paper, or laying bricks or whatever "normal" job it is that they do.
Don't get me wrong, I'm not saying that there's anything wrong with any of those jobs, but let's face it - they're not exactly riveting, and yet we are the mad ones...
It's official. Most of you are morons.
You could try PHP/HTML and maybe get him to mess about with the Facebook platform a bit. It's not too hard to learn and at least that way he can share his creations with his friends. Being able to show off my programs to my peers was hard to do when I was a nerdy teen writing ugly ugly C on my amiga. Back then it was all about finding other people with amigas and swapping floppy disks like they did on The Flintstones.
jumping in wasn't too hard when the first thing you looked at after bootup was the Basic interpreter.
Get off my lawn you whippersnapper!
I started with a NASCOM-1 1MHz 2K RAM (1K for you, 1K for the "monitor" program) Z80 kit in 1978. When I finished soldering it together the only thing I got after bootup was a prompt at which you could enter hex bytes (after you hand assembled your program on paper) to a chosen memory address.
I'd actually consider this approach for someone learning about computers today. Buy an Apple II off eBay ($20 or so) and start programming in assembler. Write an interrupt driver serial driver or something that interacts directly with the hardware. There are too many kids nowadays who may know how to program in some modern scripting language, or maybe even in C/C++, but still don't really have an intimate knowledge of how computers work at the lowest level.
Agreed! I think graphics are a great way to get young folks interested in programming. They were the thing that captured my interest the most anyway. I can still remember trying to figure out some Apple BASIC code that made a little blip bounce around the screen back when I barely knew what a less than sign meant. But if making things move around on the screen doesn't motivate your kid, then find out what does. Other projects I remember working on early on were tools to make D&D characters, because I liked playing D&D but thought the process of re-rolling the dice a thousand times till I got the stats I wanted for a character was too laborious :-) Also my friends and I tried to create a computer version of the BattleTech board game. We had know idea what we were doing, and never got anything even close to playable, but I still learned a lot from it, and over the subsequent years as I learned knew tricks and techniques I always could recognize them as something useful, as something that would have helped us get over one hurdle or another I faced on those early projects.
These days I think maybe young folks might be more motivated by web stuff that they can show their friends. Hey check out my web page! (Which would suggest javascript or java as the first language) We didn't have a modem till I was in high school so those things weren't really an option back when I was learning. It looks like a lot of kids are writing silly plugins for Firefox too.
But still I think graphics is good, because before long you start to see that you need to learn some math to do more interesting things with it.
Moffett's Ghost
Hey it worked on me when I was a kid!
"MIT betrayed all of its basic principles."
I don't know about, but agree with the graphics aspect... I got into computing first because I was into games. I stayed with graphics all the way through and work for a post production company writing tools and utilities... not exactly graphics, but I do get to write plugins and scripts for Maya and other high end apps.
Anyway, I was pretty much self-taught BASIC on my Atari, but BASIC was just too slow to do any cool graphics, so I started teaching myself assembly language.
I don't advocate having a young person teach themselves assembly language, but it gave me the kind of knowledge about how computers really work, what's going on at that lowest level, how memory is used, what a stack is, pointers, everything... you don't have to become an ace assembly language programmer, but it's a great introduction to how things work at a really low level.
By the time I was in college, I was writing graphics libraries in assembly language to use with Turbo-C++; I was writing that VGA setup code, I figured out how to do real memory mapped scrolling (and was even listed in the graphics FAQ for a time, along with my code).
Now I don't touch assembly language anymore, but I think when someone understands everything that's going on, they can gain a much better grasp of what's going on - they understand memory management better, they understand the limitations of the machine, they can learn about cache... I really think the people I've known that had that low level experience actually learned how to structure high level code better.
It can even go in parallel... here's the C++ code for "Hello World," and here's how you'd do it in assemble language.
If they can grasp that, then explaining byte-code languages becomes even easier...
I know a lot of people would think this is like learning how to build a car before learning how to drive one, but I don't think it's a good analogy; but it is true that in many places in the world, some basic maintenance skills and understanding of how the car works are crucial to getting a license to drive.
When using the high level language and a library like OpenGL, it becomes important (IMO) for them to know what OpenGL is doing; it's important to know what different types of shading are, the difference between indexed and RGB (or other colorspaces), the basic algorithm for drawing a line (again, I implemented things like this in assembly because, at the time, computers were just too slow... not necessary now, but a grasp of the algorithm is beneficial, IMO), matrices and how to calculate rotations... if you understand what OpenGL is doing, it becomes a lot easier in the long run.
Stupid sexy Flanders.
> I don't see that not having a flashy GUI means anything.
No, but having a simple to use GUI editor (Delphi back in the day or maybe lazarus nowadays on Linux) means you can quickly get results, and you can have a GUI without lots of frustration. None of the GUI toolkits IMO qualify under the "keep simple things simple to do" criteria.
For someone who like me likes mathematics, geometry and graphics, OpenGL is very nice and to me provided a natural way (and reason) to transition to C.
I had open access to an apple ]{ at school about 2 hours a week. The others did not know the computer existed (kind of).
So I learned basic from the documentation. It was rewarding to learn to master it with no outside help.
I programmed games (pacman, tennis, snake) all with less than 200 lines of basic code.
I programmed some math programs to plot functions
And then I programmed my own drawing code to generate bitmap images.
All this was great for my self esteem.
Now we are in the year 2008, so here is what I would suggest:
Coach him just a little bit, point him to the right tools, then let him learn by himself. Just congratulate him on the progress he makes.
One thing of course is to point him to something modern enough. I would suggest java inside Eclipse (part of linux distributions.
He can start by using just one object and not use anything object oriented, then he ca nlearn object oriented programming, graphics, network, etc ... ...
There are lots of java one page samples
Have fun,
Georges
Java is a great language to get started in. Just about anything that you want to do you can do in Java. It might not be best when written in Java but it can be done. I started programing in QBasic moved on to VB and then C/C++ but I only got sucked in to it once I started with Java. It's also the top language out right now so it's very practical.
More important then the language is that you figure out what he likes about programing. Keep his interest alive. I started coding when I was 10 but around the age of 14 I almost entirely stopped. I lost my drive. I was using mostly VB at the time and it was just too much of a pain in the ass and I had nothing to really show for it. Additionally I got to the point where I could not learn anything else about the computer when using Windows. Yet I was not able to jump in to Linux because 1)I knew too little about it 2) I had no one to show me the way. I basically got stuck until I got to college.
So basically keep his drive alive by...
1)Let him pick the projects and just grease the wheels. "Oh you want to do X? learn language Y." "Let me see if I can help you with that bug." He might not be at all interested in the same things you are and there is nothing wrong with that.
2)Give him the guidance he needs but don't force him in to anything.
3)Don't be afraid to learn something new so you can help him with it. It is far easier for you to learn something new then for him, you already know programmer speak.
4) On the topic of programmer speak show him Slashdot or Digg or something like that. Programmers have started there own culture in these places that he might be interested in seeing. Digg might be best for him for now but once he learns more Slashdot is likely to be more his speed.
5) Be a mentor not a coach. Just make sure he is not going to any dead ends like Visual Studio or Windows. You can only learn so much about them before you are not allowed to learn any more.
6)It sounds cheesy but be proud of him. Getting started in this is a lot of time that he could be using to hang out with his friends or play games. It's hard to keep going when your not getting anywhere yet AND no one is impressed with how hard you are trying. Just don't embarrass the kid by telling EVERYONE you meet "Little johnny just started programming!"
is perfect - immediate gratification as well as using APIs.
I have kids around the same age, and got them into the Alice environment for a while. It fell out of favor after a bit, but some of the concepts seemed to help later on when my son got a Lego Mindstorm set. My son is currently digging showing off pics of his lego creations on the lego community kids portal. He keeps bugging me for a "real" digital camera, as he has one of those cheap $15 deals from Wal Mart. I've been toying with getting him a better camera, registering a domain name for him, then teach him the basics of HTML and see what he does with it.
Method of processing duck feet