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:
Some experimentation followed, where she attempted to add some indentation. Her incorrect stabs at it looked like:
print ("Hello, Bitches!")
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.