MathJax

Wednesday, July 31, 2013

Computing for Everyone 2: Sequential Execution

Last time we covered the centrality of experimentation in computing. The exercise reinforced something you've already experienced with computers: input and output. You may have made some changes that led to some bizarre behavior in the web browser, and that's okay: it's all part of experimenting. When you aren't surprised by the results any more, you've gone from experimenting to building. Building brings home the bacon; experimenting makes us better builders.

Anyway, now that we've started experimenting and have an intuitive feel for input and output, let's start exploring the space between input and output. Let's start talking about computing itself.

We begin with a trip into the world of wacky anthropomorphisms. Let's say you're a chess player. You know you need to be really smart to play chess well. On the road to becoming a better chess player, you'll learn things about the game that will help you teach other people to play chess well, strengthen your logical reasoning skills, and grow yourself as a competitor.

Now consider the following: You can buy software that will turn your computer into a machine that can destroy you at chess for $7 USD. This means the computer is quite brilliant and intelligent, right? Perhaps the computer could teach us how to play, and maybe installing Fritz has increased the computer's ability to think logically?

As it turns out, Fritz's real strength is its ability to select extremely strong chess moves for a given position. Your computer's ability to think logically is actually unchanged by installing Fritz. The features of Fritz that give amateur chess lessons aren't significantly affected by improvements to Fritz's ability to play the game.

Computers...aren't actually very smart. If your computer isn't very smart, how can $7 software make your computer defeat every human you know at chess?

For a little more than $7, your computer can take on the best human players in the world.
Computers aren't smart, but they are lightning-fast and uncompromisingly systematic. Fritz can select better chess moves than almost any human because its software lists instructions for how to list legal chess moves based on a position and how to test the viability of different moves by evaluating the "if-I-do-this-then-he'll-do-that" chain of reasoning. Modern computers running Fritz can follow these instructions--to the letter--at an incomprehensible rate of hundreds of millions (if not billions) of instructions per second.

This execution of instructions in the pursuit of an optimal or best-effort decision is the "computing" to which this series refers. Programming a computer is the act of writing instructions, in order, that will compute the desired output for any given input.

When your program runs, the computer executes each instruction in order as fast as it can. No more, no less. Ever. Other devices may assist users of a program with input and output (e.g. a digital camera will turn light hitting a sensor into a form your phone can understand as input for its camera app), but computing is about that space between the input and output, where fast execution of specific instructions allows us to make machines do what machines have never done in human history.

Exercise:

  1. Open a cookbook or browse for an enticing recipe online. Pick a recipe that has between 3 and 5 numbered steps. All this blogging is making me hungry--I could really go for some bruschetta right now. 
    Mmm...bruschetta....
  2. Imagine you have an untrained but literate, obedient, efficient, and self-disciplined child to help you prepare dinner. Your child will do exactly what he is told in the order instructed, but, unfortunately, nothing else. In addition to moving about the kitchen, your child can follow instructions like "if this is true, then take this action; otherwise, take this other action" and "go back to step 2." Now look at the recipe you selected. Is there anything missing from the recipe that glosses over some pretty major details if this is all your child was using to prepare the dish? Imagine how you would have to augment the recipe's instructions to avoid starvation. We'll call the result an "augmented recipe."
  3. Let's say you could teach your child 10 kitchen-specific skills (boiling, chopping, etc.). Which skills would simplify future augmented recipes for the largest variety of dishes?
  4. What are the inputs and outputs to your child?
Extra credit:
  • How could you instruct your child to pay your bills?
  • If you're mathematically inclined, how could you instruct a very patient child to apply Euler's method to trace out a curve specified by a differential equation?
Bonus:
In modern times, we have the bumper-sticker sized phrase "Garbage in, garbage out" (sometimes "GIGO") to express that computers deal with the data we input, not the data we would have liked to input. While this is sometimes frustrating, it is also logically inevitable after brief reflection on the nature of computing as we have discussed it.

Tuesday, July 30, 2013

Computing for Everyone 1: Experiment

Nothing will teach you about computing faster than self-directed experimentation. Experiment confidently. You will not break your computer.


I had a Game Genie growing up. Game Genie gave you three "wishes" to change how your NES games worked by entering 8-character codes from a guide book. Infinite lives, invulnerability, and infinite ammo were popular wishes. You could also skip levels or just make bizarre things happen.

