Programming Languages 201617 (F28PL)

Course overview

Welcome to the Programming Languages 201617 webpage. In a nutshell, this course says:

“How should we program? Well, it matters what programs we have in mind. Let’s think this through …”

For historical reference.
See this year’s course.

Lecture times

- Thursday at 13:15 in EM2.50 (lab/tutorial).
- Thursday at 15:15 in JN302.
- Friday at 10:15 in WP1.08.
- Friday at 13:15 in EM1.83.

The rules:

  1. Attend lectures.
  2. Keep up with the course so you follow lectures. Research stuff on the in-ter-net.
    A student who thinks “I’ll sort it out during the holidays” is a student in denial (look at 1m03s).
  3. Rules 1-2 apply most especially to the student who thinks that rules 1-2 do not apply to them.

Lecture slides

Here are slides:

- Lecture 1
- Lecture 2
- Lecture 3
- Lecture 4
- Lecture 5 – Python

The pdfs below were developed from the following older slides (l11 below corresponds to lecture-1 above):

l11.pdf l12.pdf l13.pdf l14.pdf l15.pdf l16.pdf l17.pdf l18.pdf l19.pdf l20.pdf


Deadlines are to complete the coursework exercises (see below).

Questions A and B
End of Thursday 6 October (passed).
Questions C and D
End of Saturday 15 October (passed).
Questions E and F
End of Thursday 27 October (passed).
Questions G, H, and I
End of Saturday 5 November.
Question J
End of Thursday 10 November.
Questions K and Z
End of Thursday 24 November.

Coursework exercises

Coursework exercises are here. These count towards your final grade.

Labs from 2014 are here (this is old material but may be useful for extra exercises):

- lab07.pdf - lab08.pdf - lab09.pdf - lab10.pdf - lab11.pdf

(Supplement) Tutorials

- tut06.pdf - tut07.pdf - tut08.pdf - tut09.pdf - tut10.pdf

See also:

- Study class 1.
- How to answer a programming question.
- A poem.
- Some comments on how to answer the question.
- Ciaran Dunne’s answer to QI7.
- A one-hour Prolog tutorial.
- A short WatMan talk exploring the corner cases of various programming languages, in a similar spirit to some of our explorations of Python.
- Not a bad page discussing types in Python.


Videos of lectures will go online as they are given. See also last year’s course videos.

Lecture of Thursday 15 September at 15.15 (video)
An introductory lecture. I warn that second year is harder than first year, so if you did OK without turning up to lectures or trying too hard in first year, then don’t necessarily assume you can do the same this year. I fire up PolyML.
Lecture of Friday 16 September at 10:15 (video)
More on PolyML, including types.
Lecture of Friday 16 September at 13:15 (video)
By this point we’ve done int, real, string, functions, polymorphism (both ad hoc and parametric), and we’ve touched on lists.
Lecture of Thursday 22 September at 15.15 (video)
More on ML.
Lecture of Friday 23 September at 10:15 (video)
We discuss Booleans.
Lecture of Friday 23 September at 13:15 (video)
We discuss lists.
Lecture of Thursday 6 October at 15.15 (video)
An extended worked example involving map, filter, and Pythagorean triples. Also some recap of equality types and other stuff.
Lecture of Friday 7 October at 10:15 (video).
Lecture of Friday 7 October at 13:15 (video).
Lecture of Thursday 13 October at 15.15 (video).
Lecture of Friday 14 October at 10:15 (video).
Lecture of Friday 14 October at 13:15 (video).
Lecture of Thursday 20 October at 15.15 (video).
Lecture of Friday 21 October at 10:15 (video).
Lecture of Friday 21 October at 13:15 (video).
Lecture of Thursday 27 October at 15.15 (video).
Lecture of Friday 28 October at 10:15 (video).
Lecture of Friday 28 October at 13:15 (video)
We discuss Python sets and the output of
for v in {"a","b","c",1,2,"B",(4,)}: print(v)
I manage to slip both paradichlorodiphenyltrichloroethane and supercalifragilisticexpialidocious into the conversation. A student takes this opportunity to mention (twice!) the fair Welsh village of Llanfairpwllgwyngyllgogerychwyrndrobwyllllantysiliogogogoc - which Wikipedia describes without apparent irony as a “request stop on the … line between Holyhead and Bangor” - and he warns us against pneumonoultramicroscopicsilicovolcanoconiosis (if you can say it you probably haven’t got it).
Amongst all this fun, I barely have time to mention this clip from Guardians of the Galaxy (2m50 to 3m28).
Lecture of Thursday 3 November at 15.15 (video).
Lecture of Friday 4 November at 10:15 (video)
We start on Prolog.
Lecture of Friday 4 November at 13:15 (video)
More on Prolog, up to the static and dynamic databases and asserta and assertz.
Lecture of Thursday 10 November at 15.15
A problem class. We write Fibonacci in ML, Python, and Prolog, and the function “return the even-indexed elements of” on lists. I recommend you do the same for several functions of your choice, and make sure you understand the exercises. I give a speech on how concepts are patterns that will recur; there is no such thing as a wasted concept.
Lecture of Friday 11 November at 10:15 (video)
We finish Prolog, discussing asserta, assertz, retract, retractall, and cut.
Lecture of Friday 11 November at 13:15 (video)
A very nice problem class; I sing a song.
Lecture of Thursday 17 November at 15.15 (video)
Lecture of Friday 18 November at 10:15 (video)
More revision.
Lecture of Friday 18 November at 13:15 (video)
More revision.

