Why kids don't program
johnlawrenceaspden.blogspot.com
johnlawrenceaspden.blogspot.com
If in 1983 I could have googled sin and cos or read about it in wikipedia, I would have wasted much less time.
Among computer programmers this behavior is particularly common. I have a hunch that it's because smart people (programmers) are of often afraid of "starting over." And honestly I consider this the locus of pointless debates about programming languages, text editors, frameworks, et al.
To be like a kid again - and feel out of your comfort zone is the essence of self education. Children are little more fearless in this regard. If they are not, they should be reprimanded. To see this behavior in adults is lamentable (though understandable considering our nation's pathetic public education system).
I also remember not knowing what sin & cos were - but I also realized that they didn't have that much to do with programming in general. There was plenty of stuff left to learn.
I can see how. In fact I had the same reaction initially (and my parents are graduates, but they don't know the first thing about maths, so they were no help to me either).
I have no idea why I wrote the program to plot a circle that made it obvious what sin and cos were.
In fact I think I might have misremembered my own story. I had a ZX81 first, and I don't think that had a circle function, so it may be that the ZX81 manual explained how you could use SIN and COS to do that.
But I think we can agree that google and wikipedia are wonderful things. The upcoming generations of programmers and mathematicians are going to be Gods. How could they not be with a library like that!
Luckily the internet bubble came along just at the right moment, made it really easy to become a programmer on the job and now everything is fine.
I think you're correct here. I had a ZX81 first too (then various Spectrums, a VIC-20, and a Dragon 32!) and I also seem to remember the ZX81 manual telling you how to draw straight lines first, with FOR loops, and then progressing to circles.
The upcoming generations of programmers and mathematicians are going to be Gods.
Google and Wikipedia are awesome. I would have had my head buried in them all day if they had existed when I was a kid.
But I do worry a little about the next generation of programmers. Whenever a mum asks me what to recommend for her kid, who's fanatical about computers and just wants to dive in and write some games, I'm really at a bit of a loss for something to suggest. I usually go with Python, but it sucks to know that the kid in question is going to have to do some extra work to get things like graphics and audio going.
...because they also have lolcats?
Seriously, there are a lot more distractions these days, too.
I found out about SIN/COS a while before I really understood what they were. :) I treated them as magic keywords and used to just plug in weird functions to see what turned out (sin(x)+cos(x), sin(cos(x)) etc).
Sometimes we take things like portability and platform-independence so far that we end up complicating things. As an example, with Turbo Pascal and DOS, I could just treat the video buffer as an array and write to it. Under Linux (even in the old days), I wasn't able to figure out how to access the console display as a array. The "right way" was to wrestle with Curses. I declined the invitation and stuck to network/command line programs. :)
Without the math requisites, I was only able to take introductory programming courses in High School. Those teachers recognized my interest and feed me more advanced material while I was with them, but when I had taken the only classes available without those math prerequisites, we parted ways.
After graduating H.S. I took to writing excessively intricate batch scripts on my family's XT, and later while working on a help desk I checked out this new "HTML" and "JavaScript" stuff by way of WebMonkey tutorials and free hosting on a new service called GeoCities.
Years later, with ASP/VBscript, PHP, and bash experience all from after-hours activities I transitions from systems support and administration to programming as my career, after which my experience and expertise has mushroomed.
I couldn't have come all this way without the resources of the Web to back me up.
This anecdote makes the point that a very specific kind of thinking was better suited by the tools of the late 70s, and maybe - I've never been much inclined towards it, so I dunno.
And what we consider 'programming' is blurrier than it used to be. Is HTML programming? What if you use a fancy editor like dreamweaver? Only when it becomes dynamic? Does CSS count? A lot of youngsters, when they aren't getting off my lawn, have done web stuff, and the fact that it's a gradual shift from being a user to being a programmer probably makes it even easier.
I find the whole premise of this blog post flawed. (Great Scott! Someone disagrees with someone else on the Internet!)
Like it or not, the act of programming has become much more difficult than it once was. 1988 I could reboot my Apple IIgs, hold down a couple of keys, and I could start writing a BASIC program immediately.
Apple basic graphics was one of two commands:
GR or HGR
There are plenty of great tutorials for PyGame and pyglet. The main issue is that you have to open a terminal.
If you look past Python, Scratch provides a very low barrier to entry for this sort of thing.
If the question being discussed is "How likely is an 8-year-old to randomly discover programming", it's not unfair in the slightest. Installation of anything is a huge barrier to discoverability.
Assuming you are targeting those -slightly- older, pyglet would offer an incredibly simple way to progress, but would require you download one library, which I feel is a very reasonable requirement.
I was lucky, and in middle school, we had an elective that allowed us to use lego robotics and logo to do some really basic stuff (one of the projects, if I recall, was building a robot arm to sort bricks based on color). Not much problem solving involved in it, though - they just gave us "type this in" and "put the legos together this way" instruction booklets. If we had been encouraged to solve the problems for ourselves, I might have gotten a lot more out of it. As it is, I don't recall any logo at all.
Didn't do any more programming until sophomore year of high school, and things like optimized sort algorithms really caught my imagination. Haven't really looked back since...
Almost every web browser on the planet can run javascript, independent of operating system or underlying hardware. I don't think you can get more accessible than that
ipython -pylab
[...boilerplate...]
In [1]: n = arange(255)
In [2]: plot(n, 88+80*sin(n*pi/128))
http://imgur.com/oSd62.pngAs for the "imaginary diffusion equation" (I assume he means the Schrodinger equation), here is a simple program which solves it on the torus:
from pylab import *
from numpy.fft import *
def freeSchrodingerSolver(input, dx, dt):
np = input.shape[0]
k = arange(np)*2*pi/dx #Coordinate system in k-space
k[np/2:] -= np*2*pi/dx #FFT puts negative frequencies
#on right side of array
return ifft(exp(complex(0,-dt)*(k**2)/2)*fft(input)) / np
I really doubt it was easier to do that on a ZX Spectrum.Python 2.6.4 (r264:75706, Nov 2 2009, 14:38:03) Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]:
Not any sort of actual setup the user is expected to perform.As for "no installation", it's not that hard to install ipython on Linux. Windows, well, that's another story. But I think you're focusing on the wrong thing. The problem is not whether it came installed or not, as the effort to install is very low for anybody who's going to be motivated to do this sort of exploration in the first place. The question is, how is anybody supposed to discover that this is possible? I knew about iPython and I didn't even know it was that easy.
Additionally, you did not find this because it was sitting right in front of you. I have many friends who had things like Commodore 64s who never learned squat about them. You found them because you found documentation about it that wasn't drowned in gigabytes upon gigabytes of other information. You had limited, high-quality documentation to draw on, or good magazines, in the days that all the good magazines ran stuff like this. That's the missing step here; not the existence of good learning tools, all of which will actually blow away the experience you could get on those older machines (which were easy, but incredibly limited), but a way for anybody to stumble on them and find out what they are in the current environment, when a site full of crappy little flash games is orders of magnitude easier to find that a tutorial on Processing (http://processing.org/ ).
In my case: I started on basic in dos 5 or dos 6 when I was 10 or so, and every function I had to my disposal was listed in the help file. Alphabetically and by sorted by category. Sooner or later you find the SETPIXEL function, then discover screen 13, then discover how to draw lines and so on. You can discover that "one more thing" pretty easily, and at no point can you get stuck because dependencies are missing or you have the wrong version of libgd. Basic was installed on the family PC, and I had gorillas and snake as example programs to study. Many people I know started in a similar way.
Compare this with python today. First you have to download and install it. You don't just discover it by accident. Then you have to learn the whole edit program, save program, run in python steps. BASIC had a primitive IDE, Python doesn't. Then you have to understand packages and package management, learn how to install pylab, and so on. Python also isn't a very forgiving language.
Programming sound on BASIC was trivial too. The moment you discover SOUND and PLAY you can make primitive melodies. Want to delay? Add a few SLEEPs in between. Exploratory programing at its best, and no internet connection required.
I also started using QBASIC in DOS at age 10 or so. But I really don't see how it was easier. I don't think being being preinstalled is that big a deal; plenty of kids download and install games, level editors and the like. They also manage to program for games, e.g. Warcraft or Quake.
Learning to program differently than we did is not the same as being harder.
sudo apt-get ipython sudo apt-get install ipython ipython -pylab sudo apt-get install pylab sudo synaptic (<--used it to find pylab packages) sudo apt-get install python-matplotlib sudo apt-get install python-matplotlib-data sudo apt-get install python-matplotlib-doc ipython -pylab
And then the program works.
Actually, thanks for that, I didn't know about that stuff, and it looks really useful. If I can figure out how to get the drawings to move then it will do what I want. (to visualize the action of unitary matrices on Hilbert spaces)
But my point was that in 1982, my non-technical parents bought me a computer and then I was away. A couple of months later I had an animated model of the solar system. And I hadn't read anything except the spectrum manual (and the equivalent one for the TRS-80).
I can work out how to do the above installation for my hypothetical 12 year old son, but my poor father wouldn't have had a chance. And I suspect that the same would be true for most non-techie parents.
And how is the hypothetical son supposed to go from the pretty blue curve created by the magic plotting program to an animated solar system?
I can't see how to make the graphs move. Perhaps it can be done. Perhaps it can't and I should use SDL instead.
The point is that it is not obvious to me. Whereas the equivalent questions were obvious to a child thirty years ago.
I think the issue is mainly just lack of knowledge that truly newbie friendly environments exist. Perhaps the solution is simply better advertising of squeak, or perhaps having it come preinstalled (as OLPC did)?
Incidentally, the animation info you seek (admittedly, not suitable for newbies):
http://www.scipy.org/Cookbook/Matplotlib/Animations
Or, if you want to generate movie files:
for i in range(numframes):
[...code to make frame...]
savefig("framedir/" + str(framenumber).rjust(8,"0")+".png")
os.system("mencoder -ovc lavc -lavcopts vcodec=mpeg1video:vbitrate=1500 -mf type=png:fps=16 -nosound -of mpeg -o movie.mpg mf://framedir/\*.png")There was a BASIC program in Creative Computing that used sin() to make a long snake of text scroll down the screen. So, in my mind, sin() and cos() were things that made wavy lines.
A little while later I was puzzling over how to draw a circle. I had this epiphany that the X component was drawing a wave, just like sin(), and the Y component was drawing a wave that was just out of phase. I went home and programmed it and it worked instantly.
We had a Britannica at home, so I finally looked up what sin() and cos() were, and the diagrams made it all obvious.
It's good that we now have Wikipedia and all, but kids today are still deprived of a computer that comes with a decent programming environment, that makes fun stuff like graphics dead simple.
That one comes from personal experience.
It has a graphing mode, where you can put in functions and it'll draw them for you. And it has a programming mode, with a very BASIC-like syntax that I wrote simple graphing programs, ridiculous text-based rpgs, and my own version of the oh-so popular Drug Wars.
Having no idea what a ZX Spectrum is, I can only assume that the likelihood of the author having one 30 years ago is about the same as the likelihood my having a TI-83 in high school, especially because the calculator was pretty much required for some of the math classes I was in.
Since the ZX ran BASIC, programming for the spectrum and your TI-83 is pretty comparable, although your TI-83 was a bit more powerful. :)
I guess the same could be done with the information available on the Internet. If someone wants to learn javascript they have all the info they could possibly ever want. There are so many options now. But learning to program is a question of interest and determination, not availability of information.
I wrote a freely available book called "Invent Your Own Computer Games with Python" and released it under a Creative Commons license. It's available at http://inventwithpython.com
I think Python makes a great (even superior) replacement for BASIC. Adding in Pygame, and it is much easier and fun to learn programming.
I prefer pyglet over PyGame. I wrote a tutorial for it in the style of your chapters 16-19. It's up at [1].
Why would I be sure of this? People have come up behind me and asked questions like "Wow, that's a really cool word-like program. Where did you get it?" Of course I tell them I made it and almost always I get asked how. I've even given out a couple of programming "lessons". (That's a lie. I've given out hundreds of programming lessons, and I've written at least ten little programming manuals to help people begin to program.) However, the real point is: If given inspiration, kids are very curious creatures and will start to program.
Anyway - 8-bit computers were superb "teach-yourself-programming" machines, but I think novadays kids have internet access, so they will manage :)
PS. I would choose python + pygame to teach a kid graphic programming. It is simple, interpretted and has interactive console.
I have been toying with the idea to write a Javascript LOGO for the Canvas Element. There used to be Online-Logo Applets, but I think they were all Java.
At least it might be a fast way to draw nice things programmatically.
The next step was to start learning Java through Karel J. Robot ( http://www.csis.pace.edu/~bergin/KarelJava2ed/Karel%2B%2BJav... ), which was a nice, easy segue from LOGO. After going through the Karel material, the students could dive into more advanced stuff.
The course was self-paced, so if you mastered the LOGO stuff in one day and wanted to move on, you could. You just had to show that you mastered the relevant learning concepts.
All in all, this was a great way to structure a course. So yes, LOGO can still be relevant.
Here are a few programs I made with it (note that the default is to 'run normally'. You might want to click 'stop program' and then 'run fast'):
* Sierpinski triangle: http://logo.twentygototen.org/83EGZPPC
* Sierpinski carpet: http://logo.twentygototen.org/4c5iy9iU
* Sierpinski arrowhead curve: http://logo.twentygototen.org/hYDSZt8h
* Hilbert curve: http://logo.twentygototen.org/CFyUSzqG
* Hexaflake: http://logo.twentygototen.org/AJeuVkKc
It's also important that there be a lot of reference materials which would be easy for a kid to teach him/herself with.
For example: http://www.scribd.com/doc/200861/A-Touch-of-Applesoft-BASIC-...
This was the book I read when I was 10 years old. It was also easy to find BASIC code at the school library and in computer magazines.
How many current general computer magazines still publish useful bits of code ("How to access your mouse from Apple Basic", etc) ?
The web has made printing code redundant. Why type it in when you can cut and paste?
I started when I was a tot during the days of DOS on an IBM box. At least kids these days have the internet, we were left to fend for ourselves.
Eventually this led to html, javascript, php, VB, C#, etc. Dad wasn't real thrilled when he realized I used all of the printer ink to do this, but I'd say it was a pretty good return on his investment.
EDIT: I'd like to play with BASIC again, anyone know of a way to do that on OSX? VM?
I did mine on a TI-83 calculator, went to visual basic, and then C++/DirectX. Once I grasped sin/cos/tan, I created Microcosm (missle command, angles, rotation as my primary game mechanic due to my fascination of the power of trig, http://arcade.connersc.com).
I feel the same way. You put it in words clearly. :)
10 print "BAH"
20 GOTO 10
<script>
for(i=0;i<100;i++) {
document.write("BAH");
}
</script>Alas, it doesn't seem to be getting much activity.
Every project goes through slow periods. _why has some quite large shoes to fill.
Let me know what he thinks, and any feedback that you might have. Positive comments are a great motivator. My email is in my profile.
http://vodpod.com/watch/2078103-art-code-symposium-hackety-h...
However, along with every other 7 year old, he want to know how things work. I am finding that many of my explanations get from A to B via "and at this point there is a computer that does ...". - Things: Microwave, car, alarm clock, phone, camera etc. and broader systems: exams, shops, banks etc.
I could explain things in terms of the model that is embodied in the computer, but that seems wrong - at least as the only explanation. If you pull it apart, you don't find the coresponding physical embodiment.
If he does want to dig further into this and explore how to make computers do things, I want to have a good set of resources to draw on - My current short list w/ comments:
- Lego Mindstorms NXT
Start with the provided graphical environment, move on to one of the several text based development environments, eg: NQC, leJOS. He loves Lego, and I have already set up a mindstorms controller+psx joystick to give him a drive+steering component he can use in his own constructions. I find the graphical a bit cumbersome.
- Nodebox (http://nodebox.net/code/index.php/Home)
I think it is great - python & easy graphics. I have already been showing off some simple drawing animations and fielding requests to: "Make it go the other way, go red, faster, jump etc." - Cool, but I am well aware the he'll get frustrated with syntax errors.
- Processing (http://processing.org/)
Also, cool - not used it so much myself, and I am not sure I want to start explaing curly parens & semis, but it does lead into Wiring and Arduino. One thing I would really love for him to experience is making things w/ embedded cpus - even if it just simple things to spin motors and flash leds.
- Scratch (http://scratch.mit.edu/)
Only recently found this. For me, the visual programming was way easier than Lego NXT. Going to have more of a play.
- Nintendo DS homebrew
- C64 - in the form of a C64DTV (http://en.wikipedia.org/wiki/C64_Direct-to-TV)
- Usebox (http://belogic.com/uzebox/)
When I was mucking around w/ NDS homebrew I had him draw some characters, then we scanned them and displayed them as sprites bouncing around (one was under joypad control - no collisions or gameplay, maybe 20 lines of code)
My own experience was that making games was a very powerful motivation - and all these 3 provide a way into that - C64 & Uzebox would provide a similar experence to mine (well, I was a BBC fanboy, but anyway). Nintendo DS would be a bit more up to date, and would have some currency with his mates. Some way of targetting NDS from processing would be a cool halfway house.
Assuming he is at all interested, it will be interesting to see if any of this is appropriate. If not, well, there is another son - and maybe I'll just get stuck in myself.
You can easily make a page with a javascript editor and immediate evaluation if you wish, and simplified api.
Any particular reason it needs to be web-based?
Sorry for posting so many comments: I'm a teacher so the issue of computers, programming, and education fascinates me to no end :)
I've thought a few times that this is the modern equivalent of the immediate feedback "plot via BASIC".
It's even better, given the fact that JS is a decent language and the results are more easily shareable with your friends.
A massive advantage of BASIC was that it would tell you it was wrong as soon as you typed something with a syntax error in it, and it put a big flashing "?" (or similar) right there until you fixed it. Can JS be made to do that?
And it would have syntax colouring which basic lagged in.