a first programming language (intro)

pigeon

The first programming langauge we’ll cover is a reductively simple one I’ve created and call Pigeon. The basic concepts in Pigeon reflect those found in real languages we’ll learn later, such as Javascript and Python.

data types

Any program language has a basic set of data types. The basic types in Pigeon include numbers, strings (pieces of text), and booleans (the values true and false).

operations and expressions

The real action in our code is composed of operations and expressions, which are basically the same as found in mathematics, but written in a different form.

variables and assignment

A data value can be stored in a variable, a symbolic name. At any moment in time, a variable has one current value, but in the course of code, we can assign it new values; a variable always has the value last assigned to it. For example, say the variable adam currently has the number value 3; if we assign adam the value 8, it henceforth will have that value until we possibly later assign it some other value.

branching and looping

Our code needs to make decisions: either do this or do that. This is called branching, and for this purpose we have a construct called if-else.

Other times, our code needs to loop (to do the same thing repeatedly).  For this purpose we have a construct called while.

functions

Pigeon, like any language, comes with a small set of built-in operations, but the programmer may wish to create their own operations. A function is a programmer-defined operation.

collections

A collection is a value (a piece of data) which is made up of other values. Collections allow us to deal with sets of data, say the annual average rainfall in Toronto for the last century or, say, the name of every student in a school. Pigeon has two types of collections: lists and dictionaries. The values in a list are ordered by number, i.e. first, second, third, and so on. The values in a dictionary are not ordered but rather are each uniquely identifed by an associated value, called a key.

Comments are closed.