Introduction to Programming


~1,100 words


Last modified: December 28th, 12,015 HE

[…]that affability and condescension which God shows to the learned, that promptitude with which he protects and supports them in the elucidation of obscurities and in the removal of difficulties, has encouraged me to compose a short work[…]

Muḥammad ibn Mūsā al-Khwārizmī

The other day, someone asked me to explain what coding is to me and what the different types are plz. I defined programming and explained about the existence of different languages, grouped into paradigms and often split into different dialects, and gave them the flawed-but-suitably-colourful metaphor for the similarities between programming and natural languages. Someone else said it was quite interesting and that I should do some sort of tutoring, so they could soak up my knowledge.

Gross, but I’m not too busy so here goes.

An Introduction and a Justification


There are between a billion and a trillion1 programming tutorials out there on the internet, so why write another? Because I’m bored af stuck at home over the holiday I can’t think of any that approach programming in as language-independent a way as possible, and I think that’s a niche that’d be nice to fill. I think programming is entirely a task that can be learnt, as least to a basic understanding, in a language-agnostic way. Dijkstra complains that

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

Edsger W. Dijkstra, How do we tell truths that might hurt? (EWD498)

and whilst I can’t speak for BASIC (having cut my teeth on VB.NET), I feel there’s an argument to be made for learning ‘a programming language’, rather than ‘programming’, being a potentially harmful and restricting approach.

Bear in mind that I’m probably not a programming genius. I’m just another berk with a keyboard, so if I get something wrong please don’t bite my ear off. I can’t offer £2.56 for corrections because I’m poor, but I will try to fix what’s broke.

How This Tutorial Will Probably Work

Right now, I can think of 5 or so well-defined parts. Whether there’ll be more, I don’t know. I’ll try to keep them fairly light-hearted and not overly technical, but there will be some brief forays into the mathematical underpinning of programming concepts now and then. It might look scary, but they’ll actually be fine — I didn’t even do A-Level Maths and now I’m doing Computer Science at university.

Also, I’ll try to add the odd bit of historical flavourtext now and then, because I find myself far more motivated to learn something when I can get a sense of the bigger picture and tangents I could follow if I wanted to. I’d rather have more information than I cared about than not enough to satisfy me, so I’ll give you the same. I’ll probably colour them differently or something.

I can’t be arsed with pseudocode, and I’m not so dedicated as to make up my own programming language just for this tutorial, so examples of programming concepts demonstrated in code will be in real-life languages. However, in the interests of keeping this guide as language-agnostic as possible, I’ll mix them up as I go through so that this doesn’t become like a guide to C programming (I hear K&R have a quite well-regarded one of those already) or something.

I’ll also stick a recommend reading at the end of each chapter, with books I hear are good as well as ones I know are.

Some Definitions

There are some pretty fundamental definitions that it’s probably a good idea to ensure we’re all on the same page or before setting off on our journey of discovery and wonderment.

The distinction between programming and coding

In my mind, at least, programming is the act of devising a program/algorithm to solve a problem, whilst coding is the act of translating that program/algorithm into a particular programming language — to use the first of many slightly shaky programming-language-to-natural-language metaphors, programming would be roughly analogous to Fyodor Dostoevsky creating the story of a dysfunctional family whose father ends up suspiciously murdered, and coding roughly analogous to him writing it down in Cyrillic characters as Бра́тья Карама́зовы, for other readers (of Russian) to acquire the story via. Coding could then also be extended to describe people like Constance Garnett, David McDuff & co. translating the book into The Brothers Karamazov and the Latin alphabet.

What is Turing-complete?

Turing-completeness is more of a theoretical concept than anything else, but the idea is that a Turing machine is Turing-complete if it can be mathematically proved to be possible to compute any task using it, giving a sufficient amount of memory and computational time. In practice, it’s been proved that the simplest possible Turing machine requires only 2 possible states and 3 possible values of a symbol,2 meaning pretty much everything is Turing-complete. Including Conway’s Game of Life, a programming language called Brainfuck and rocks. Yes, even Minecraft is Turing-complete, as someone demonstrated by making a computer in it.

Alan Turing

For a general overview, I can think of one excellent book:

Code: The Hidden Language of Computer Hardware and Software, by Charles Petzold. One of the best books I’ve ever read. Starts out with basic logic, explains how it can be represented in electrical circuitry and builds from there, through telegraphs to transistors to programming languages.

The Annotated Turing: A Guided Tour Through Alan Turing’s Historic Paper on Computability and the Turing Machine, by Charles Petzold. Haven’t read it myself yet, but I hear good things. For anyone more interested in the theoretical, mathy side of computer theory. A sentence-by-sentence breakdown of Alan Turing’s On Computable Numbers, with an Application to the Entscheidungsproblem, the paper that created computer science back in 1936.

You could also watch The Imitation Game, directed by Morten Tyldum and starring Benedict Cumberbatch and Keira Knightley. An entertaining, if not wholly accurate, dramatisation of Turing’s breaking of the Enigma cipher.

  1. Actual real number, honest. ↩︎

  2. See article on the Wolfram blog here ↩︎