To watch the files above, you may need to download then locally (right-click save, then open); just left-clicking on the link may not work.

See also
- lectures from last year,
- the list of tutorials below.


rlwrap gives BASH-style history and completion at the command line. If you don’t know what that means then trust me—-you want this.

Run SML, PolyML, Python 3, and SWI Prolog by respectively typing

rlwrap sml
rlwrap poly
rlwrap python3
rlwrap swipl

The exam

A mock paper is available in two flavours:
- Without solutions.
- With solutions.
Attempt the one without solutions first.


In addition:
- These 50 Chuck Norris facts will be examinable.
- So will all 93 of these rules of cycling (my personal favourites: rules 9, 12, and 14).

Interesting webpages

You may like:
- Hans-Wolfgang’s course F21SC on Industrial Programming which covers C-sharp and Python.
- This list of ten reasons not to use a functional programming language. (The ‘not’ here is ironic.)
- A Wired article about functional programming (Erlang and Haskell) being used by WhatsApp and Facebook. A worthwhile read.
- A rather beautiful article by Paul Graham about functional programming (Lisp) used in a startup. Also a very worthwhile read.
- If you liked Paul Graham’s essays, you could also look at The hundred-year language and Revenge of the nerds.
- A one-page SML crib sheet. Very helpful.

Course resources

- Rosetta code is worth at least one visit, and not just because you’re doing F28PL.
- A Python visualiser. Or jump straight in.

Local stuff

- Lecture videos.
- Lecture slides.
- Tutorials.
- Labs.


- Study class 1.
- Example SML programs (from a previous year, but still useful), and also
- The standard SML basis library. A useful read to explore built-in functions.
- A one-page SML crib sheet. Very helpful.
- These ML lecture notes from the University of Washington are succinct and very clear.


There’s some really really good stuff online, including:
- Learn python the hard way.
- Learning Python.
- This online Python course, in particular the page on recursion.


- Example Prolog programs.
- Bill Wilson’s Prolog dictionary.
- The Prolog tutorial by Paul Brna and Tamsin Treasure-Jones dates back to 1996 and is still great.
- Lydia Sinapova’s Prolog Class Notes.

Required reading

You are required to read the following short essays, which discuss imperative programming (represented by C, Pascal, and Java), functional programming (represented in the essays by Lisp and in this course by ML), and logic programming (represented by Prolog).
I may base a discussion question in the exam on material from these essays.

  1. Beating the averages,
  2. The hundred-year language, and
  3. Revenge of the nerds.

A bit about me

I am a researcher in theoretical computer science. My research is mostly in formal logic.
Everybody calls me Jamie but my name is actually Murdoch. You can contact me by e-mail on “gabbay at macs hw ac don’ttypethis uk”. My office is G.50 Earl Mountbatten Building.

The students

Ah, well. I’m glad you asked. You should be second year undergraduate students. Let me know if this is not the case; I’d be interested to know!

A propos nothing in particular

- Revised log levels proposal: “FYI” “WTF” and “OMG” (John Barnette)