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:

http://bit.ly/IqT6zt

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

resized014

resized016

resized021 resized022

resized023


Building the Ship

resized072

resized071

resized070

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."""
        self.laws.append(new_law)
        
    def show_laws(self):
        """Show all the laws in the constitution."""
        for law in self.laws:
            print(law)
            
    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")
        self.show_laws()

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'
my_constitution.add_law(
    'All internet users must be licensed to access the internet')
my_constitution.add_law(
    'Marijuana possession, manufacture, etc. is legal in this state.')
my_constitution.add_law(
    'Gas prices will always be less than $2.00 per gallon.')
my_constitution.add_law(
    'Everyone will have access to a free, ' +
    'high-quality, invidualized education.')
    
# Show the constitution.
my_constitution.show_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)]
numbers.reverse()

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

Github streak days 31-60: What I’ve learned

green_boxes

My current GitHub contributions graph

About two months ago I started writing some lessons for an Introduction to Programming class I was about to teach. I was using IPython Notebook to write those lessons, so I decided to put the notebooks on GitHub. I worked on the project pretty steadily, and soon passed my old GitHub record of 17 days. From then on, watching those little green boxes pile up got more and more addictive. Is it worthwhile to maintain a streak? I don’t want to keep it going forever, but it has definitely been worthwhile so far.

Introduction to Python - the main project I've been working on, as it looks now.

Introduction to Python – the main project I’ve been working on, as it looks now.

My main project at this point is Introduction to Python. Introduction to Python is an open resource for students who want to learn Python as their first language, and for teachers who want a free and open curriculum to use with their students. The project is growing steadily, both in terms of content and in terms of features that help students learn Python efficiently.

Improving my git workflow: branching

Introduction to Python, as it looked a month ago.

Introduction to Python, as it looked a month ago.

I have been a hobbyist programmer most of my life, which means I have worked mostly alone on my projects. When I started using git a few years ago, I began the bad habit of pushing all of my commits to master. This habit was great for starting a GitHub streak; it was easy to make a few commits each day, and some days I got to see some really dark green boxes show up. But as my project started to grow and attract some potential contributors, I started to feel really self-conscious about having such a cluttered master branch.

All output is collapsed by default, so readers can try to predict what the output should be.

All output is collapsed by default, so readers can try to predict what the output should be.

I knew about branches before, but had not practiced using them enough to make them part of my regular workflow. This streak has me using git every day, so it became harder and harder to put off using branches. Most of my commits involve adding content about how Python works, so many of these commits are quite appropriate to push directly to master, especially at this early stage. But one goal was to make the output of all sample code hidden by default, with a pair of show/ hide buttons below the sample code. This is a great learning feature; it allows students to predict the output of a code sample they are looking at, and then click a button to see if their prediction was correct. I am not a front-end guru, but I can find my way around js libraries and css hacks. Some of my commits while working on this feature would make no sense in master; they put buttons on the screen that didn’t do anything yet, and they put buttons on pages that had no output. So I did all this work on a feature branch, and then merged that to master. It was very satisfying to become more comfortable with a workflow I know will work well on a truly collaborative project.

A few other things I learned

I learned about a number of other things through pushing commits each day, and did some things I would not otherwise have gotten to:

  • I started writing some of my non-programming curriculum on IPython Notebook, so that I could share it easily with students. I would like to learn to use a Python static site generator such as hyde, pelican, jinja, or nikola, but I didn’t have time to dig into that this month. There’s so much that can be done just using IPython Notebook markdown cells!
  • I pushed the content on Introduction to Programming through making basic terminal applications. Now anyone who follows the curriculum starting at Hello World can learn to write simple terminal applications.
  • I feel more and more connected to the programming world outside my small town in Alaska, where my students are the only people I know who write any code.
  • I started writing tests! I wrote a test to verify that all links in this project are working. The default behavior is to start a SimpleHTTPServer and test the local working copy, but it accepts a flag to test all links on the deployed site. It does not yet test anchor tags, but just being sure that all links between pages and to external sites are not broken makes me more confident in the project overall. I also got to use Requests, which makes me feel like a Real Python Programmer.
  • I found that I am much more likely to keep a project going. I started a really cool version of a text-based Adventure game, which starts out with the player standing on the front steps of our high school. Students and staff loved the first day’s progress. In the past I would have copied this to my computer and maybe done something with it. Instead I just threw it up on GitHub, and I have worked on it a couple times since then. The simple act of using GitHub every day makes it easy to keep interesting, nascent projects alive.
  • I used Bootstrap 3.0, which I’ve been wanting to use in a project.

What’s next?

I’m going to try to keep this streak going a while longer, as long as it is keeping me productive and improving my professionalism in programming. In the next 30 days, I’d like to:

  • Keep using branches. This is a no-brainer, for everything except content that should go directly into the project.
  • Consider using pull requests. I know some people don’t merge any of their own branches, they submit all branches as pull requests, even if they are simply going to accept their own PR. I want to do this just to be more comfortable with the process of submitting and accepting PRs.
  • Keep adding content to Introduction to Python.
    • Finish the basic sections through Functions, Classes, Exceptions, and Testing.
    • Complete the first project, a mapping visualization using matplotlib Basemap.
    • Add more content around how to write programs. You’ve managed to learn a bunch of syntax, but how do you think through a project’s requirements and figure out how to  start writing code?
    • Clarify the section about setting up a programming environment: how to install linux on a donated computer, how to troubleshoot non-functioning Python environments, how to find help, etc.
  • Do some non-github work. I have one non-open project that I need to make significant progress on. It’s hard to work on closed projects when you’ve been immersed in the open source world, but I have a pretty meaningful project to work on. I aim to balance the two, instead of focusing so much on just the open source work.
Posted in programming | Tagged , , , , , , , | Leave a comment

What I’ve learned from my first 30-day GitHub streak

My first 30-day streak on GitHub

Look at that nice patch of green on the right hand side!

Today marks the end of my first 30-day streak of making contributions on GitHub. I had no intentions of starting a streak, but now that I’ve got one going, it’s addictive. More importantly, I find I am learning a great deal, and my overall work habits are improving.

Starting a new project

About a month ago I started teaching an Introduction to Python class, which I teach each fall. This year I decided to use IPython to write up my lesson notes and demonstration programs. In the course of learning IPython, I discovered how easy it is to post notebooks online using IPython Notebook Viewer. I ended up posting the notebooks on GitHub, and sharing them with students through the Notebook Viewer.

I wrote a post about how IPython and GitHub were making my teaching better, and I was quite surprised to see that post sit on the front page of HN for most of a day. The overwhelmingly positive response inspired me to keep working on the project, and before I knew it I had matched my previous streak of 17 days.

30 days: Nothing new on GitHub, but quite meaningful for me

I know there are some really long streaks on GitHub, and I have no intention of setting any records. But I was pleasantly surprised to find that I was learning a lot by maintaining my own streak.

  • I made steady progress on my project. I would have made steady progress on this project anyways, but having fun with a streak definitely helped me maintain a steady level of progress. Except for one or two days of simply opening a new issue, the streak has me focusing on writing at least some code each day.
  • Simply opening a new issue is not “cheating”. I opened new issues on a couple days when I didn’t have time to make a more serious contribution. But that wasn’t cheating. It gave me the chance to put into writing a number of issues that were stirring in my head. Good documentation always makes a project stronger, and tracking issues effectively is part of forming good documentation habits.
  • My first pull request. Yes I will accept it!

    My first pull request. Yes I will accept it!

    I got my first pull request! It was minor, but that’s what I expected for a first pull request. It’s a pretty good feeling to have someone else make even a minor contribution to a project I had started.

  • I learned more about git. Three weeks into the project, I decided to host static versions of the notebooks I was creating for students. IPython’s Notebook Viewer is a wonderful tool, but some of the longer notebooks were taking 8-12 seconds to load. GitHub was down one day during class, so students lost access to the public versions of the notebooks. I decided to throw static versions of the notebooks up somewhere, and ended up creating introtopython.org. The load times went down to about one second, and I have a much easier time pointing students to our learning materials. I ended up making a post-commit hook that converts the raw notebooks to html. I had heard of git hooks before, but never had the opportunity to use them until now.
  • I kept up with other projects as well. One of my routines each morning is to click the little blue notifications dot at the top left side of the GitHub page. I love the Gittip project, but I just don’t have time to contribute right now. Even though I can’t actively contribute, I still feel connected to that project by skimming the notifications every morning. When I do have some time to contribute, it will be much easier for me to jump into that project.

What’s next? 60 days?

I learned enough from these first 30 days that I want to try for a 60-day streak. I don’t care much for chasing numbers, but I am quite curious to see what the next 30 days will bring. I expect to see a much more refined project, and I hope to have a few more contributors. I expect to learn some more about git, and continue improving my overall workflow. And yes, I do look forward to seeing a larger area of solid green squares on my GitHub page.

There is one thing that might keep me from maintaining my streak, however. I have been a lone hobbyist programmer for most of my life, so I have developed the habit of doing almost all of my work on the master branch. I know I should be working on branches, and I read recently that committing to non-default branches does not count as a contribution; only the merge back into master counts. So it sounds like working on a branch for a couple days, for ten or so commits, will only count as one contribution on the day that branch is merged back into master. I certainly don’t want to let a streak motivate me to have a bad git workflow, so I will happily give up a streak to pick up a better overall workflow.

If these streaks we’ve been hearing about have made you consider starting your own streak, why not begin today? Who knows what you will learn, and what you might accomplish.

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

How IPython Notebook and Github have changed the way I teach Python

A live notebook about how to use lists in Python.

A live notebook about how to use lists in Python.

I teach in a small high school in southeast Alaska, and each year I teach an Introduction to Programming class. I recently learned how to use IPython Notebook, and it has completely changed the way I teach my classes. There is much to improve about CS education at the K-12 level in the United States, and sharing our stories and our resources will go a long way towards improving what we offer to students.

My first programming classes

3d Modeling

How I tend to use Python: A model of a koch snowflake, and the real thing printed in stainless steel. I wrote a Python program to generate the OpenSCAD code for printing the model.

Like many people who teach Intro to Programming classes, I don’t have a formal CS degree. I started programming as a kid, and then went on to a degree in Physics. I have always programmed for fun, however, and recently I have started to take my programming more seriously. As I have taken my own programming more seriously, I have been looking for ways to bring it into my teaching.

The first time I taught an introductory programming class, I created lessons each day and came up with exercises and challenges for students to try. Students loved the class, because they spent most of their time trying to apply what they were learning to problems they could solve. They felt like real programmers from the first day of the session. The class was a nice start for me as a programming teacher, but we didn’t get very far. It was just too hard to create curriculum at a pace that kept up with my more capable students. As someone without a formal CS background, there was also plenty I had to clarify for myself along the way.

The second time around, I tried to base the class on an established curriculum. I tried to use Zed Shaw’s Learn Python the Hard Way, because I had heard such consistently good things about it in all the tech communities I participate in. It didn’t work out though, because students just did not catch on to the approach of LPTHW. I know LPTHW asks students to write their own programs, but for people brand new to programming, there was just too much left to them to figure out, even with a teacher in the room. I have one student who really enjoyed it, but for most students we didn’t get a whole lot further than my first class, and they had a lot less fun along the way. This is not a criticism of Zed’s work, it is an admission that I did not use his curriculum in a way that captured my students’ interest in programming. My students seemed to respond better to very specific exercises based on what they just learned, with a more gradual transition into exercises and challenges that ask them to apply their own ideas to what they have just learned.

This year’s class

This time through, I wanted to go back to creating my own lessons, with more efficiency than I had before. I also needed a backup plan for students who might outpace my teaching. I heard about IPython Notebook every day at PyCon this past year, so I decided to take a look at it. Once I got used to it, I couldn’t believe how effective it could be as a tool for teaching.

An active editing session in IPython Notebook. Each cell can either be text or code, and code cells can be run as independent programs.

An active editing session in IPython Notebook. Each cell can either be text or code, and code cells can be run as independent programs.

If you are unfamiliar with IPython Notebook, it basically lets you mix Python code and text on the same page, and lets you run your code blocks as separate programs. IPython Notebook was developed for scientific programming, where you want to solve a larger problem through a series of smaller programs, with notes in between about your progress. This approach allows for a much more efficient workflow than having to write a bunch of separate program files, with your notes in separate text files.

As a teacher, I found this was a perfect tool for creating lessons. I write a few notes about a topic, then write a small program to illustrate how to implement the topic in code. IPython Notebook makes it easy to develop these lessons locally, and GitHub makes it easy to store these notebooks in a publicly accessible place. The IPython Notebook Viewer then makes them available in a reader-friendly format.

My basic workflow:

  • I created a notebook for the syllabus I’d like to follow.
  • For each topic in the syllabus, I create a local notebook which will hold lessons for that topic.
  • When I have time, I create lessons at home and push them live.
  • I always teach with my computer hooked up to a projector. When I clarify something during a lesson, I push the changes to GitHub as soon as the lesson is over.
  • If I cover a new topic in class, I write my examples directly in one of the notebooks. If the live work is clean enough, I push it straight to GitHub. If the live work needs a bit of cleanup, I commit locally and then push it live after class, when I have the chance to look it over more carefully.
  • If a student starts to outpace me, I can steer them into something more established such as Udacity or Coursera. These are the students who are likely to be successful in more independent learning settings.

Results so far

This workflow has been extremely satisfying so far, for me and for my students. We are having as much fun as we had the first year I taught a programming class, but we are covering things much more quickly as well. I can see a number of benefits in this workflow:

  • Students can have a copy of all class materials open on their own computers, and accessible outside of class.
  • We can add and modify exercises and challenges at will, throughout the class.
  • Students get to see some of the tools they will use when they become more proficient, such as git, GitHub, IPython, and others.

What’s next?

I really want to figure out a way to embed programming in my school culture throughout the year. A few thoughts about how to move forward on this goal:

  • Continue to develop the notebooks throughout this session. Some of this involves converting old blog posts into IPython notebooks.
  • Develop a core set of assignments that students can do in any class, that use their programming skills to help them in their other classes. For example, use your understanding of Python’s dictionaries to keep track of the key words you are learning in each of your classes.
  • Set up a system where students who reach a certain level of skill and understanding begin to teach newer students, using our class materials. This would take the pressure off of me to always teach introductory courses, and would let me teach some more advanced classes.
  • Clean up the notebooks, so they stand on their own rather than serving as class notes. Right now, they don’t read well for independent learning. This could be improved, although they probably shouldn’t get too wordy.

Collaboration

If you’d like to play with these notebooks, check out the project page on GitHub. I’d be happy to collaborate on building out these resources, so get in touch if you’d like to contribute. I can be reached through email, ehmatthes at gmail, or twitter @ehmatthes. If you are active on GitHub, you can also leave feedback on Issue #10.

Posted in programming | Tagged , , , , , | 12 Comments