Tired of ads? Enjoy an ad-free experience by signing up.
Paul Bradshaw · · 12 min read

Coding for journalists: 10 programming concepts it helps to understand

Photo credit: The Daily Dot

Photo credit: The Daily Dot

If you’re looking to get into coding, chances are you’ll stumble across a raft of jargon which can be off-putting, especially in tutorials which are oblivious to your lack of previous programming experience. Here, then, are 10 concepts you’re likely to come across — and what they mean.

1. Variables

cat-box

Variables are like boxes which can hold different things at different times. Photo credit: Wolfgang Lonien.

A variable is one of the most basic elements of programming. It is, in a nutshell, a way of referring to something so that you can use it in a line of code. To give some examples:

  • You might create a variable to store a person’s age and call it ‘age’
  • You might create a variable to store the user’s name and call it ‘username’
  • You might create a variable to count how many times something has happened and call it ‘counter’
  • You might create a variable to store something’s position and call it ‘index’

Variables can be changed, which is their real power. A user’s name will likely be different every time one piece of code runs. An age can be added to at a particular time of year. A counter can increase by one every time something happens. A list of items can have other items added to it, or removed.

They can also be combined: an age (one variable) might be calculated based on a birth date (another variable).

2. Strings, integers and other jargon for types of data

A string is a series of characters — in this case, literally. Image by Kate Ter Haar.

A string is a series of characters — in this case, literally. Photo credit: Kate Ter Haar.

You can have different types of variables, which changes what you can do with them. Typical types of variables include:

  • Numbers — integers (whole numbers) and floats (those with decimal places)
  • Text — generally called strings and indicated by quotation marks like so: “17 August”
  • Lists or arrays — explained below — normally indicated by square brackets and commas like so: [“Manchester”, “Glasgow”, “Paris”]
  • Dictionaries or dicts — explained below — normally indicated by curly brackets, colons and commas like so: {“Age” : 23, “Name”: “Jane”}

This is important because problems can occur when code encounters information in the wrong format. For example, you cannot perform a calculation with strings, or in some cases, combine text with numbers.

In those cases coding often involves telling the code to treat ‘7’ as a number and not a string, or even to convert the string ‘seven’ to its numerical equivalent. Computers are great at performing tasks repetitively, but need explicit instruction on what they’re doing.

3. .classes and #ids and selectors

Stay ahead in Asia’s tech landscape

You've reached your 2 free content limit for the month. Sign up for free to read the full story.

🏄 For casual readers / 👶 Free

Basic

US$0

Free forever

Get instant access to this article and more every month

0 premium content

Unlimited news briefs

5

5 articles

Ad-free reading experience

Just US$0 per day

⌛Sign up in 20s. No payment details needed.

📖 For learners / 👍 Starter

Lite

US$4.92/month

Billed annually at US$59/year

Get instant access to this article and more every month

4

4 premium content

Unlimited news briefs & articles

Ad-free reading experience

Just US$0.17 per day

Cancel anytime

Our subscriber community includes professionals from these companies:

Stay updated on the go with our mobile app.

Get latest insights with smoother, more personalized experience through TIA mobile app.

Community Writer

Paul Bradshaw

Freelance consultant, trainer, speaker and writer on online journalism and social media. Visiting Professor at City University London and course leader for the MA Online Journalism at Birmingham City University in Birmingham, UK. Publisher of the Online Journalism Blog (onlinejournalismblog.com). Named one of the UK's "most influential journalism bloggers" by UK Press Gazette, "The UK's Jeff Jarvis" by The Telegraph's Shane Richmond and "The English village Jay Rosen" by Ben Goldacre.