Game Genie: Natural Video Game Enhancement
The Game Genie also came with a book that would tell you how you could tweak the codes they provided for different games to write your own. If there was a code for a game that would let your character start with 5 lives instead of 3, they had tables so you could tweak that code for 7 or 9 lives instead.

I used this table on Super Mario Bros. 3 to tweak a starting world code. SMB3 had 8 "worlds," and Game Genie would send you to any of them. I had to see what world 9 was like, and Game Genie showed me. It was a bizarre, but made a delightful experiment. Notably, my NES was never in danger of exploding.

You will not destroy your computer by experimenting: and low-risk, self-directed experimentation is how you will learn the fastest.

Exercise:
Save this blog post to your computer's hard drive as HTML. Open the .html file in a text editor (e.g. Notepad if you're a Windows user). What you see there should match what you see if you right-clicked this page and selected "View page source" in your web browser.

Open your locally saved copy of this .html file in your web browser: you can drag the file on top of your Chrome/Firefox/Internet Explorer icon or use File -> Open... in your web browser's menu to find your local copy. You'll know you have the right copy of this article open if your browser's address bar starts with "file://" instead of "http://" or "www.".

You are now looking at two views of this web page: one in your browser, and one in your text editor. You can now experiment by making and saving changes to the .html file and refreshing your browser (F5 or Ctrl+R in Windows, Cmd+R on a Mac). Some things to try:
  • Easy: Change some text, save, refresh your browser, look at what happens
  • Exploratory: Find the HTML image tags. HTML tags are the things surrounded by angle brackets (< and >). The image tags look something like '<img src="blah blah blah" />') in your text editor. Change one of the images to a picture of a cat by manipulating the "blah blah blah" part. Here's a nice picture you can use.
  • More exploration: Change other parts of the page, add effects, look at hyperlinks on the page by skimming through w3schools free HTML tutorials (formatting, links and images should be pretty instructive). As a bonus, w3schools has a "try it yourself" functionality to help you quickly experiment.
Extra credit:

Start exploring the files on your hard drive. Look at files related to your operating system: C:\WINDOWS if you're a PC user or /System if you're a Mac user. You definitely don't want to change these files directly without studying them first, but exploring these files can teach you a lot about working with your computer.



Bonus:

Monday, July 29, 2013

Computing for Everyone 0: Yes, Everyone!

Welcome to the Computing for Everyone series! Which everyone? Every everyone--that means you!

The ENIAC was the size of a blue whale and took up about as much space as a volleyball court.


We have arrived in a world of information at our fingertips and ubiquitous computing, and we're only just beginning to grasp what that means as a population. Think of the first electronic computers filling rooms and buildings. Now think of how so many of us have computers millions of times more powerful in our pockets.

My Galaxy SIII fits in my pocket, including the case


What is the nature of computing power? How are we using it? How could we be using it?

Here is a short list of what advances in computing have enabled as of 2013:

  • On-demand entertainment
  • New forms of entertainment
  • Almost-free publishing
  • Almost-free, almost-effortless research
  • Efficiently navigate unfamiliar cities
  • Almost-effortless group outing coordination
  • Convenient, fast, and secure financial and government transactions
  • An explosion of consumer choice
  • An unprecedented reach for businesses with niche markets
  • Ads that are actually for things you might want sometimes

Each of these advances is only possible because of the harnessing of computing power. This is what has been pre-packaged for mass consumption. But computing is a general power that can be adapted much more closely to our own needs.

The MacBook Air runs all day on battery power.


Computing isn't something you need to wait for others to do on your behalf; computing is something you can personally use to save time, reduce risks, spend less mental energy on trivia, and do things which were not possible or feasible before computing power became cheap and ubiquitous.

Enough warm-up. Enjoy the series.

Exercise:
Each bullet point above describes a computing-enabled change in terms of its positive effects. What are the new challenges introduced by each change? 

Example: "On-demand entertainment means there's no pressure to schedule leisure time around TV broadcasting schedules, but it also means that there is less social bonding on the basis of new episodes of popular TV shows. This presents the challenge of bonding with acquaintances through other means."

Extra credit:
What's a repetitive part of your life you could automate away to save time? What are some things you would do or do more often if you could find a way to speed up smaller parts of getting these things done?

Monday, July 1, 2013

Gratitude the easy way

Gratitude is the key to both goodness and happiness. So often, though, we don't know what we've got until it's gone, or we take what we have for granted.

It's a trick in life to know what you've got when you have it. One way to get something and no you've got it? Get an "after body." You'll never take your physique for granted, you'll know the work it took to make it, and you'll never want to go back.