Comparative Programming Languages

CMPT 383, Summer 2021

Greg Baker

This Course

Comparative Programming Languages.

Instructor: Greg Baker. Office hours: Fridays 13:00–14:00, online.


  • Amir Daneshpajouh
  • Aunnoy Mutasim

Course web page: in CourSys

Online Offering Strategy

My online instruction plan: change as little as possible from in-person offerings.

  • Don't remove material; don't add material.
  • Keep what can be done online.
  • Adapt the rest as best possible.

Online Offering Strategy

Lectures will be pre-recorded.

In the lecture time, they will be available as a YouTube Premier (≈ watch party) in ≈50 minute chunks. Greg will be available to answer questions during that time.

They will be available as regular YouTube videos for viewing later.

Online Offering Strategy

Technology choices:

  • Lectures: YouTube.
  • Discussion forum: Piazza.
  • Office hours by video chat: Zoom (or ask in discussion).

Online Offering Strategy

Requirements for you:

  • A PC with a webcam.
  • … that is powerful enough to run a VM: at least 8 GB memory, 20 GB disk, reasonably decent processor (not too old, not a Celeron or other low-spec).
  • Windows, Mac, Linux all good.
  • A stable Internet connection.
  • Occasional participation during lecture time for quizzes. (3 times)

Topics (1)

Functional programming.

  • … with Haskell as the primary language.
  • What is functional programming?
  • Basics of Haskell and functional programming techniques.
  • Why is functional programming interesting?

Topics (2)

Programming language features.

  • What are the important differences between programming languages?
  • What factors might influence choice of language?
  • Why are there so many programming languages?

Topics (3)

Safe programming, ownership, and concurrency.

  • … with Rust as a language that helps with all of this.
  • How can a language ensure safe programs (and safe in what sense)?
  • The compiler can give us a lot of assurances, if the language is designed for that.

Overall Goals

My big goals for the course:

  • The world of programming languages is more interesting than just C++ and Java. It's good for you to see that.
  • Learning other programming languages can make you a better programmer, even if you only use Java/C++.


Where the marks come from:

  • Weekly Exercises: 10 × 1.5% = 15%
  • Assignments: 10% + 15% + 10% = 35%
  • Quizzes: 3 × 8% = 24%
  • Project: 26%

Compared to in-person offerings: eliminated midterm and final exam; introduced quizzes and project.

Weekly Exercises

There will be a short exercise due most Fridays: ten in total. Designed to reinforce basic ideas and force you to practice the concepts.


There will be one larger assignment for each major section of the course:

  1. functional programming + Haskell (10%)
  2. programming language features (15%)
  3. safe programming + Rust (10%)


There will also be one quiz for each major section of the course, worth 8% each. Dates may change if necessary, but planned during lecture times:

  1. June 24 (Thursday of week 7)
  2. July 15 (Thursday of week 10)
  3. August 5 (Thursday of week 13)


The project will integrate ideas from the rest of the course.

It will involve creating a system with parts written in different languages and interacting with each other. You will need to choose appropriate languages to implement different components and have them communicate.


Some optional books/​references if you want them:

I'll add additional links to the course web site and/or lecture slides as appropriate.


To get credit for this course, I expect you to demonstrate that you know how to apply a variety of programming language concepts. That means:

  • A pass on the weighted average of the stuff where you demonstrate programming ability: exercises + assignments + project.
  • A pass on the average of the quizzes.

Failure to do these may result in failing the course.


Academic Honesty: it's important, as always.

If you're using an online source, leave a comment.

def this_function(p1, p2):
    # adapted from

If you work with another student, we shouldn't be able to tell from the results.

More details on course web site.


You are expected to do the work in this course yourself.

Independent work is not copying a solution from somewhere but understanding it. If you work with another student, we shouldn't be able to tell from the results.

More details on course web site.


The quizzes are structured as regular tests: individual work, but open book.

It will be hard to monitor that, but cheating on our quizzes will be treated as equivalent to cheating on an in-person exam, with corresponding penalties: I will be asking for a grade of FD in the course for any academic dishonesty on quizzes.

What is a program?

We're going to be looking at programming differently that you're (probably) used to, so we'll have to rethink our basic definitions too.

What is a program?

An old definition I used in CMPT 120:

An algorithm is an unambiguous sequence of instructions for solving a problem. A program is a description of an algorithm that a computer can understand.

i.e. a program is a sequence of instructions.

What is a program?

Consider this instruction in some programming language:

total = values.sum()

How is .sum() evaluated? Right to left? Left to right? In parallel on many cores?

There are many details of that instruction that we didn't really specify. We left them to the language/​library to figure out.

What is a program?

Some languages don't specify a sequence of steps. One you might be familiar with:

SELECT users.last_name,
FROM users INNER JOIN orders ON user_id
WHERE > today()

How does the database get you the results? You don't know (because it depends at least on the way the tables are indexed).

What is a program?

We will see more examples of languages that don't specify steps explicitly (in case you don't think SQL counts as programming).

We are going to have to adjust our understanding of what a program is.

Imperative Programming

The old definition of programming was probably a good definition of imperative programming.

In an imperative program, the programmer gives an explicit series of steps that must be followed in order; variables represent the current state and are manipulated directly by the programmer.

e.g. C/C++, Java, C#, Python, JavaScript, …

Imperative Programming

But there's more to the world of programming. Previously-held assumptions that we'll see aren't always true:

  • Programs are made of statements/​instructions that are followed in order.
  • The programmer indicates what values to store in memory.
  • Programs are composed of functions/​methods/​procedures and classes/​objects.

Declarative Programming

In this course, we will explore some non-imperative languages. Declarative languages let you describe the results you want, but not the exact sequence of steps required to get there.

Declarative Programming

Examples of declarative (non-programming?) languages:

  • SQL: describe the records you want, joins to make, etc. The DB server figures out how to get those results.
  • XSLT: describe transformations on an XML document.
  • HTML, CSS, SVG, Makefiles, HTML template languages.

Declarative Programming

There is not a totally clear line between imperative and declarative languages.

That is, a programmer can often do declarative-like things in imperative languages, and vice-versa.