Blog Post

How I Succeeded at Learning to Code

 

How I Succeeded at Learning to Code

Or, When Programming Transformed My Methodological Dexterity

 

Earlier this year, on January 10th, I published a blog post in which I challenged HASTAC readers to make 2012 their "year of code," calling for grad students all across the network to sit down and learn to program.

Well, I failed. … Kind of. No, that's a total lie. In reality, I succeeded beyond what I thought was possible. But it took me much failing to discover how I needed to learn, which led to my success. For those of you that have ever been interested in programming or been told that you need to learn -- whether you're a social scientist looking at online behaviors, a humanist navigating the disciplinary shift toward digital methods, or a hard science scholar on the prowl for better statistical techniques -- this article is for you. 

Fail and Fail Again: Learning to Learn to Code

I'm here to say that everyone should learn to program. In fact, I will staunchly now take the stance that every graduate program should require one year of coding instruction (specifically in Python) to their students, regardless of discipline.

What people don't realize is what programming is. I know many feel that programming seems daunting. Realistically, though, programming is just as natural as writing a paper: you type out instructions like how you hold a reader's hand as you traverse your academic arguments. 

Before 2012, I had spent a couple of years attempting to learn to code. I had a high level of experience with markup languages like HTML and CSS, and I had been inculcated with QBASIC through a middle-school curriculum. But for some reason, self-teaching myself to code just didn't work. I tried mentorship, working groups, and online instruction (like MIT OpenCourseWare) in a variety of languages: nothing pulled through.

After writing the HASTAC blog post in early January, I attempted learning through CodeAcademy as a last-ditch effort: it seems like step-by-step interactive instruction was going to be it! Wrong again. As a new service, CodeAcademy was a bit buggy, and Javascript did not gel well with me. Just reading instructions on what to write and reproducing them wasn't helping. I abandoned the effort around March.

 

 

It Finally Clicked with Python

Then came the summer, and the clouds opened up. With the boom in Massively Open Online Courses, one major player -- Udacity -- opened up its doors. Udacity, co-founded by computer scientist and Google-er Sebastian Thrun, provides instruction in a number of programming-related areas, including an Intro to Computer Science course that walks the student through Python (a popular, well-supported programming language) while building a web crawler as a class project. 

In my eyes, Udacity did three things right: 1) it sets up the experience directly in the browser, meaning the student doesn't need to download anything to start coding; 2) it combines video content with other textual instruction, where questions asked in the video are translated immediately into text and interactive question-asking modules; and, most importantly, 3) it provides a quick-fire approach to teaching and quizzing, where the student watches a 1-3 minute video per concept, going through 6 chapters of about 50 videos each in the intro course. Additionally, Udacity not only provides questions that challenge you to write code, but the questions help you think through the issues of programming rather than merely duplicating lines and running them to see what happens.

 

Also, it's important to highlight the importance of choosing Python as the programming language. Python is a popular scripting language that is useful for, basically, any task. You can use Python for simple scripts, web development, complex mathematical processes, and more.

The crucial aspect of Python for social science and humanities scholars in particular is its approach to code: it emphases readability and structure over anything else. Thus, for individuals who have never coded in their lifetimes, they can look at Python code and understand, for the most part, what's going on. The language uses easy-to-read syntax and whitespace to visually block out code, again to emphasize readability and the communication of code over all else.

Finally, Python is well-supported in the tech community and industry. So many programmers use and develop for Python that you can find hundreds of packages that provide additional functionality and toolkits to the language. Many industry leaders use Python (eg., Google) on a day-to-day basis. And there's many people that know Python, resulting in almost an overabundance of resources in case you ever get stuck (the best probably being StackOverflow, a question-and-answer website for programming issues). 

Over the summer, I completed the Udacity course working on and off in the evenings for about three weeks. Since the end of the summer, I've written dozens of scripts that have been useful to my research, and I now consider computational methods as part of my personal toolkit.

 

 

for steps in success: print steps >> win, win, win

 

I highly recommend that you check out Udacity's CS101 course. If you're ambitious (or bored), you can finish it over Thanksgiving break. If you need more time, you could spend 1-2 hours a day for about 2 weeks during winter vacation working through the exercises. 

 

But then you learn to program… so what? What value could coding possibly bring to your discipline, to your research, to your personal growth?

 

Well, for one, there are so many practical directions in which anyone could possibly take Python:

- counting word occurrences and co-occurrences in large texts

- statistical analysis (using the numpy and scipy packages)

- network analysis (with the networkx package)

- gather data from various APIs: Twitter, Facebook, LinkedIn, Tumblr, etc.

- create a web scraper for harder-to-gather data

- perform word-based analysis (utilizing the natural language toolkit)

- fashion a personal or academic website

- automatically organize and catalog your PDFs and physical books

- set up a webpage for a survey, open-ended questionnaire, or for people to qualitatively code your content

- image analysis, graphs, data visualization, and mapping

- creating video games and art

 

But beyond practical tasks, you can also use Python in profound ways to shape your research methodologies and approaches. 

 

For me, as a second-year PhD student at the Annenberg School for Communication & Journalism at USC, I use Python to look at social behaviors on social media sites: my area of research deals with digital data, and I come from a traditional ethnographic and media studies background (in particular working with danah boyd at Microsoft Research and Henry Jenkins while he was still at MIT). With Python, I can take one step further into my research, driving much of those studies toward empirical analysis (or, at the very least, making the empirical parts much easier, faster, and more automated). Programming in general, though, has given me an entirely new outlook on my methodological perspectives and provides new opportunities to work with data that I previously hadn't had skills to access.

 

Overall, programming with Python is a worthwhile endeavor, one which I've been helping various classmates at USC Annenberg reach for their own projects. Udacity makes it easy to learn quickly, and from there, all it takes is a bit of imagination to fit code into your methods of research (and maybe some extra skills at searching for the right toolkits, if you need them). It's still not too late to make 2012 your year of code!

97

2 comments

this is a great explanation of your endeavour of learning to program, the ups and downs, the tools and resources you used, and the benefits you have drawn from it. Very motivating as well to go ahead and do the same! Thanks for the list of examples, they provide a good context of why learning to code might benefit me or any other person.

86

Great read. I particularly like the expression "Methodological Dexterity". Picking up some basic coding skills—Python as well primarily because of NLTK—hasn't necessarily changed what I work on (yet), but definitely how I go about my work, so I can really relate here.

72