6. Programming fundamentals

Every programming language is different, and each works in a slightly different way. This is why there is, and why we learn, more than one programming language. Different languages have different pros and cons, and may better suit or not suit particular problems or constraints that are present.

Nevertheless, there a wide number of general concepts that apply across our different types of programming. Sometimes there are variations in different languages, and sometimes the same underlying concept is given different names in different places, but the approach is similar.

This part of the notes introduces some of these concepts, so that we can think about them in theory before getting to practicing them in the lab. We’ll mainly give examples in Python, but will also use pseudocode so we can focus on the underlying concepts rather than necessarily what’s needed to make them work in practice. Unless otherwise stated, assume that any code examples are in Python.

Some of the later topics, those from stack and heap memory and after, are relatively advanced and relate more to the latter half of the course on Rust and lower level languages. You may like to revisit these later in the course.

In any program, there are two key things that we need: data the information we’re working with; and operations we can do to that data to manipulate it, extract information from it, or convert it in-line with whatever our needs are. The basic unit of storing data is a variable. (There are then other types we’ll get to later.) The basic unit of code to manipulate data is a function. We’re going to introduce functions first, but of course this makes some use of variables, and so you might need to go back and re-read functions once you’ve also read about variables.