Learn to code like a journalist
Conversations with Data: #34
Do you want to receive Conversations with Data? Subscribe
We’ve all heard it before: Coding has become an essential skill for newsroom journalists. Yet, despite the demand for these skills, many of us are hesitant to get started, either because of an aversion to numbers or the seemingly huge task of grasping a new language.
We think it’s time to strike down that fear.
In this edition of Conversations with Data, we’ve collected practical advice from a group of global experts, so that you can begin coding...like a journalist!
What you said about getting started
Almost all of our contributors agreed that the best learning strategy is to pick a project, rather than teaching yourself coding for the sake of it.
Why? “Because it will quickly seem a bit pointless and abstract,” said Paul Bradshaw, course leader of the MA in Data Journalism and the MA in Multiplatform and Mobile Journalism at Birmingham City University.
“Try to pick a project which is relatively simple, skills-wise, and then move on to new projects which add increasing complexity in the areas you're interested in.”
Ændrew Rininsland, FT, reiterated this advice: “Depending on your learning style, you'll likely get much further looking up specific questions that lead towards building a discrete project than you will by trying to memorise an entire Python textbook”.
However, taking on a project doesn’t mean you will immediately accomplish your goals, Rui warned.
“You will not. You will dream big, but the lack of knowledge will always be a roadblock. Should that stop you from trying again? Of course not. Ira Glass said it about storytelling, but I think it fits perfectly with my life as a journocoder: ‘for the first couple years you make stuff, it’s just not that good. It’s trying to be good, it has potential, but it’s not. But your taste, the thing that got you into the game, is still killer. And your taste is why your work disappoints you’. Learn how to balance the dissatisfaction of something not being as great as you wish with the pride of accomplishing something.’”
Likewise, Kira Schacht, from Journocode and Deutsche Welle, told us to embrace mistakes and use them to refocus on your project’s goals.
“Don’t be afraid of messy code the first -- or the fiftieth -- time you try. There are many ways to solve a problem, so what if it takes you a few detours to find yours? The results of dead-end approaches often turn out to be useful for future projects anyway. Especially as a beginner, though, it can be easy to lose your goal in the woods of tutorials, functions, and data structures. Once an hour, take a deep breath and ask yourself: What exactly was I trying to do again?”
After you’ve built up some skills, then start teaching what you’ve learnt to others. Even if you don’t have someone to teach, Rui Barros suggested using Rubber Duck Debugging tactics, or you could create your own tipsheet, as recommended by MaryJo Webster from the Star Tribune.
“Writing down how to do something or telling it to someone else helps you realise the gaps in your knowledge and also helps it stick in your brain. If nothing else, make a repository of code snippets and put it in a place you can easily find. Mine is just a text document (not exactly ideal, but it gets the job done) where I put in things like ‘How to import an Excel file’ followed by a line or two of code that is either an example from a previous project or is a generic piece of code that will help me remember the syntax for doing a particular task,” MaryJo explained.
Geoffrey Hing from APM Reports seconded this advice, adding “that one of the biggest advantages to this is that it acts as a sort of Rosetta Stone for the language you use to describe what you're trying to do and the language used by other practitioners. Often when I'm searching the web for resources on how to do something, or asking others for help, the biggest impasse is that I'm using different language. In my snippet library, I try to reference both the language that feels natural to me (so I can search for it easily in the future) and the language used in the resources I eventually found.”
Similarly, you can also blog about the things that you’ve learnt.
“People generally get nervous about the idea of writing about a topic that they're not experts about. But hey, we journalists do it all the time! Writing about a new skill you learned has two positive effects: it forces you to think through all the angles of something you've learned and make sure you really understand it, and it documents that knowledge for the future. If you get something wrong, someone will (hopefully gently) point it out to you ... and you'll learn more!” explained computational journalist Ben Hancock, with reference to Sachua Cha's No Excuses Guide to Blogging.
What you said about choosing the right programming language
Now that we’ve covered the foundations of getting started, let’s look at picking the right language.
First up, the data team at Code for Africa highlighted the idea of ‘focussed learning’. Remember that you don’t need to learn everything, just what’s relevant to you. So, think about the tasks at hand, such as scraping and crawling or plotting and visualisation, and look for the best tools to get those jobs done. Here are some of their suggestions:
“If you want to use code for scraping/data analysis, learn that, focus on just the libraries you need; for data analysis, Numpy and Pandas are great and for scraping -- Scrapy (all from Python). Our recommended coding languages would be Python and R, and learning resources would be edX.org and Datacamp where a number of courses are free.”
Journo-dev Laurence Dierickx backed up this advice: “Before diving into the code, ask yourself which programming language will suit what you would like to do the most. If it is to deal with data, maybe you should first learn R or Python, then SQL. If you would like to develop interactive contents, PHP and MYSQL would probably be more relevant.”
By now, you should have an idea of some languages to explore. To get experimenting with them, try these tips from MaryJo Webster, which she used to first learn R:
“...pick an analysis you've already done using another tool and replicate it in whatever programming language you are trying to learn. Under this scenario you don't have to learn a new dataset and/or a new topic, freeing up your brain to focus on learning the new programming language. And you don't have to go through the process of figuring out what to do with the data -- you already know the steps. I did this when I was first learning R. I had several analyses that I repeat every year -- like school test scores and an annual look at our housing market -- and had previously done in SQL or Excel, depending on the difficulty. I had notes outlining the steps in my analyses and I just had to figure out how to do the same thing in R. It made the learning process so much easier.”
For more standalone resources, check out Paul Bradshaw’s primer on programming concepts and computational thinking, along with these tipsheets (here and here) from Cailtin Ostroff of the Wall Street Journal. And don’t forget our video course, Python for Journalists, taught by NOS’ Winny de Jong.
Our next conversation
When Code for Africa submitted their coding advice, it got us thinking about how data data journalism is practiced across their region. The team operates Africa’s largest network of civic technology and open data labs, and we’re excited to have them with us for an AMA in our next edition. Be sure to submit your questions by commenting below.
As always, don’t forget to comment with what (or who!) you’d like us to feature in our future editions.
Until next time,
Madolyn from the EJC Data team