The FizzWife Project: Hello, World!

January 27, 2011 under The FizzWife Project

Before Dena writes her FizzBuzz implementation, I felt it necessary to explain how a computer actually works and what is involved in the creation of software using a canonical “Hello World” program as an example. I spent the first hour covering the major components within a computer, how they work together and how software makes it all tick. While drawing maniacally on a whiteboard, Dena witnessed my best attempt at describing the hardware’s inner workings of:

  • CPUs and how various architectures differ
  • storage, both primary (ex: RAM) and secondary (ex: hard disks)

After thoroughly confusing and then (hopefully) un-confusing her, the time had come for me to make sense of it all by proceeding to explain how software consists of instructions and how those instructions are executed by the hardware. At some point, I ended up broaching the subject of bits, bytes and binary arithmetic, which eventually led to talk of ASCII character tables.

At this point, she assured me that – after some additional explanation – she was indeed following along. It would seem to me that people who don’t often have to think in terms of systems might have trouble grasping this deluge of techno mumbo-jumbo within the span of an hour, so I feared she was merely humouring me. But she insisted she understood, so I’ll chalk it up more to her being a quick learner and less of me being a decent teacher.

With her newly-acquired knowledge of what those “ones and zeroes” actually mean, I then went on to the basics of software and how “in the old days”, programmers created software by feeding computers punch cards which represented the binary data and instructions that it could understand. This brought us to the first example program; “Hello World” writing in machine code:

01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 00100001 00100000

Dena either had a look of terror, disgust or some combination thereof when she saw this. I assured her that software development had come a long way since this sort of programming was the norm, and this would be the only time she’d see something like it.

Next up was the language of the CPUs; Assembly. Harking back to the previous 60 minutes, Dena was made aware that the processors of the various architectures each had their own “readable” language that programmers could use to write software. And so “Hello World” written in x86 Assembly was ready for viewing:

       .MODEL Small
       .STACK 100h
       .DATA
   msg db 'Hello, world!$'
     .CODE
   start:
     mov ah, 09h
     lea dx, msg
     int 21h
     mov ax,4C00h
     int 21h
   end start

While “English” was apparent in this code, I sensed that she was thinking that she bit off more than she could chew by (willfully, I must add) signing up for this experiment. Fears were cast aside when I mentioned that technology evolves quickly and high-level programming languages from COBOL and Fortran, all the way to C/C++, Java, C#, Haskell and [drumroll] Python would make this all worth while. I explained how modern compilers and linkers are special software that take readable code and turn it into machine code that computers can understand. Often, I’d turn to examples that she could relate to in ways such as:

You know at work when you launch Microsoft Word? Well, Microsoft developers wrote a bunch of code (probably in C++) to enable you the user to do all sorts of things like letting you change fonts and their sizes, set margins, print, etc. That code was compiled by a C++ compiler that they use to become that winword.exe file on your computer so that you can simply click on Word’s shortcut and magic happens.

Relating it all in that manner appeared to cement the understanding. Without delving into functions just yet, Dena wrote her first program in a high level programming language. In a style that’s clearly all her own, she wrote a “Hello World” program in Python:

print("Hello, Bitches!")

Some experimentation followed, where she attempted to add some indentation. Her incorrect stabs at it looked like:

        print("Hello, Bitches!")

and:

print        ("Hello, Bitches!")

and:

print(        "Hello, Bitches!")

Eventually, she realized what works:

print("        Hello, Bitches!")

Slightly unsure of herself and why only the last attempt at indentation worked, I commended her first programming victory and that her experimentation conveniently leads us to the next lesson: Variables and Functions with a side order of Parameters.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »

The FizzWife Project

January 17, 2011 under The FizzWife Project

Welcome to The FizzWife Project!

The goal of the experiment is to teach my wife Dena, a law clerk with little technical/scientific background, enough about the bare essentials of computer programming so that she is able to successfully implement FizzBuzz on her own.

FizzBuzz, of course, is a problem that Jeff Atwood (Internet) famously summarized as a test of programming ability (and not programming proficiency). FizzBuzz boils down to the following problem statement:

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

The problem is trivial for experienced programmers, but may present a challenge to non-programmers such as Dena.

A note to all coders out there: please don’t post your own solutions to FizzBuzz in the comments; I will delete them.

The impetus for this experiment actually had little influence from yours truly. In August, Dena and I visited her brother in Kotzebue, Alaska. For the long trip, I packed some books (GASP! real dead-tree versions) to pass the time, and one of those books was Coders at Work. At various points during the trip, Dena – completely of her own volition – picked up and read some of Coders at Work; its conversational nature (and lack of any actual code) proved interesting to her. So much so, that she approached me with interest in learning something relating to what the interviewees in Coders at Work spoke about. I didn’t think she was serious, but she continued to broach the subject even after we returned.

My dilemma was to determine a project or a set of projects that would help her gain understanding of the bare essentials, while at the same time keeping her interest high. The project had to avoid dependencies on computer science-y things like data structures and algorithms, engineering topics like methodologies/paradigms/architectures, and any sort of APIs. Robert “Uncle Bob” Martin recently highlighted that programming, regardless of the language and environment boils down to three things; sequence, selection and iteration. And I think FizzBuzz, while being simple, is an excellent example of these three principles. I also settled on Python as the language she’ll use, to avoid strongly typed languages for the time being and the benefit of using IDLE for REPL purposes. Immediate feedback is a good thing! Also, I feel Python’s syntax is easy for a beginner to understand.

Join Dena and I as she’s introduced to the essence of programming, with the goal of her creating her own FizzBuzz implementation. I’ll post updates on her progress and code snippets, so stay tuned!

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »