Ranges and expressions 1
Spreadsheet programming
Last updated
Spreadsheet programming
Last updated
The objective of this session is to introduce fundamental concepts and skills in design computing. We will cover the notions of sequences and transformations, information representations as well as touch upon generative design. We expect here some basic familiarity with spreadsheet and interactions with CAD software.
The notion of representation is related to cognitive processes. Briefly, we reason based on mental, visual and physical constructs. Those can capture exactly the same ideas but with different means, for example we can express the notion of linearity in the form of a mathematical equation ; a physical entity, such as scribe drawn on a piece of paper; or an object, say a straight edge. The are all facets of the associated characteristics we attribute to the underlying concept.
Representations are complementary in a sense, but each has its own benefits and limitations. We often employ multiple because they allow us to externalize cognitive processes, to communicate ideas, to off-load information and enable us to process information within a finite cognitive budget, and to take advantage of the power of our sensible sub-systems.
For our purposes we will use here three different representation systems:
a cellular data view of information using spreadsheets
a command line interface (CLI) for issuing drawing instructions
a computer aided design (CAD) environment for visualizing 3D entities
Computation explores the notion of a process, a sequence of operations that take place in time (by people or computing machines). Let us introduce the abstract notion of information processing through the idea of a sequence, a range, a series, or a signal; nomenclature varies depending whether we look at it from a mathematical, computer science or engineering perspective.
We will start with a blank spreadsheet, you may use MS Excel, OpenOffice Calc or Google Sheets, and create the most basic range possible: the natural numbers. We input the label “index” in the first column and zero as the initial value in the cell below. To create a range we enter the expression = A2 + 1
, which translates to “read the value above, add one and write it in this cell”. We then drag the corner handle down to automatically expand the range. Conceptually, this integer range represents the discrete ticks of our imaginary computing clock.
Range expansion is an amazing feature of spreadsheets that makes them popular for quickly replicating repetitive actions that exhibit some form of structure or pattern. Spreadsheet data manipulation is the oldest and still the most popular form of visual computing!
Symbolic Expressions
The notion of a symbolic expression is foundational to computing. You are already familiar with such expressions from mathematics. Manipulating symbolic variables for solving equations, independent of actual values, is a core component of algebra.
The expression entered above however, is conceptually somewhat different from a mathematical equation which establishes relationships between variables. A key distinction is that a computable expression has concrete inputs and it results to concrete outputs. In other words, we can directly evaluate computable expressions.
For example x + y = 1
, mathematically means that pairs of numbers, e.g. reals, must always add up to unity (“one”). This establishes a relationship, or constraint, between the x
and y
variables, but does not imply directly a way of determining those pairs that adhere to the relationship. We need to solve for “x
” and “y
”, i.e. search for them.
On the other hand, input + 1
is a computable expression for determining a new value given an existing one. In computing we write output = input + 1
to show where the new value is supposed to be stored. The proper way to interpret this statement is as output ← input + 1
. The arrow, highlights clearly the distinction between a mathematical equality, a sense of truth, and a computational operation of (1) reading a value, (2) performing an addition and (3) storing the result.
Information Layout
Another pleasing aspect of spreadsheets is that they visually capture the notion of information storage through cells i.e. content placeholders. The particular “memory” layout is that of a rectangular grid. The arrangement of cells in a two-dimensional layout is influenced by the flat shape of the monitor and perhaps traditional paper media. It has nothing to do with what we can compute!
For example, we may stack all columns vertically and still be able to perform the same operations. In fact, in general computing we conceptualize memory as linear, like a single column. Nevertheless, even though the shape of the data does not matter for computation, it does help us to reason about them.
Types of Information
A cell contains a single value, which generally may be a number or a text entry. This differentiation between data types is also important because the operations we can perform depend of those types. For instance, we can add and multiply numbers, but those operations are not directly meaningful for text values.
Spreadsheets blur the boundaries between types because eventually all information is visualized as text. It is important however for us to differentiate between the visual representation of a number, which is transformed first to text and then to pixels, from its actual information content.
Referential Indirection
Linking cells, using their columns letter and row number, as part of expressions, enables a notion of indirection, where we do not have to repeat or copy manually values, but retrieve them knowing the location they are stored. The idea of knowing, finding and using the index or offset between locations in storage is surprisingly very common. The concept of making a copy versus referencing a value from another location is also very critical to familiarize with, and spreadsheets offer a helpful mental paradigm you may always relate to.