On this page:
2.1.1 Exercises 1
2.1.1.1 Question 1
2.1.1.2 Question 2
2.1.1.3 Question 3

2.1 Programming Languages

For a computer to be able to solve a problem it is necessary to describe the process of solving the problem in a language that it understands. Unfortunately, the language that a computer “innately” understands is extremely poor, making the description of how to solve a non-trivial problem a very exhausting, tedious and complex task. The countless programming languages that have been invented aim at alleviating the programmer’s burden, by introducing linguistic elements capable of simplifying those descriptions. For example, the concepts of function, sum, matrix or rational number do not exist natively in computers but many programming languages allow their usage in order to simplify the description of scientific calculus. Naturally, this implies a process that transforms the programmer’s descriptions into instructions that computers can understand. This process is called compilation and although it is relatively complex, we only need to know that it allows us to use programming languages that are closer to the thinking capabilities of humans, than those of computers.

Compilation is of extreme importance because it allows us to use programming languages not only to instruct a computer on how to solve a problem, but also to explain that process accurately to another human being. In this way, much like mathematics, programming languages become a way of transmitting knowledge and, in fact, they are even more rigorous than mathematics.

There is a great diversity of programming languages, some better equipped than others to solve specific problems. This means that choosing a programming language should depend on the kind of problems we wish to solve, but it should not be a full commitment. For a programmer, it is much more important to understand the fundamentals and techniques of programming than to master one language or another. However, to better understand these fundamentals, it is convenient to exemplify them in a concrete programming language.

As this document will focus on programming for architecture, we will use a programming language that is geared towards solving geometrical problems. There are many languages that serve this purpose, most commonly associated with Computer Aided Design (CAD) or Building Information Modeling (BIM). ArchiCAD, for instance, offers a programming language called GDL, an acronym for Geometric Description Language that enables users to program multiple geometric forms. In the case of AutoCAD, the language used is called AutoLisp, a dialect of a famous programming language called Lisp. A third option is the RhinoScript language, available for Rhinoceros 3D. Despite these languages seeming very different from each other, the concepts behind them are very similar. These fundamental concepts of programming will be the main focus of our study. However, for pedagogical reasons, it is convenient to address them in a single language.

Unfortunately, GDL, AutoLisp, and RhinoScript were developed many years ago and they have not been updated, possessing many archaic characteristics that make them harder to learn and use. In order to ease the learning process while allowing our programs to run in different CAD environments, we are going to use a new language called Julia, which was purposely adapted for programming in architecture. Julia is freely available at https://julialang.org/. In this text we will explain the fundamentals of programming using Julia, not just because it is easier to learn, but also for its practical applicability. However, once learned, the reader should be able to apply these fundamentals to any other programming language.

In order to facilitate the programmer’s task, Julia can be used from a programming environment called Atom, which offers a text editor adapted to edit Julia’s programs, as well as a set of additional tools for error detection and debugging. This programming environment is shared with a freeware license and it is available at https://atom.io/.

2.1.1 Exercises 1
2.1.1.1 Question 1

Exponentiation \(b^n\)is an operation between two numbers \(b\) and \(n\). When \(n\) is a positive integer, exponentiation is defined as:

\[b^n = \underbrace{b \times b \times \cdots \times b}_n\]

To a reader not familiarized with exponentiation, the previous definition raises several questions that may not be evident: how many multiplications should actually be done? \(n\)?, \(n-1\)? What if \(n=1\)? Or \(n=0\)? Propose a definition for the exponentiation function that raises none of these questions.

2.1.1.2 Question 2

What is a program and what purpose does it serve?

2.1.1.3 Question 3

What is a programming language and what purpose does it serve?