Comment

Comment by japhyr

This has me reflecting on how I learned to program, compared to how people learn to program today.

I learned to program using BASIC when I was between 5 and 10 years old. My dad was a software engineer at DEC, and he had a kit computer in our basement that he let us play with once in a while. My first program was a number-guessing game, and it went something like this:

    10  NUMBER = 23
    20  PRINT "I'm thinking of a number."
    30  INPUT "Make a guess: " $GUESS
    40  IF GUESS < NUMBER THEN
    50    PRINT "Too low!"
    60    GOTO 30
    70  ELSEIF GUESS > NUMBER THEN
    80    PRINT "Too high!"
    90    GOTO 30
    100 PRINT "You got it!"
That was pretty straightforward, because everything about it was linear except for the GOTOs. You can think about each step with very little planning, and when you need a break in program flow you can use a GOTO. It also means when teaching, you can introduce each new concept as the need arises: store a value, print a statement, prompt for input, check a condition, and go back to a previous statement.

Let's see the same program in Python:

    number = 23
    print("I'm thinking of a number.")

    guess = 0
    while guess != number:
        guess = input("Make a guess: ")
        guess = int(guess)
        if guess < number:
            print("Too low!")
        elif guess > number:
            print("Too high!")
        else:
            print("You got it!")
The overall program logic isn't much different when you read the code. But to write this code, you need to know a number of things in advance. You need to know how you're going to approach the problem. You need to know what a loop is, and specifically what a while loop is. Conceptually, especially for a young person, a while loop is much more abstract than a GOTO statement.

I am happy that people get to learn a language like Python as their first language today. They can do much more interesting things, in a shorter amount of time, than they could in basic 40 years ago. But the very first programs people write seem fundamentally different, and that's not a bad thing.

parent japhyr 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton