Unfinished Projects: One last programming lesson from my dad

Last night I got to hold a fresh copy of the first book I’ve ever written. It was an amazingly satisfying experience. As many authors will attest, the journey from submitting a proposal to holding the finished book was much longer one than expected. It was difficult to maintain a healthy attention to detail when I found myself working on the seventh or eighth revision of a single chapter. What got me through this was the last lesson my father taught me as a programmer.

I gave the first copy of the book to Ever.

I gave the first copy of the book to Ever.

My son was born in March of 2011, and I was on top of the world. One month later to the day, my father died unexpectedly. My dad never met my son; we live in Alaska and he was planning to come out for a visit that summer. Instead I flew back to New Hampshire with my family for his services.

My father spent the majority of his career working as a software engineer in the 70’s and 80’s for companies such as Raytheon, Sanders, and Digital. I was lucky enough to learn how to program on a kit computer my dad put together in our basement. He introduced me to BASIC on a computer that was really just a bare motherboard wired to a keyboard without a case, and a cathode ray tube that rested in a plywood case. My first program was a simple number guessing game, and I still remember the satisfaction of watching my family play a game I had written myself. I studied physics in college and went on to teach high school math and science, but I always kept up with programming as a hobby.

During the week we spent at my parent’s house after my father passed away, I spent a lot of time sitting quietly in his office. I always loved waking up early when I visited home and hearing about my dad’s latest projects. I’d thumb through his vast library of O’Reilly books, and listen to him explain concepts like how to set up a database so it can be scaled when the need arises. My father never taught me specific skills as a programmer after those initial BASIC lessons, but I always went to him when I needed a perspective on some aspect of programming that only comes from working in a professional context over long periods of time. I felt lost without my connection to his professional work, and the thought that I’d never get to sit in his office with him again.

I had the privilege and the burden that week of looking through my dad’s computer, and seeing the projects he was working on that would never be finished. His main project was a design tool for woodworkers that he’d been working on for years, which he never quite felt ready to release. There were numerous other projects, the details of which I don’t remember at this point. All I remember is the overwhelming feeling of his work suddenly stopping, and the sadness of knowing those projects would never see an actual user.

When I flew back to Alaska and started working on some of my own projects again, I realized I didn’t want my son to someday look through my computer and see a bunch of unfinished projects. I started looking more critically at my own projects, and made a commitment to myself to take a more professional approach to my work as a programmer. I had the skills to do meaningful projects, and I wanted to start using my skills to solve real-world problems. I let go of any quest for perfect code and started focusing on bringing some of my projects to the point where I had actual users.

I fell into a book project almost by accident. I gave a lightning talk about an open source education project at PyCon in 2013, and in one of the conversations that followed I was invited to consider writing a book. I went back to my classroom in the following weeks and noticed a list on the wall I had made with my students. Someone had asked what you need to know as a programmer in order to start working on meaningful projects. I looked at that list, and turned it into a book proposal; the proposal was accepted, and I got to write the book I’d always wanted to teach from.

This was my favorite page to finally see in print.

This was my favorite page to finally see in print.

Holding my first copy of the book last night was a bittersweet experience. I felt a deep sense of pride and accomplishment, and accepted warm congratulations from my family and a number of close friends. But I felt an odd mix of emotions when I thought of my dad. I wished more than anything that he was still alive, so I could hand him a copy of my book. But without that last lesson about the importance of finishing projects, I would never have taken my own work seriously enough to follow through on such a large project.

So thank you dad for sharing your love of programming with me. And thank you for that final lesson as well; I finished this book for you, and now I’ll find another project that’s worth following through on.

Posted in family, programming | Leave a comment

How advertising ruined the rickroll

I’m currently teaching a class called Who owns you? In this class students take a critical look at the apps we use on a daily basis, and they can learn to build their own simple apps if they want. To lighten things up, I’ve been starting each class with a computer-related joke – Why did the mosquito fly away from the computer? It didn’t want to get caught in the World Wide Web! Students love it, and the jokes often lead to meaningful critical and technical conversations.

Today I tried to go a step further and rickroll my entire class. I set up a document with the following text showing:

Today’s joke: (scroll to see the joke)

Then below the visible screen:

Why did the chicken cross the road? (scroll to see the answer)

And a little further down:


It worked – most of the students had never been rickrolled, and I got to sit back and watch them enjoy their first exposure to Rick Astley. In many ways, it was my most successful rickroll to date.

But in one significant way, the experience was utterly disappointing. When the student unknowingly clicked the link with all of us watching, a 30-second youtube ad started playing. Students are so used to ads that it didn’t ruin the rickroll – they were still caught off guard, and they still laughed and started dancing when they realized they’d been had. But the joke didn’t have nearly the same impact it would have had the video started playing instantly.

This led to a great discussion about the impact of online advertising. Students talked about the kinds of ads they like, and the kinds of ads that just get in the way of meaningful online experiences. Students recognize the need to fund online services; they know developers need to be paid, and they know that servers don’t run themselves. But most of us felt that anyone who cares about quality online experiences would never place an ad at the beginning of a Rick Astley video.

We didn’t stick to just advertising in today’s conversation; the rickroll is much more interesting than that. We also talked about what links meant in the original text-only internet, and how commerce helped and hurt the overall development of the internet.

It’s a great class. I just wish we could sort out online advertising well enough that today’s generation can enjoy the full experience of the rickroll.

Posted in education | Leave a comment

Ever’s First Starship

Ever has made many small ships, but this is his first larger ship that has a nice degree of symmetry, that he’d like to be able to build again. We decided to take it apart step by step, and take a picture of each step. I’ll do a more consistent job of photographing the steps next time, but I think this will serve as a functional set of instructions.

The Finished Ship



resized021 resized022


Building the Ship




resized069 resized068

resized067 resized066 resized065

resized064 resized063 resized062 resized061 resized060

resized059 resized058 resized057 resized056 resized055 resized054 resized053 resized052 resized051 resized050

resized049 resized048 resized047 resized046 resized045 resized044 resized043 resized042resized039 resized038 resized037 resized036 resized035 resized034 resized033 resized031 resized030 resized029 resized028 resized027 resized026 resized025

All done!

Posted in family | Leave a comment

The CyberConstitution Class

Each fall I teach an Introduction to Programming class, and it’s always fascinating to see the connections students make as they experience their first real exposure to programming. Today I introduced the concept of classes, and we ended up in one of the most engaging conversations I’ve had with students in a while. Instead of drawing from my own experience to make up an example during the lesson, I asked students the following question:

If you had infinite programming skills, what would you build?

It’s a question I like to ask from time to time, and I’m really glad I asked it again today. I gave students a couple minutes to jot their answers on notecards, then asked a few students to share what they had come up with. After discussing a couple ideas I asked if anyone wanted us to use their idea as an example. One student raised her hand, and here’s what she had written:

I would write a cyber constitution for America that would have a solid set of laws, but wouldn’t limit freedom of speech.

I told her it was a great example because we can easily identify some kinds of information that should be stored in an electronic constitution, and we can also identify some actions you’d want to take when working with an electronic constitution. Here’s the class we developed during the lesson:

class CyberConstitution():
    """A solid set of laws, that doesn't limit speech."""
    def __init__(self):
        """Initialize the constitution."""
        self.state = ''
        self.author = ''
        self.preamble = ''
        self.laws = []
    def add_law(self, new_law):
        """Add the new law to the list of existing laws."""
    def show_laws(self):
        """Show all the laws in the constitution."""
        for law in self.laws:
    def show_constitution(self):
        """Show the entire constitution."""
        print("This is the cyber constitution for the state of " +
            self.state.title() + ".\n\n")
        print("Authored by: " + self.author)
        print("\n\nOur constitution contains the following laws:\n")

I had no idea how compelling this example would turn out to be. Right away, a number of questions came up:

  • “How many constitutions are there?” (51 in the US alone, and ours was one of the most recently written. Many students had no idea each state has its own constitution.)
  • “Are there laws in a constitution, or are they called something else?”
  • “What’s a preamble? What would we say in a preamble?”

I asked what laws students would put in a constitution, and recorded their responses in code:

# Make a constitution.
my_constitution = CyberConstitution()

# Set the attributes (information) for the constitution.
my_constitution.state = 'alaska'
my_constitution.author = 'sr'
    'All internet users must be licensed to access the internet')
    'Marijuana possession, manufacture, etc. is legal in this state.')
    'Gas prices will always be less than $2.00 per gallon.')
    'Everyone will have access to a free, ' +
    'high-quality, invidualized education.')
# Show the constitution.

Here’s the output:

This is the cyber constitution for the state of Alaska.

Authored by: sr

Our constitution contains the following laws:

All internet users must be licensed to access the internet.
Marijuana possession, manufacture, etc. is legal in this state.
Gas prices will always be less than $2.00 per gallon.
Everyone will have access to a free, high-quality, invidualized education.

It helps to read these suggestions with an understanding of what high school students might be thinking about on a typical morning. The first suggestion comes from students who have watched their peers be bullied to the point of physical violence, and watched people’s lives be significantly affected by the negative impacts of social media. The second comes from students watching many non-violent people in their lives face all kinds of legal issues for marijuana violations, while many better-connected people around them get away with the same behaviors. The third suggestion comes from students who struggle to pay for gas with their high-school level jobs. The last one was my contribution.

These are great issues to discuss, and they place programming in a much-needed context. It’s not really about the code you write, it’s about what problems you might be able to address if you stay interested in programming. It’s about knowing what can be done with code, event if you don’t stay with programming.

After the lesson students went back to work on their own programming exercises. Most of them are not using classes yet, so no one expanded on the CyberConstitution class today. But they went away with a better understanding of how programmers can build tools that re-engage people in the fundamental question of how we might build the kind of society we want to live in. What more could we want for students in an Introduction to Programming class?

If you’re a programmer, you can play around with CyberConstitution on github.

Posted in education, programming | Tagged , , , | 1 Comment

Processing a long list efficiently in Python

This post was inspired by Brandon Rhodes‘ excellent talk at Pycon 2014,  All Your Ducks In A Row: Data Structures in the Standard Library and Beyond.

Python’s lists are dynamic.  You do not need to declare their length ahead of time, and you can add to them at any time. How does Python manage memory for a list when it doesn’t know how long your list is going to be? It allocates a little extra room at the end of the list, in case you end up adding some more items. Most of the time this makes your list operations fast, but it can catch you off-guard if you don’t think through some operations carefully.

Consider an example where you want to work through a long list, popping items until the list is empty:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop()
    print number

This code makes a simple list of 100,000 numbers. It then removes the numbers one at a time from the end of the list, and prints each number as it is removed. When I time this program on my computer, it takes roughly 1.3 seconds.

Now let’s try the exact same program, except each item will be popped from the beginning of the list instead of the end of the list:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop(0)
    print number

This program takes twice as long! The difference is even more significant if you use a longer list.

Why does it take so long? Python is constantly moving all of the items in the list, since lists are more optimized for adjustments at the end of the list than they are at the beginning.

An efficient solution

How can you do this more efficiently? Since the goal is to work through each item from the beginning of the list, you can reverse the list before popping its items. Then you can pop from the end of the list, which is efficient, and still work through items in the order you intended to:

numbers = [x for x in range(0, 100000)]

while len(numbers) > 0:
    number = numbers.pop()
    print number

The reverse() operation takes a negligible amount of time to run, so this version takes rougly 1.3 seconds again.

The takeaway? If you are looking at performance issues, understanding how Python manages memory can be really helpful in making optimizations.

Posted in programming | Tagged , , , | 3 Comments

The education community needs a better online discussion tool

The Educator News homepage.

The Educator News homepage.

I just finished building Educator News, and I’d like to explain a bit about why I built the site. It’s an early draft of what I want it to be, but the basic functionality is there. If you would like to see a beter online conversation about education taking place, take a look and share your feedback.

I have wanted to find an education-focused site that has these criteria:

  • Good submissions. Good submissions are articles that offer some specific insights about how to do education well. Good submissions offer specific critiques of certain issues in education. Artilces may be political in nature, but good submissions avoid anything to do with simply spreading FUD.
  • Good comments. Good comments contribute to a constructive conversation about education. Good comments respond to specific points in the article being discussed, and to other points people are raising. Like good submissions, good comments avoid spreading FUD. And of course, good comments are respectful of other people even in the midst of heated disagreement.
  • Good community. A discussion site needs a healthy, active community in order to be interesting. People need to submit thought-provoking and informative articles, and read some of the submissions that others share. People need to encourage positive submissions and commenting behavior, and respectfully but decisively address poor submissions and poor commenting behavior.

I have never found a strong education-focused news and discussion site online. The sites I have found all suffer from some significant drawbacks – they are not very active; they are active, but there is not much substance to the discussion; they are active, but they only focus on one aspect of education.

A clear set of guidelines is critical for building a strong community.

A clear set of guidelines is critical for building a strong community.

What does Educator News offer that should make it a strong community? I believe EN has the right structures to create a better online conversation about education:

  • An upvoting system for submissions. Upvote the submissions that add to the conversation, and ignore the sumissions that distract from a meaningful conversation. If people do this consistently, the front page will be full of meaningful submissions and free of low-quality submissions.
  • A flagging system for submissions. If a submission is pure spam, or otherwise completely inappropriate, you can flag the submission. Flagged submissions will be reviewed, and can be set invisible by moderators.
  • A system for ignoring bad domains. When some domains are identified as consistently being a source of inappropriate or low-quality submissions, these domains can be ignored. The community will no longer need to manage submissions from these domains individually.
  • A system for upvoting comments. Everyone who registers on Educator News can upvote comments. Upvoting is not about agreeing with a comment; it is more about encouraging well-written, thoughtful responses.
  • Downvoting comments is a privilege. When users gain enough experience on Educator News, they can then help downvote non-constructive comments. There is a clear set of guidelines for what kinds of comments we want to avoid. This includes abusive and offensive comments, but it also includes vague comments such as “I agree!” and “Me too!” These kinds of comments tend to clutter up online discussions.
  • A system for flagging comments, and ignoring users. If a comment is abusive, seriously offensive, or way off-topic, the comment can be flagged instead of downvoted. Flagged comments are reviewed, and these comments can be ignored. When a comment is ignored, it becomes invisible to everyone else on the site. If a user consistently makes inappropriate comments, their entire account can be made invisible to everyone else.

Not an echo chamber

There is a bit of a danger, when building a new community, of creating an echo chamber for your own ideas. Educator News is not an echo chamber. When I built EN, I put aside all of my opinions on what makes good education except for one: I want people to disucss the substance of ideas that relate to education. I put aside my own political beliefs about education, and simply focus on helping to facilitate meaningful, evidence-based conversation. It’s the same thing I do on a daily basis when guiding conversations between students in my classroom.

If you’d like to help build a high-quality conversation about education, please join us at Educator News!

Note: Educator News is modeled after Hacker News, which I have learned a great deal from over the last few years. For the technically-minded, EN is a fully open project, and you can see the Github repo if you are interested. It’s ugly MVP code for now, but I am steadily cleaning it up. Feel free to open an issue.

Posted in education | Tagged , , | Leave a comment

Ninety Days on Github

90 days on Github

90 days on Github

Ninety days ago, I unknowingly started my first real Github streak. I didn’t really decide to start a streak until I was about 17 days in, but since then I’ve been very conscious to keep it going. I’ve thought about ending the streak a few times recently, but it’s still more of a benefit than a burden. There are a number of things I’ve noticed as the streak has started to be measured in months instead of days:

  • Contributing at a minimally meaningful level is becoming routine; it’s just part of my day now.
  • I’m aware of the length of the streak, but these days it’s more of a habit I want to keep than a number I’m trying to chase.
  • Contributing on a daily basis keeps me from losing sight of the long-term goals of my projects. This makes it much easier to work more intensively on my projects when I get a window of time.
  • Someone reached out to become involved in one of my projects (introtopython.org). I’m starting to mentor this person, which is very rewarding and motivating.
  • I find myself getting more involved in an active, highly professional mailing list (IPython-dev). It is inspiring to have meaningful conversations, and even some collaboration, with such focused and talented people.

I had two satisfying milestones during the last 30 days. I finally converted a Basemap tutorial from an old blog format to the new project I am working on. It’s the first project for introtopython.org, and I’ve already received some positive feedback about the tutorial. It was a fair bit of work to make the original tutorial, and it feels much better to have it hosted in a collaborative project rather than on my personal blog. I am more confident it can be kept up to date, and not die a rather quick death of outdated installation instructions, and broken links to government data sets.

Highlighting lines of code that have been added or modified in a tutorial.

Highlighting lines of code that have been added or modified in a tutorial.

I also made a quick and dirty method for highlighting single lines of code in the IPython Notebooks I am using to make introtopython.org. I feel this kind of highlighting is essential for making good tutorials and learning resources. I’m sure there is a more elegant way to implement this kind of highlighting, but I was at least able to bring a bit of functionality into IPython that I needed to make an effective final product.

Maintaining a longer streak feels a little forced and artificial at times, but overall it is keeping me connected to some important projects and some inspiring people. I’m going to aim for another 30 days, and I still have a satisfying sense of wonder about where these next 30 days will lead.

Posted in programming | Tagged , , , , , , | Leave a comment