How to program a computer, for children ... II
Posted by Simon on October 16, 2008 at 02:28 AM
Tags: code, links
A while ago I wrote "How to program a computer, for children". I was actually inspired by Ming's efforts along the same lines. I just read it and decided to take a slightly different tack, doing it all with math (since programming is all math anyway).
Incidentally... why has a rather bizarre system called Shoes which is apparently supposed to teach children to program but I suspect might frighten them instead. For adults, you have surely read his guide to ruby ... right?!?!?!
And here we go.
Programming a computer is a lot like writing instructions for someone really, really stupid. Imagine a person who knows nothing. They don't know how to walk, talk, read, or write. In fact, the only thing that they know to do at all is simple arithmetic. They can add, subtract, multiply, and divide any number at all. But that's all. They can't do anything else without being told how to do it in the form of math.
So, to get a computer to do something, you must turn it into math. Let's say you want to get a computer to go around the room. First you have to explain what "go" means in terms of math. Then what "around" means... in terms of math. And what is "a room" ... that's not math yet, so computers don't know what it is.
Well, let's start with "go". Let's give it a try:
How to "go":
1. increase the total number of footsteps that you have ever taken in your life, by 1.
See how I turned that into math? That's how computers think. Unfortunately, computers don't know what feet are either. But that's OK. For now, we'll assume that someone else has already built a foot for our computer, and when we tell it to increase by 1, it will know what to do. In computer language, this would be:
totalNumberOfSteps += 1
Now it's not completely true that computers can only do math. They can also repeat the same thing over and over again, like a mindless machine. It's called a "loop". If we just take one step, that's not really "going" very far. Instead let's have the computer "go" further.
How to "go":
1. totalNumberOfSteps += 1
2. do that over and over again
Since the computer is mindless, it will do this forever, so we can rewrite this into computer language like this:
1. totalNumberOfSteps += 1
2. repeat forever
OK, so now the computer goes. But will it ever stop? I don't know... if it has an atomic power plant, it might be millions of years before it stops. And in that time, it will grind its way through even the thickest of reinforced concrete walls. And it will never go "around" the room because it can only go forward.
So maybe we ought to give the computer a way to measure how far it's moved. Let's say it's got a little measuring wheel that touches the floor. Whenever it takes a step, the wheel clicks around a little more. In fact, it's just like an odometer on a car, that tells you how far the car has ever gone.
That's all fine, but how can the computer know if it moved? Remember it can only do math and repeat things. Well, the guy who made the odometer gives us two number:
odometerReadingBeforeTheStep
odometerReadingAfterTheStep
Clearly, if the "After" number is more than the "before" number, then we moved forward without hitting a wall. If not, we're stuck. We can use some fancy math to write this down:
odometerReadingAfterTheStep > odometerReadingBeforeTheStep
That just means that the number of the left is bigger (>) than the number of the right.
OK... so does that help us? How do we fit that into steps 1 and 2? Another little trick that computers can pull is to check some math before they take a step. So they can (a) do math (b) repeat things (c) check math.
It works like this:
if 1 == 1 then oneIsEqualToOne += 1
That's a pretty stupid example, but you know, 1 is "equal to" (==) 1, in math, that's true. So, oneIsEqualToOne will be put up by one number.
We can use that for our robot to. Can you see how yet?
1. totalNumberOfSteps += 1
2. repeat if ...
If what? Remember the odometer?
1. totalNumberOfSteps += 1
2. repeat if odometerReadingAfterTheStep > odometerReadingBeforeTheStep
Pretty simple. Add a step, and then do it again if the odometer shows you moved forward. If it doesn't, the computer just stops, because it has no more instructions. That's called "halting". When the program halts, you check it's progress. In this case, it will have walked into a wall. And then stopped. Always. That may not sound like much, but we're halfway to getting around the room.
I was reading the manual for my HDTV (I know, who the hell does that?) when I noticed a GPL license notice and acknowledgment for among other things, "linux kernel". Wild.
Useful software: PDFCrack, Map.Hamilton iMapper, and Skim for PDF annotation
Posted by Simon on September 27, 2008 at 10:31 PM
Tags: links
Some miscellaneous useful software.
"Forget" your PDF password: use open-source PDFCrack. Installs easily on Mac command line (use gmake).
Looking for high-quality maps and "satellite" imagery of Hamilton? Try Map.Hamilton's iMapper. The interface takes a few minutes of experimentation to figure out, and then it's cool. Make sure you switch to Aerial Viewer (latest year) to get their ground imagery, which I think is actually generated by airplanes. It's quite a bit higher resolution than Google Earth has.
Want to annotate your PDF files? Try Skim. Seems potentially easier than using OmniGraffle... (and cheaper...)
He is apparently
Trying to sort the brilliant ideas from the lesser ones.
Unfortunately, he is not very successful. But he is trying.
He also uses SimpleLog, the best Ruby on Rails blog out there that doesn't work under Rails 2.0, has been abandoned by its author, but still works great for me.
ALL NEW "Simon Says" content RIGHT HERE
Posted by Simon on July 10, 2008 at 02:52 PM
Tags: art, links, meta, tech
Wow, WYM Editor is so cool that I can just like type in a new blog post whenever I want to. Wild!
So anyway, I've been saving up a whole load of links and stuff for months until I had this new site all sorted out. So here's something.
Hmm... where did my "stuff to blog about" folder go?
Oh, here's an awesome one. Nikkei Electronics Teardown Squad. These guys kick ass. Watch as they take apart a MacBook Air and declare "No Waste Outside, Nothing but Waste Inside".
About 30 screws were used to attach the keyboard alone. "The total number of screws in the MacBook Air was several times the number used in a PC we make," one of the engineers said.
Burn, baby, burn!
OK, here's another one from the files. Nathan Fawkes Art. He's part of a network of film animators and illustrators and concept artists who all have their stuff up on blogspot.
And I'd like to remind myself particularly about this post about science fiction.
Tinselman is the very amusing blog of the co-creator of Myst, Robyn Miller. It's a bit iffy on a daily basis ... and very eclectic. A bit like this blog, but better.
He's got this ongoing thread about the Republic of Tinselman, which appears to be something dating back to some attempt to create a fake republic on Wikipedia, or something, but whatever. It's just stuff.
He also seems to be a big fan of Walt Disney . To be particular, Walt Disney, and Disneyland. Not necessarily the Disney company or the movies per se. In fact, thinking about it, or maybe I read this somewhere. Anyway, that he wanted Myst to be a bit like Disneyland, which I think it is.
It's worth noting that Robyn Miller is the one who did the music for Myst and Riven, and he left after Riven. It's a bit obvious looking at any of the sequels after that the original spirit isn't there. With his brother Rand, he also did pre-Myst stuff like Cosmic Osmo, which was pretty cool and all done in the absolutely brilliant and amazing but now-forgotten HyperCard . In fact, did you know that the original Myst for Mac was written and deployed in Hypercard? Amazing but true.
Actually, that reminds me of a story, which is that back when Myst was first released I was working at this rather unusual place called the Southam InfoLab . Anyway, I was mainly a HyperCard hacker and pretty damned good at it if I may say so. And I managed to hack into Myst and actually look at the source code running it. HyperCard is an interpreted language, the language is called HyperTalk, and there was no compiler for it. So, they implemented this fiendishly complex system for preventing you from breaking into debug mode and viewing the code, but I managed to hack it. I don't remember doing much with it though, because the source code for Myst was way over my head at the time.
Anyway. Robyn is clearly a very interesting an unusual person. I think it would be very interesting to meet him and peer into his brain some day. Once you get past the "oh my god he's the guy who made Myst" thing then his blog seems to be quite interesting.
Linkdump: cousin Suzanne, "Me", Excel little graphs, The Grooming of the Woodside Man
Posted by Simon on August 28, 2006 at 12:00 PM
Tags: art, graphics, links, tv, unix
A bunch of links and things.
Ahree Lee created (or is creating?) an amazing short film. Starting in 2001 she started to take a picture of herself, every day, in the same pose. As of 2004, she created a short film called Me in which the images are flashed at you at the rate of about one week per second. If you want to download the film, you can use mplayer (like I did...) with something like this from your unix shell. (Note that the rtsp URL might change, you can get it from AtomFilms web page / View Source.) (Also note that I had to insert a backslash in front of the exclamation mark, probably inserted by atomfilms to foil script kiddies trying to use this method.) I think you could do some cool analysis of the images over time.
mplayer -dumpfile out.rm -dumpstream 'rtsp://shockreal.edgestreams.net/real.atomshockwave-secure_!/me_300.rm?auth=caEascHb6b7dRbpdudXcLbKdibBaHbDbbdP-be81D5-cOW-REAwJrGowGoHn3wlB&aifp=123&span=10800'

My cousin Suzanne Thoma finally has a website. She still sings but mostly she's now a freelance graphic designer. My opinion: website needs some work. I'm not sure that my parents would be able to navigate it.
How to create little bar charts inside the cells of an Excel spreadsheet looks useful and pretty easy to do. Generally speaking Excel's graphing sucks, and it looks like the Excel 12 graphs aren't going to get any better. Apple's iWord graphs are somewhat better but not perfect and some important graph types are missing.
Finally, let's hear it for art: The Grooming of the Woodside Man V1 by Simon Donikian and The Grooming of the Woodside Man V4 .
Enough for now...
I can't get enough of ravenblack quizzes!
Posted by Simon on August 19, 2006 at 12:00 PM
Tags: links, meta
I just can't get enough of these ravenblack.net quizzes! They're so awesome! The author is a genius!
Wait, the author is also really weird and has a RavenBlog !
While I'm here and screwing around, here's a Googlewhack: aquaplane wimax
Also, I'm redoing some fundamental bits of the XSLT that runs my site, so things might be a bit haywire for a few days.
Imagining the Tenth Dimension is a cool, flash-animated information graphic. Unlike a lot of flash graphics, this one really needs to be animated, the movement really adds to the explanation power of the graphic.
After watching it, you're supposed to understand why "String Theory" has ten dimensions and what they are. In theory, anyway.
Here's a flash app that you can test your hearing , how high it goes at higher frequencies. Best to start at the top and then notice when you can start to hear something. For me, it's 18 000 Hz which is pretty good considering how bloody old I'm getting. How about you?
This all came from a shopkeeper in england who used high frequency sound to repel teens . Fascinating and clever idea.
Oh by the way, you need a decent set of speakers or headphones to do this, otherwise you can blame your crappy speakers :-)
I'm on an enforced work holiday which gives me lots of time to blog. So aside from a lot of work on the tagging system here at Simon Says , I've been going through old bookmarks and recent news as well. Here's a good one.
Camino (the best browser for OS X) reaches 1.0 :
The Camino Project is proud to announce the Camino 1.0 web browser, the culmination of four years of work by dedicated volunteers.
Designed exclusively for Mac OS X, Camino 1.0 is built on Mozilla’s Gecko rendering engine and offers one of the fastest browsing experiences available. The only browser available that combines the rendering power of Gecko with the Aqua user interface, Camino 1.0 offers superior integration with the Mac platform and a focused feature set. Among Camino’s signature features are elegant tabbed browsing, an enhanced bookmarks manager, and built-in ad-blocking.
I helped to write that announcement. Snappy eh? Anyway, my last major involvement was back in, er, let me consult my new tag browser ... 2004 when my history patch landed . I wrote a major improvement to the history panel, which was crap before that. It's still not perfect, but just after that I got awfully busy with Semacode.
However I was with the project during a rocky time in 2003/2004 when Apple launched Safari and it looked like the game might be up for Camino. But it's definitely not up. Camino is way better than Safari. It's faster, more attractive, renders better ... it's even more "mac-like" (however you want to say it). And the crowd now involved are clearly doing a good job. All around great news.
PS. The new website looks great . Also. I still administer the mailing list .
So I was just putting the finishing touches on the beginning of my wikipedia article on the History of computer science , writing about that great wronged genius Alan Turing (wronged in his own time, not ours), when I was reminded of my "famous" math NEWS cover on the subject of Turing's machine .
The cover appeared in this 1999 issue of the magazine best known for profquotes. If you've never looked before, put on your sunglasses and maybe start with The Best of mathNEWS .
Does Wikimedia Commons take cartoons?
Some bookmarks are just too good to keep to myself. The Canadian Architect and Builder is an online archive of fully-scanned images of this journal, published between 1888 and 1908. They've got some really beautiful drawings. Run, do not walk, to the "plates" ... the rest is text & ads, which I find a bit dull. But the pictures rock. Especially if you then go and google for the buildings and see what they look like today vs. 100 years ago.
The Eden Project is a multi-biome park in England somewhere where they've built these amazing huge greenhouses for visitors using a transparent material called ETFE foil. It's a transparent polymer that's used as an architectural membrane in some new structures (although one's been around for at least 20 years) and it's tough and much, much lighter than glass. What they do is make a multi-layer pillow of the stuff and inflate it with air in the middle to give it a convex shape and good insulation properties.
I found an interesting mailing list called Greenbuilding; here are the Greenbuilding archives .
A useful concept in designing an efficient building is to know about embodied energy . The embodied energy of a material is the total amount of energy needed to create it and deliver it to you—extraction from the ground of raw material, cost of production, cost of delivery. You can use a higher embodied energy material if your building will last longer or if it will give you better efficiency in other ways (such as ongoing power costs).


