What is Programming Coding?
Computer programming, also known as coding, is the process of creating software. But what exactly is software, and how is it made?
What is Software?
Software is a set of instructions for a computer to perform.
It’s a bit like a cooking recipe:
Crack an egg into a bowl
Whisk the egg
Put a pan on medium heat
Grease the pan
Pour the eggs into the pan
And so on
Instead of manipulating ingredients, computers manipulate data. The instructions inside software look more like this:
Load some data
Load some other data
Transform those two bits of data into result data
Send the result data to the monitor for display
Send the result data over the internet
And so on
These instructions are usually called source code. Source code is just a set of written instructions that a computer can understand.
What Does Source Code Look Like?
Code is not written in natural languages, like English.
Here is a little program written in a language called Ruby:
require 'open-uri' require 'json' FRONT_PAGE_URL = 'https://reddit.com/r/all.json' front_page = JSON.load(open(FRONT_PAGE_URL).read) top_post = front_page['data']['children']['data'] puts 'The top post on reddit is:' puts top_post['title'] puts top_post['url']
This program displays the current top post on reddit, like this:
The top post on reddit is: One of my favourite things about working in the ski fields http://i.imgur.com/hWwlWgI.jpg
Here is the exact same program, written in a similar language called Python:
import urllib, json FRONT_PAGE_URL = "https://reddit.com/r/all.json" front_page = json.loads(urllib.urlopen(FRONT_PAGE_URL).read()) top_post = front_page['data']['children']['data'] print "The top post on reddit is:" print top_post['title'] print top_post['url']
Here is the same program in a different-looking language called Clojure:
(require '[clojure.data.json :as json]) (def front-page-url "https://reddit.com/r/all.json") (let [top-post (-> front-page-url (slurp) (json/read-str) (get-in ["data" "children" 0 "data"]))] (println "The top post on reddit is:") (println (get top-post "title")) (println (get top-post "url")))
As you can see, programming languages are very different to natural languages. Natural languages are ambiguous, with many different layers of meaning – sarcasm, innuendo, and those sorts of things. That’s great if you’re communicating with a human, but computers don’t understand any of that.
Computers take everything literally. If you ask a computer whether a number is odd or even, it will always answer “yes.” I’m not even joking – here is the Ruby code:
puts (5.odd? or 5.even?)
This code displays “true,” which is technically correct. The number five is either odd or even, but that’s not what I meant.
It’s More Than Just Writing Code
Writing code is just one part of making software.
Large pieces of software – like Windows, OS X, and big-budgets games – are made up of millions and millions of lines of code. When you have that much code, you need to plan out how the code will be written, and how different parts of the code will work together. This kind of planning is called design or architecture. On large projects, a lot of time is spent designing and architecting before code is written.
Another large part of making software is testing. Just because the code has been written doesn’t mean it is correct. The code might crash sometimes, or give the wrong results, or freeze, or any number of other problems. To try and avoid these problems, professional software developers have various different ways to test their code.
Then there is debugging, which is the process investigating, diagnosing and fixing problems in source code. This is a skill in itself.
So programming is writing instructions for a computer to perform. The instructions, called source code, are written in special languages that are unlike natural human languages. It also involves planning, testing, and debugging source code.