I’ve been thinking for a long time about how to write this post. This is the second in a series about coding, for journalists. It’s taken a while to get to this second post because I’m still feeling conflicted about exactly what to say.
In the first post, I wrote about HTML and CSS. I have no qualms about urging journalism educators to teach some HTML and CSS in journalism courses. I even say it should be required — not as a whole course with nothing else in it, but as part of some normally required journalism course such as editing or publication design.
So that’s how I’m going to start — with something simple and basic that you should understand.
That is no longer considered good professional practice. (In fact, it’s been frowned upon for several years already.) I’ll say more about that in the next section.
One of the best arguments for learning jQuery: It can do beautiful things with data tables. But I’m getting ahead of myself.
Beginners making Web pages can download and use various jQuery plugins — among the most popular are “lightbox” plugins (see an example), which usually display photos in an overlay, fading the rest of the page beneath a semi-transparent gray screen. Increasingly popular is the jQuery UI library, which includes all kinds of readymade pretty things such as pop-up dialog boxes. You can also use ThemeRoller to create a whole interface where everything matches and looks perfectly professional.
You can make things move. You can change the order of data (as you can see in the tables example linked above). You can change colors and styles. You can make anything respond to clicking or dragging or mouse movements. You do this by using CSS styles and selectors embedded in your HTML (which means you need to know CSS to use jQuery well).
But how can we learn these?
If not — do you give up? Well, no. I would never suggest that.
Two very excellent books have answered most of my questions about these things:
jQuery: Novice to Ninja (the clearest text with the most useful, practical examples; there’s a new second edition) Update: According to a post from SitePoint staffer Simon Mackie on Feb. 8, 2012, the changes in the second edition include “a fairly substantial addition to Chapter 9″ regarding jQuery Mobile, as well as updates for jQuery 1.7 (first edition covered 1.4).
As always, please post a comment here if you have a correction or a question.
There’s been a lot of talk about journalists learning to code, and that conversation mainly centers on programming. When we say programming, we mean the use of computer programming languages, which cause things to happen. Things happen because a user — a member of the audience — touches something or adds some information. Interaction. Programming makes things happen.
I want to write a short series of posts about coding, for journalists. That includes journalism students. And yes — it includes the journalism educators too.
Today I’m starting with something we call code, but most people would agree it is not programming. The system we use to present information on Web pages begins with HTML, a markup language that structures the content of the page.
I’m starting with HTML because I know a heck of a lot of journalism educators have never tried to learn HTML, and that’s just wrong. You know how to use a comma? Good, I would expect that. The basic use of HTML is just as important as correct use of commas, and it’s certainly not harder to learn.
In fact, it’s probably easier.
Introducing HTML to the timid, the skeptical, the downright terrified
When you think about a magazine or newspaper article, you know it probably has a headline, a byline and paragraphs. HTML is used to identify each of those things, to mark each one as a structural element of the document. Each element is surrounded by a pair of tags. Tags look like this:
Similarly, when some text in a paragraph appears as bold or italic, or as a functional link to another Web page, that bit of text is surrounded by a pair of tags.
You can be fairly fluent in HTML if you memorize about seven basic tags. Go ahead, click that right now and show yourself how un-scary this is.
Now, thanks to the brilliant folks at Codecademy, you can learn HTML in a painless, even fun, way — free, online. Go there, sign up for a 100 percent free account, and get started with their Web Fundamentals track. I’ve tested this with real live journalism students, and it is just great. Go. Go now. Start at the top, do everything from top to bottom, and don’t skip anything.
So you go to Codecademy. Good! You complete a few exercises on a Sunday afternoon. Good! And then … you don’t look at any code again for two months.
Bad! Very bad!
Even more important than having a nice little project in mind is coding every day. Yes. I said every day.
Yes, of course, you’re going to miss a day now and then. But here’s my biggest, best tip ever: NEVER miss two days in a row. Never. We forget this stuff even faster than we forget foreign language vocabulary when we fail to use it.
Also, don’t exhaust yourself by working on your code-learning goals for too long at one stretch. This makes it a chore, and tedious — and you will start to associate feeling grumpy with learning code. And then you won’t learn it.
I’ve been telling my students to aim for one hour a day. Some days you’ll do less. Some days, you’ll do much more. And those are great days, when you want to keep working! I got this idea from Zed Shaw, who wrote about this idea in his introduction to his online book Learn Python the Hard Way. He compares it to learning to play the guitar. Practice, practice, practice. It’s a fine analogy.
Introducing CSS, the style that dresses up the structure
I have one complaint about the current Codecademy exercises for Web Fundamentals, and that’s the way they introduce CSS styles.
CSS can be added to HTML directly in three ways (and there are other, indirect ways too). But first, let me give you an analogy.
HTML makes the structure of a document explicit, so it’s rather like a skeleton, or the girders and beams that frame a building. On top of that skeleton, we add muscles and skin and hair. On top of the frame, we add plaster and paint and decorative flourishes. CSS is the code that governs colors and font families, size and shape, the way it all looks. This is HTML. And this is HTML with CSS.
So this code can be inserted directly into the structural areas of a document — right inside the HTML tags. This is the worst approach, because it’s a pain in the neck to change it. Codecademy starts you out with this way of inserting CSS, and that’s what I don’t like.
The second way to add CSS to HTML is to place all the styles at the top of the document, inside an area called the head (not to be confused with headings). This is slightly better, but it still means that if you needed to update or change your styles, you would have to go in and open every darned page on your website. Yeah. Imagine doing that at The New York Times.
The third way is the best way, and (I would say) the right way: All the CSS code is written in a separate document, a separate file. This way, when you have to make a change, you change it once, in one single document, and instantly it changes all the instances of that style everywhere it is used, on every page in your website.
By completely separating the style from the structure, we make it easy to update, correct and improve the styles.
But I don’t mean any disrespect toward Codecademy — they’ve done a great job overall, and the second half of their excellent Web Fundamentals track is all about using CSS in a separate document.
Why start with HTML and CSS if these are not ‘programming’?
My thought is that most journalism people — students, teachers, reporters, editors — work a lot with words. If you start them out with words, and formatting that makes their headlines look pretty and lets them incorporate photos and captions, then they are starting from a place where they already have some level of comfort. If you start them out with code, the alien nature of that world might seem to be too great a leap.
I’m not saying everyone needs to memorize massive quantities of HTML and CSS, or master these to the extent that you could code an entire 10,000-page website. No. I am saying you need to understand how this stuff works, because all the Web uses HTML and CSS.
And note, I have not mentioned any software programs in this post. This is not about software. This is like learning how to use commas.
Update: New Resource for Learning HTML and CSS
(May 4, 2013) Recently I discovered that an old favorite of mine, the HTML Dog site, has redone all their tutorials for HTML5 and CSS. Everything has been updated to reflect today’s new coding environment! Highly recommended!! Note: This site is vastly better than the W3 Schools site, where you will likely be misled by some outdated materials.
(Oct. 27, 2013) If you want an explanation of why W3 Schools is a poor reference, read this.
My university played host this weekend to several dozen journalism educators and some very wonderful working journalists. They all came to the Journalism Interactive conference to share what they know and learn new things about digital media and training the next generation of journalists.
Most of our conference sessions were in the historic building in the photo above, which provided a warm atmosphere unlike the typical conference hotel or campus-based venue. We had lovely sunny weather and lots of happy attendees. Those who were stranded overnight because of canceled flights (thanks to a big snowstorm in the northeastern U.S.) didn’t seem put out at the prospect of spending an extra day in Florida.
I produced a Storify using the tweets I had favorited during the events of Friday and Saturday at J/i. This was an interesting exercise in curation for me — I tried to keep up with all tweets tagged #jiconf as they appeared, and I favorited only about 1 in 20. Then I opened my own Twitter Favorites in the Storify editing window and made selections with the aim of representing different attendees and different panels and speakers.
When you’re writing a blog, you should check your stats from time to time (I’m not as obsessive about it as some are) to see what people are reading, where they came from (referrers), what they click in your posts.
Search terms are especially interesting to me. They don’t exactly correlate with the most-viewed posts on a blog.
I find the popularity of the search terms timeline, timelines, and — check out the detail list! — the Chinese characters for “timeline” to be mystifying. When I do a Google search for timelines,my post about that topic doesn’t even appear on the first two pages of results.
That brings me to a key observation about paying attention to your stats. If people are coming to your site because of a search, you should think about whether you might want to offer them more on that topic. I don’t mean you should add stuff that doesn’t match the mission or purpose of your blog — but think about whether it makes sense for you to beef up your content to satisfy those searchers.
Early in 2011, I looked at my blog stats and saw that a large number of searches then included the word timeline. So I searched my blog and found I didn’t have any posts devoted to the design or production of timeline graphics. So I made a mental note to get around to that, someday — because those graphics are part of teaching about online journalism.
Later that year, in April, I was asking students in a journalism course to create an interactive timeline graphic in Adobe Flash. I wanted to show them examples, so I dug into my bookmarks — and then I had the material for a blog post about timelines (already linked above). I suppose that accounts for the extraordinary dominance of related terms in my stats for 2012.
There are hundreds of search terms (in my WordPress stats for this blog) that resulted in fewer than 40 site visits in 2012. If I did a text analysis of all the search terms (maybe using a clustering algorithm from Overview?), maybe I would find others in the 200-300 count range, or even higher, but I’m not that into it. I had enough interest to paste the top search terms into Excel and generate the chart you see above — which took a lot less time to do than writing this post!
Take a look at your blog’s search stats — if you’re serious about blogging.
Update: Total search terms that people used in 2012 to come to Teaching Online Journalism: 498 (my WordPress logs do not show any terms that were used fewer than 5 times). Total visits from those search terms: 10,837. (So the people who came for timelines may represent about one-fifth of all who came via search.) Total site visits for the year: 99,567.
Digital expertise is no longer an option for journalism students at both undergraduate and graduate levels, and digital training should be an integral part of any journalism program.
Unfortunately, digital training is not always desired by students who enroll in a journalism master’s degree program.
When students enroll in a graduate program for journalism, they come with a very wide range of expectations and assumptions (this is true not only at my university — I’ve discussed this with professors at various j-schools around the United States and Canada, and they see the same range).
Some students have not thoroughly researched what real journalists do in their jobs. Some students are not fully aware of how the journalism field has changed in the past 10 years.
One consequence of that shortage of information: Students may resist or even reject training in digital skills necessary for, say, data-driven journalism. Why? Because the student wants to be “a writer” or “a TV reporter.”
Everyone who wants to apply to any journalism graduate program, at any university, needs to research the field and the jobs in that field. Don’t make any assumptions. Check out the ads for real journalism jobs today.
In this blog post (Why Journalism Tools Gather Dust), Dan Schultz of The Boston Globe describes what amounts to one of the big reasons why news websites are not as successful as they could be.
If you borrow code then you are more likely to be familiar with what the rest of the world is doing. If you share code then you are going to build your systems with an emphasis on reuse and extensibility (i.e. correctly). If you regularly borrow AND share code then you are building a community around whatever it is you do.
What I’m trying to say is that if newspapers can buy into the mantra of openness — even just internal openness — they can kill about thirty birds with one stone.
But they usually don’t.
Legacy media companies have a lot of bad habits. Like some close-minded people, these companies have dragged their ancient prejudices and beliefs with them into their old age.
What Schultz describes reminded me of a newsroom that jealously guards a “scoop” that’s not really a scoop — some news they uncovered that — seriously, guys — either no one really cares about except other journalists, or everyone will find out about anyway within an hour, so who the heck cares if you break it first? (I’m not saying there are no real scoops; I’m just saying that journalists sometimes get all proprietary and hush-hush about something that truly is not groundbreaking or even secret.)
As Schultz points out, some media organizations such as The New York Times do follow open-source principles — but there’s more to it than that:
[W]ithout a supportive institutional strategy, open source and reusable code are just nice-to-haves.
A deadline mentality (also dragged along from the past) encourages short-term thinking. Almost everything in most newsrooms is about today and right now; very little is about planning and building for the future.
Recently a friend of mine — formerly a professional programmer and systems analyst — lectured me about my plan to teach journalism student to code. Teach them to respect commenting and documentation, she said. Teach them to write code that others can come along later and read, because by doing so, they will become better programmers, and their future code will be better because of the effort.
Why is this required reading? These ideas are important for discussion, both in the classroom and in the newsroom.
I’ve been thinking about this a lot lately. I’ve been preparing a syllabus for an upper-level undergraduate journalism course that I will begin teaching in January. I’ve been learning Python and starting to learn about jQuery.
I’ve got some advantages: I learned HTML in 1995. (I bought a book and did all the exercises in it, at home, on my own time.) I played with the BASIC programming language on my first computer in 1984 until I learned how programming works. (I bought a book and did many of the exercises in it.) I bought an account at an early online community called the WeLL, which gave me access to a Unix command line, which helped me learn about the Internet before we had the Web. I think that was around 1989. (I bought a book to learn Unix commands.)
I’ve had no formal training in programming or Web technologies. My B.A. is in print journalism.
I’ve got some disadvantages: I don’t have strong inclinations toward investigative reporting. I’ve taken two or three workshops with the old computer-assisted reporting crowd, and I admire what they do. I attended a wonderful presentation by Jennifer LaFleur (director of computer-assisted reporting at ProPublica) at a recent conference. However, I seem to lack all interest in examining large datasets. I can download them, dump them into Excel, and clean them. After that, I have no desire to do anything else with them. (I’m not proud of this. I’m just saying.)
I’ve had almost no math education. High school algebra and, in college, symbolic logic. No calculus. Not even a geometry class.
So I think about my journalism students. I think about what I like and don’t like, what I consider fun and interesting, and what I don’t. And I look at all the great work being done online by all kinds of journalists using a wide variety of digital tools.
What I want to do is open doors.
I want to be able to show journalism students that they can do things with code. Even if they think they can’t.
Above all, I want them to understand that “doing things with code” can lead you in several very different directions in the field of journalism.
This is important.
Moreover, they won’t practice what they learned, and very soon, they will forget all of it.
We can offer a course about scraping and doing stuff with large data sets. We can teach students how to find stories in data. Students who like this, who learn how to do it and want to continue doing it, are probably among those most likely to get a journalism job. Like the Web technologies course, though, this is a class that many students will either avoid like the plague or take and then count the minutes until it’s over.
Right now, many of you might be thinking thoughts about two types of students: those who appreciate such a course and use what they learn in it, and those who are not appreciative — and so what? Forget about them.
What I’ve been thinking about — a lot — is that there are a zillion ways to turn students off. To make them do things in a class that result in the students forming negative opinions. “I don’t like this,” or “I’m no good at this.” (I think this often happens in Reporting 101 courses too.)
Learning that you can do these things — these code type things — is the first step. Learning that you are capable. You can figure this out. You are not “bad at math,” or “bad at computers.”
Most journalism students learned — back in high school, or even before — that they are “good at writing.” Some of them are quite surprised to learn (in Reporting 101) that they are not good at writing a lede, finding appropriate sources, avoiding cliches, or using commas correctly. Yet the confidence that they are good at writing will sustain many of them through all kinds of setbacks.
If students realize that they can write code — they can figure it out, solve problems, make things that work properly — they will have opened a door that leads to dozens of different journeys in journalism.
They might choose data journalism and the investigation of large datasets.
They might choose design — they might go on to create new user experiences that make journalism more interesting to more people.
They might become a hybrid, a graphic journalist who combines data and presentation to make complex stories easier to understand, using animation and interaction.
My concern is that the way we introduce code to journalism students can push away those who might really excel in one of those areas.
I don’t have a solution. I don’t know if there is one.
But again and again I return to the way I felt in 1984 when I was learning BASIC, in 1995 when I was learning HTML. It was fun. I was happy to be learning. I completed little exercises and they worked. I felt proud of myself.