Hacks: What do you mean when you say, “I want to learn programming?”
Do you want to grok Abstract Syntax Trees and learn how to optimize tail recursion?
- OR -
Do you want to be more technical so you can better understand and manipulate the technology in your ecosystem?
This question was inspired by the varied responses to Brian’s question from May 13th about what to teach Librarians in a two-hour, intro-to-programming session.
Out of the five responses (in the first 19 hours) I think my answer is the most accurate AND the most impractical. It is essentially the equivalent of:
SCENE: Man and woman standing on train platform. WOMAN: "Excuse me, Sir? Can you tell me the time?" MAN: LOOKS AT WRISTWATCH, THEN WOMAN. "Yes, I can." RESUMES READING NEWSPAPER.
Correct, but not helpful.
I’d like very much to be helpful. It would be illuminating to know what problems you are trying to solve when you think “I need to know programming.”
Maybe you don’t need to know programming. Maybe you just need to know how to frame the question so it can be answered by a program (or a programmer).
Maybe there needs to be course that teaches pseudocode for journalists.
So, Hacks, why do you want to learn programming?
Perhaps obviously, I believe the answer to this question differs dramatically from person to person, even in the same newsroom. That's why I think it's so hard to teach an intro.
For me, personally, at first I wanted to know enough to be able to communicate with programmers and understand what was possible. Knowing the difference between what would take a day and a month. What was worth me doing with basic tech skills vs. what someone could do faster programatically. That's a great way to start.
I ended up applying my journalistic curiosity to the skills behind the programming, though. Not enough to know you could develop a graph based off of variables calling a database, and that you could avoid making new graphs by hand every time news updated. I wanted to know the ins and out of how to do it, but didn't want to deal with it myself. That was Level 2.
Once I got a glimpse of how to do it, and felt the satisfaction of figuring something out, I wanted to develop it and make it happen. Now, I'm learning to be a programmer for news. This is Level 3.
There's an infinite number of levels ahead. I can't even tell you all the problems I want to solve, because I don't know what exists, still don't know the limit of what's possible. That's part of the fun. Perhaps the skill I need most is knowing how best to go about learning more. My current issue is improving my ability to structure complicated programs, and write functions in a more concise and efficient way.
Despite where I am now, if you tried to teach me about lists and dictionaries when I was back at Level 1, I bet I would have bailed. I think formal intros are good for a push in the right direction, but going really deep is something you have to commit to on your own.
It's worth considering the large difference between what I call "plumbing" programming and actual computer science.
Most web developers, (for the most part, I include myself in this), spend nearly all of their time making various libraries working with other libraries, getting data from one place to another, and presenting data. As much as I understand tail recursion (and actually, I don't grok ASTs), as a developer I don't need those skills, and journalists need them even less.
The best developers (as opposed to hardcore "computer scientists") I know exercise skill in understanding which libraries in their box of tools best apply to the problem at hand, and are then efficient at "plumbing" them together.
Whenever I've worked with journalists who are interested in being able to program, it's because they've seen several tools that they know could work well together, but they don't know how to make that happen. I think these are the skills that are most worth passing on.
Mark, this is a great question. When I was taking early classes in computer science I remember a teacher describe functions (and later, objects) as black boxes. You input things into the black box, "something happens," and then you get an answer. The goal of computer science is to make these black boxes. You reduce complicated problems (sorting things, routing airplanes) into algorithms/functions/classes that take inputs and give answers.
I think when most people are talking about "programming," however, they're talking about USING the black boxes rather than building them. They want to learn what it means to query an API and put it onto a map, or make a word cloud -- what Mark Ng called "plumbing."
I think the specific application of programming varies by project, but generally falls into one or more of three categories: collecting information, analyzing/organizing information, or presenting information.
While I think most people hope to achieve plumber status of programmer, there's definitely a group out there who simply wants to know how to communicate with the plumber and know whether they're getting ripped off.
I guess at the end of the day we're all black box plumbers?
The person asking the question should have a clear set of goals.
I would frame what I want to learn in three ways. I want to learn how to:
- Think computationally
- Think like programmer
Besides maybe not knowing what they want to learn, hacks sometimes also don't know what certain terms mean. For example, I've heard people call HTML "programming" instead of markup.
Probably the primary thing I'd want to do is scrape websites for information... Followed closely with mashing different sources together... Followed closely by visualisation.
Getting more ambitious, I'd like to create tools that allow users to interrogate and mix data in similar ways.
At the moment I'm trying to get my head around Ruby on Rails and Python primarily.
For me its about control.
I want to remove the layers it takes for me to disseminate information. I don't want to have to rely on a designer or programmer for anything.
When I first said those fatal six words ("I want to learn to program") I was thinking about cleaning and manipulating data -- essentially automating some of the excel tasks I was doing to clean up a big dirty dataset into something I could work with for a sweeps story. I imagine I'm not the first to think that; but what that works out to -- text processing and database interface -- was a good place to start learning.
The other thing that newbie geeks, including myself, always seem to find sexy is scraping online databases. My first real effort at web programming came when the state Department of Justice told me they wouldn't release a copy of their Megan's Law database (you know, the same one they ALREADY PUT ONLINE behind some god awful 1998-looking asp-and-arcIMS-powered sort-of-searchable front end. Yeah, that one...). Never underestimate the inspirational power of anger -- it taught me to use urllib2 and Beautiful Soup.
Though actually, what I was REALLY thinking when I said "I want to learn to program" was that scene in Terminator 2 when John Conner hacks the ATM.
As a Python developer, I've used BeautifulSoup and LXML to parse HTML pages grabbed from the web As mentioned above, BeautifulSoup has made some compatibility missteps in version updates, and LXML is generally considered faster, so I'd generally recommend LXML first.
LXML requires C libraries, while BeautifulSoup is pure python, so installing is sometimes a challenge: Mac users especially used to hit problems with running installer packages, although I think that is mostly past history, but if you run into problems, google for install lxml mac and if you still have problems, post a top-level question here and we can assemble instructions under a clear question header.
I learned to use BeautifulSoup from some of the interesting applied tutorials in the O'Reilly book Programming Collective Intelligence which provides an interesting balance between teaching coding (for people with moderate past Python experience) and teaching algorithms and advanced big-data-processing strategies (a lot less background in that is necessary to understand the book.) One reason I'm enthusiastic about this book is that it provides a good introduction to BeautifulSoup and several other real libraries and information services, in parallel to the declared subject matter.
Regarding PHP, I'm a novice at best. I haven't used this tool, but Daniel Berger offered it to the NICAR-L list in a similar thread:
I do a lot of work with data in a very small newsroom. Our editors have expressed interest in us doing more with visualization, but my skills are limited.
When I say I want to learn programming, I mean, I want to look at Flowing Data's tutorial on heat maps using R and be able to follow along.
I want to open up an API key and not have it read like gibberish.
I want to be able to see .GPX and KML files and be able to work with them (no more hand plotting on Google Maps for idiots, please)
Good question. I want to learn for a couple of reasons, but mostly because certain problems arise in my daily (online) life that require solutions that don't exist. At least, not to my knowledge... In some cases, programming can help.
The first - and only - tool I ever built is a pretty simple one. And it's a case that illustrates my motivations to learn pretty well. I wanted a service that would give me RSS feeds for a single search term across many platforms (Twitter, Delicious, YouTube, Google News, Yahoo News, and some Asian equivalents). By using some simple string replacement, the result was this. I tried using simple pie to parse the resultant feeds on the bottom, but with no luck so far. My code is here if anyone wants take a peek (please don't laugh!). I think a tool like this - if built properly - would be super useful for research.
I'd like to answer this from a skewed position: I want to teach journalism students some foundation skills in programming. Why? Because if they have some basic knowledge (like what I got in a FORTRAN course as an undergrad), they will find it much easier to tackle whichever language turns out to be useful the first time they really want to do a project.
Right now we have smart students who are good at design, majoring in journalism, and interested in doing some data visualizations or interactive projects -- but they've never been introduced to any kind of programming at all. I want them to see that it is not as hard as they imagine it to be. I want them to see, for example, how a loop automates a task that otherwise would be impossibly long, and understand that it could also be useful for so many other tasks.
I don't want to force them to simply do a programming project. I want them to understand the application of programming basics to a myriad of diverse problems.
Please login to post questions.