As programmers learned their craft from practice and immediate engagement with their material, computer science was concomittantly developing from a seemingly more abstract discipline. Mathematicians such as Alan Turing, John Von Neumann and Grace Hopper can be seen, not just as the foreparents of the discipline of computing, but also as standing on the shoulders of a long tradition of mathematicians. Computation is one of the many branches of contemporary mathematics and, as it turns out, this discipline also has reccuringly included references to aesthetics. After the metaphors of literature and the patterned structures of architecture, we conclude our analysis of the aesthetic relation of domains contingent to source code by looking at how mathematics integrate formal presentation.

This section approaches the topic of aesthetics and mathematics in three different steps. First, we look at the objective or status of beauty in mathematics: are mathematical objects eliciting an aesthetic experience in and of themselves, or do they rely on the observer's perception? Considering the difference between abstract objects and their representation: is aesthetic representation ascribed to either, or to both? And what is the place of the observer in this judgment? Having established a particular focus on the representations of abstract objects, we then turn to the epistemic value of aesthetics, and how positive aesthetic representations in mathematics can enable insight and understanding. Finally, we complement this relation between knowledge and presentation and depart from the ends of a proof, and an evaluative appraisal of aesthetics in mathematics, by investigating the actual process of doing mathematics, concluding with topics of pedagogy and ethics.

The object of mathematics is to deal first and foremost with abstract entities, such as the circle, the number zero or the derivative, which can find their applications in fields like engineering, physics or computer science. Because of this historical separation from the practical world through the use and development of symbols, one of the dominant discourses in the field tended to consider mathematical beauty as something intrisic to itself, and independent from time, culture, observer, or representation itself. Indeed, a circle remains a circle in any culture, and its aesthetic properties—uniformity, symmetry—do not, at first glance, seem to be changing across time or space.

According to the Western tradition, mathematics are perhaps the first art. Aristotle, in his Metaphysics , wrote of beauty and mathematics as the former being most purely represented by the latter, through properties such as order, symmetry and definiteness^{153}
. By offering insight into the harmonious arrangement of parts, it was thought that mathematics could, through beauty, provide knowledge of the nature of things, resulting in an understanding of how things generally fit together. Beauty then naturally emerges from mathematics, and mathematics can, in turn, provide an example of beauty. At this intersection, it also becomes a source of intellectual pleasure, since gaining mathematical knowledge exercises the human being's best power—that of the mind.

Arguing for this position of objective quality being revealed through beautiful manifestation, Godfrey H. Hardy writes, in his Mathematician's Apology , that beauty is constitutive of the objects that compose the field; their abstract quality is what removes them from the contextuality of human judgment.

A mathematician, like a painter or a poet, is a maker of patterns. If his patterns are more permanent than theirs, it is because they are made with ideas . A painter makes patterns with shapes and colours, a poet with words. The mathematician's patterns, like the painter's or the poet's must be beautiful ; the ideas like the colours or the words, must fit together in a harmonious way. Beauty is the first test: there is no permanent place for ugly mathematics. ( Hardy, 2012)A Mathematician’s Apology by G. H. Hardy, 2012.

Here, Hartman posits that it is the arrangement of ideas that possess aesthetic value, and not the arrangement of the representation of ideas. In this, he follows the position of other influential mathematicians, such as Poincaré (
Poincaré, 1908)

Science et méthode by Henri Poincaré, 1908.

, or Dirac (
Kragh, 2002)
Paul Dirac: Seeking beauty by Helge Kragh, 2002.

, who rely on beauty as a property of the mathematical object in itself. For instance, Dirac states that a physical law must necessarily stem from a beautiful mathematical theory, thus asserting that the epistemic content of the theory and its aesthetic judgment thereof are inseparable; a good mathematical theory is therefore intrinsically beautiful. Summing up these positions, Carlo Cellucci establishes proportion, order, symmetry, definiteness, harmony, unexpectedness, inevitablity, economy, simplicity, specificity, and integrations as the different properties inherent to mathematical objects, as mentioned from an essentialist perspective (
Cellucci, 2015)
Mathematical Beauty, Understanding, and Discovery by Carlo Cellucci, 2015.

. Ironically, this rather seems to hint at the multiplicity of appreciations of beauty within mathematics, with mathematicians concurring on the existence of beauty, but not agreeing on what kind of beauty pertains to mathematics. Nonetheless, they do agree that beauty is connected to understanding and epistemic acquisition. John Von Neumann, writing in 1947, states that:One expects a mathematical theorem or a mathematical theory not only to describe and to classify in a simple and elegant way numerous and a priori disparate special cases. One also expects "'elegance" in its "architectural," structural makeup. Ease in stating the problem, great difficulty in getting hold of it and in all attempts at approaching it, then again some very surprising twist by which the approach, or some part of the approach, becomes easy, etc ( Von Neumann, 1947)The Mathematician by John Von Neumann, 1947.

The point that Von Neuman makes here is a difference between the content of the mathematical object and its structural form. Such a structural form, by organizing the connection of separate parts into a meaningful whole, makes it easy to grasp the problem. In this sense, it is both the crux of aesthetics and the crux of understanding.

Similarly, François Le Lionnais, a founding member of the Oulipo literary movement in postwar France, wrote an essay on the aesthetic of mathematics, paying attention to both the mathematical objects in and of themselves, such as e or π, but also to mathematical methods, and how they compare to traditional artistic domains such as classicism or romanticism. Without getting into the intricacies of this argumentation, we can nonetheless note that his descriptions of mathematical beauty find echoes in source code beauty. For instance, his appraisal of the proof by recurrence^{154}
reflects similar lines of praise given by programmers to the elegance of recursive functions, which are sharing the same mathematical device (for instance, see
and
for examples of recursion as an aesthetic property). A proof by recurrence is indeed a kind of structure, which can be adapted to demonstrate different kinds of mathematical objects.

recursion_iteration_csharp

```
public static void recursiveQsort(int[] arr,Integer start, Integer end) {
if (end - start < 2) return; //stop clause
int p = start + ((end-start)/2);
p = partition(arr,p,start,end);
recursiveQsort(arr, start, p);
recursiveQsort(arr, p+1, end);
}
public static void iterativeQsort(int[] arr) {
Stack<Integer> stack = new Stack<Integer>();
stack.push(0);
stack.push(arr.length);
while (!stack.isEmpty()) {
int end = stack.pop();
int start = stack.pop();
if (end - start < 2) continue;
int p = start + ((end-start)/2);
p = partition(arr,p,start,end);
stack.push(p+1);
stack.push(end);
stack.push(start);
stack.push(p);
}
}
```

- The comparison two functions, one using recursion, the other one using iteration, intends to show the computational superiority of recursion. .
(
amit, 2012)

Answer to "Quicksort: Iterative or Recursive" by amit, 2012.

scheme_interpreter

```
(define (eval-expr env)
(lambda (expr env)
pmatch expr
[,x (guard (symbol? x))
(env x)]
[(lambda (,x) ,body)
(lambda (arg)
(eval-expr body (lambda (y)
(if (eq? x y)
arg
(env y)))))]
[(,rator ,rand)
((eval-expr rator env)
(eval-expr rand env))]))
```

- Scheme interpreter written in Scheme, revealing the power and self-reference of the language.

To understand is to grasp how each elements fits with others within a greater structure (either in a poem, a symphony or a theorem), with some or all of these elements being rendered sensible to the observer (
Cellucci, 2015)
) demonstrates the relation between geometry, algebra and numerical analysis through a restrained set of syntactic symbols, where e is Euler's number, the base of natural logarithms, i is the imaginary unit, which by definition satisfies i^{2}=-1, and π is the ratio of the circumference of a circle to its diameter. Each of the symbols is necessary, definite, and establishes clear relations between each other, revealing a deep interlock of simplicity within complexity.

Mathematical Beauty, Understanding, and Discovery by Carlo Cellucci, 2015.

. The beauty of a mathematical object can then be ascribed in its display of the definite relation between its elements. For instance, the equation representing Euler's identity (see
euler

euler

There is also empirical grounding for such a statement. This equation ranked first in a column in the Mathematician Intelligencer about the beauty of mathematical objects; the columnist, David Wells, had asked readers to rank given theorems, on a linear scale from 0 to 10, according to how beautiful they were considered (
Wells, 1990)
^{155}
. Again, while this assessment does show that there can be consensus, and thus some aspect of objectivity, in a mathematician's judgment of beauty in a mathematical object, it also showed that mathematical beauty also depends on the observer, since mathematicians provided varying accounts.

Are these the most beautiful? by David Wells, 1990.

Rather than focusing on the beauty of the mathematical entities themselves, then, another perspective is to consider beauty to be found in the representation of mathematical , since conceptual entities can only graspable through their manifestation.

A first approach is to consider that that the beauty ascribed to mathematics and the beauty ascribed to mathematical representation are unrelated. This disjunctive view, that aesthetics and mathematics can be decoupled (e.g. there can be ugly proofs of insightful theorems, and elegant proofs of boring theorems), was first touched upon by Kant. As Starikova highlights, the philosopher operates a distinction between perceptual, disinterested beauty, and intellectual, vested beauty. Perceptual beauty, the one which can be found in the visual representations of mathematical entities, is the only beauty graspable, while intellectual beauty, that of the objects themselves, simply does not exist, "mathematics by itself being nothing but rules" (
Starikova, 2018)

Aesthetic Preferences in Mathematics: A Case Study by Irina Starikova, 2018.

.Such manifestation of perceptual beauty, connected to mathematical entities themselves, can nonetheless be found in the phenomenon of re-proving in existing proofs, in order to make them more beautiful. Rota, for instance, associates the beauty of a piece of mathematics with the shortness of its proof, as well as with the knowledge of the existence of other, clumsier proofs^{156}
(
Rota, 1997)

The Phenomenology of Mathematical Beauty by Gian-Carlo Rota, 1997. [link]

. Thus, it is not so much the content of the proof itself, nor the abstract mathematical object being proven that is the focus of aesthetic attention, but rather the process of establishing the epistemic validity of such an object.What is useful here is technique, the demonstration of the knowledge from the prover to the observer, through the proof. As such, the asssessment of aesthetics in mathematics, both as a producer and as an observer, depends on the expertise of each individual, and on the previous knowledge that this indivual has of mathematics^{157}
(an assessment of the aesthetics of mathematics for non-expert is discussed in
Aesthetics as heuristics
below). It seems that the way that the mathematical object is presented does matter for the assessment.

If beauty is not intrinsic to the mathematical object, but rather connected to the representation of the mathematician's knowledge, there remains the question of why is beauty taken into account in the doing of mathematics. Looking at the lexical fields used by mathematicians to qualify their aesthetic experience, as reported in (
Inglis, 2015)

Beauty is Not Simplicity: An Analysis of Mathematicians’ Proof Appraisals by Matthew Inglis, Andrew Aberdein, 2015.

provides us with a clue: amongst the most used terms are "ingenious", "striking", "inspired", "creative", "beautiful", "profound" and "elegant". Some of these terms have a connection to the epistemic: for instance, something ingenious enables previously unseen connections between concepts, implying the resourcefulness and the cleverness of the originator of the idea. The next question is therefore that of the relationship between the aesthetic and the epistemic in mathematics; and in how this relation can manifest itself in source code.Caroline Jullien offers an alternative to the perception of mathematics as an autotelic aesthetic object, by retracing the definitions of beauty given by Aristotle and establishing a cognitive connection through a cross-reading of the Metaphysics and the Poetics , highlighting that " the characteristics of beauty are thus useful properties that yield an optimal perception of the object they apply to. [...] Men can understand what is ordered, measured and delineated far better than what is chaotic, without clear boundaries, etc. " (
Jullien, 2012)

From the Languages of Art to Mathematical Languages, and back again by Caroline Jullien, 2012.

. She then develops this point further, building on Poincaré's assessment of mathematical entities which fulfill aesthetic requirements and are, at the same time, an assistance towards understanding the whole of the mathematical object presented. Aesthetics, then, might not exist exclusively as intrinsic properties of a mathematical object, but rather as an epistemic device.Her argument focuses on considering mathematics as a language of art in the Goodmanian sense of the term, investigating how mathematical notation relates to Goodman's criteria of syntactic density, semantic repleteness, semantic density, exemplification and multiple references (
Jullien, 2012)

From the Languages of Art to Mathematical Languages, and back again by Caroline Jullien, 2012.

. She shows that, while mathematical notation might not seem to satisfy all criteria (for instance, syntactic density is only fulfilled if one takes into account graphical representations), a mathematical reasoning can present symptoms of the aesthetic, particularly through the ability to exemplify and refer to abstract entities.However, to do that, she also includes different representations of mathematical systems, beyond typographical characters. Taking into account diagrams and graphs, it becomes easier to see how a more traditionally artistic representation of mathematics is possible. The thickness of a line, the color-coding or the spatial relationship can all express a particular class of mathematical objects; for instance, the commutative property in arithmetic can be represented in geometry through the aesthetic property of symmetry. In this work, we focus on the textual representation of source code, eluding any graph or diagram (such as the one we've seen in architectural descriptions of software systems in
). Nonetheless, we have argued in
Aesthetics and cognition
that source code qualifies as a language of art: while the syntactic repleteness does not match that of, say, painting, the unlimited typographical combinations, paired with the artificial design of programming languages as working medium enables the kinds of subtle distinctions necessary for symptoms of the aesthetic to be present.

uml

Following Jullien, if a piece of mathematics is eliciting an aesthetic experience, or presenting positive aesthetic properties, it might then be a support for the understanding by the viewer of this very piece of mathematics. Such a support is itself manifested in this ability to show a harmonious correspondence of parts in relation to a whole. A beautiful presentation is a cognitively encouraging presentation. The subsequent question then regards the nature of that understanding: if it does not happen as an instant stroke of enlightenment, how does it take place as a gradual process of deciphering (
Rota, 1997)

The Phenomenology of Mathematical Beauty by Gian-Carlo Rota, 1997. [link]

?Addressing this question, Carlo Celluci hints at the concept of fitness, meaning the appropriateness of a symbol in its denotation of a concept, and the appropriateness of concepts in their demonstration of a theorem. Only through this dual level can fitness enable understanding rather than explanation (
Cellucci, 2015)

Mathematical Beauty, Understanding, and Discovery by Carlo Cellucci, 2015.

. This gradual conception of understanding fits the context of proofs and demonstration; when confronted with source code—that is, with the result of a thought process of one or more programmers—the processual conception of understanding seems to find its limits.To illustrate the relation between presentation and understanding of defined conceptual entities, we can look at how the linked list, a data structure that is fundamental in computer science, can be represented in an elegant way. The linked list allows for the retrieval and manipulation of connected items, as well as for the re-arrangement of the list itself, and thus holds within it thoughtful implications in terms of organizing and accessing sequential data. To do so, each item on the list contains both its value, and the address of the next item on the list, except for the last item, which points to null
; a last component, the head
points to the current element of the list. A graphical representation is provided in
.

linked-list

linked-list

The linked list implementation shown in
establishes a source code representation of such data structure. This comparison between a graphical representation and a textual one highlights that the graphical representation is not only artistic in the traditional sense of the term, but rather that it operates different expressive choices, and calls for attention on different parts of the same concept (e.g. the head
of the list). On the other side, the textual representation also makes attentional choices, but to different aspects (here, the structure of the list_item
); in this case, it seems less explanatory than the graphical representation, and limited in communicating why this is a canonical example of such a computational entity, or how did one reach this conclusion among other possible entities. The preference of graphical demosntrations over textual ones might indeed rely on the fact that our visual perception is the most developed of our system, and that our reasoning takes place through the manipulation of visual cues (
Wallen, 1990)

linked_list

```
struct list_item {
int value;
struct list_item *next;
};
typedef struct list_item list_item;
struct list {
struct list_item *head;
};
typedef struct list list;
size_t size(list *l);
void insert_before(list *l, list_item *before, list_item *item);
```

- A textbook example of a fundamental construct in computer science, the linked list. This header file shows all the parts which compose the concept. This program text does not do anything by itself, it only describes a certain data structure in a certain way. .
(
Kirchner, 2022)

Linked List by M Kirchner, 2022. [link]

On Form, Formalism and Equivalence by Lincoln A. Wallen, 1990.

.linked_list

```
struct list_item {
int value;
struct list_item *next;
};
typedef struct list_item list_item;
struct list {
struct list_item *head;
};
typedef struct list list;
size_t size(list *l);
void insert_before(list *l, list_item *before, list_item *item);
```

- A textbook example of a fundamental construct in computer science, the linked list. This header file shows all the parts which compose the concept. This program text does not do anything by itself, it only describes a certain data structure in a certain way. .
(
Kirchner, 2022)

Linked List by M Kirchner, 2022. [link]

Looking at
, one can view the different relationships between parts and wholes: the list item composing the list itself, the head pointer being a specific instance of the next pointer, and the different methods to access or modify the list itself. Seeing all of these together suggest an understanding of the whole through the parts which is nowhere explicitly described but everywhere suggested. On the contrary, the diagram provided in
provides a much more immediate understanding of how the linked list is structured. As such, its aesthetic properties (spacing, weight, color) contribute to highlighting the smae parts as defined in
- A textbook example of a fundamental construct in computer science, the linked list. This header file shows all the parts which compose the concept. This program text does not do anything by itself, it only describes a certain data structure in a certain way. .
(
Kirchner, 2022)
.

linked_list

```
struct list_item {
int value;
struct list_item *next;
};
typedef struct list_item list_item;
struct list {
struct list_item *head;
};
typedef struct list list;
size_t size(list *l);
void insert_before(list *l, list_item *before, list_item *item);
```

- A textbook example of a fundamental construct in computer science, the linked list. This header file shows all the parts which compose the concept. This program text does not do anything by itself, it only describes a certain data structure in a certain way. .
(
Kirchner, 2022)

Linked List by M Kirchner, 2022. [link]

linked-list

linked_list

```
struct list_item {
int value;
struct list_item *next;
};
typedef struct list_item list_item;
struct list {
struct list_item *head;
};
typedef struct list list;
size_t size(list *l);
void insert_before(list *l, list_item *before, list_item *item);
```

Linked List by M Kirchner, 2022. [link]

Rather than in the static description of the structure, we can look at the operations which can be performed on it in order to suggest implicit qualities of the object at hand. The linked list example (see
- A textbook example of a fundamental construct in computer science, the linked list. This header file shows all the parts which compose the concept. This program text does not do anything by itself, it only describes a certain data structure in a certain way. .
(
Kirchner, 2022)
) might be considered aesthetically pleasing only at a particular level of skill. However, once we start manipulate the concept, we can grasp its underlying properties. In
, we have reproduced two functions which perform the same operation: given a list and an element, they remove the element from the list.

linked_list

```
struct list_item {
int value;
struct list_item *next;
};
typedef struct list_item list_item;
struct list {
struct list_item *head;
};
typedef struct list list;
size_t size(list *l);
void insert_before(list *l, list_item *before, list_item *item);
```

Linked List by M Kirchner, 2022. [link]

linked_list_remove

```
void remove_cs101(list *l, list_item *target)
{
list_item *cur = l->head, *prev = NULL;
while (cur != target)
{
prev = cur;
cur = cur->next;
}
if (prev)
prev->next = cur->next;
else
l->head = cur->next;
}
void remove_elegant(list *l, list_item *target)
{
list_item **p = &l->head;
while (*p != target)
p = &(*p)->next;
*p = target->next;
}
```

- A comparison of how to remove an element from a list, with elegance depending on the skill level of the author . You are not expected to understand this.
(
Kirchner, 2022)

Linked List - Removing by M Kirchner, 2022. [link]

The distinction is made clear via the function names between a beginner level ( remove_cs101
, labelled "CS101" for the course number of introduction to computer science) and an expert level ( remove_elegant
). In the first one, we see two main statements, while
and if
. The first statment looks for the element to be removed by looping over the list. Once it has found it, it hands it over the next statement, which checks for the particular edge case where the target element might be the first one, which needs to be handled differently than for all other cases. In this case, the representation of this operation does not quite reach into the generic.

The second function is more complex, yet more enlightening. In order to get rid of the particular edge case which does not symbolize the universality of such a procedure, the author^{158}
makes a heavy use of the pointer notation, which allows a program to refer to either the content of a variable, or to the address at which the content is stored.

This use of pointers implies a change in the mental model when considering a linked list. While the first implementation operates on list_item
elements, and then individually deals with the sub parts (such as the next
field), the second implementation considers the list mostly as a series of pointers, thus reducing the conceptual overload, and increasing the functional efficiency at the price of initially more cryptic notation. Indeed, the indirection taking place through the use of pointers and references can only be grasped by non-beginners.

linked_list_remove

```
void remove_cs101(list *l, list_item *target)
{
list_item *cur = l->head, *prev = NULL;
while (cur != target)
{
prev = cur;
cur = cur->next;
}
if (prev)
prev->next = cur->next;
else
l->head = cur->next;
}
void remove_elegant(list *l, list_item *target)
{
list_item **p = &l->head;
while (*p != target)
p = &(*p)->next;
*p = target->next;
}
```

- A comparison of how to remove an element from a list, with elegance depending on the skill level of the author . You are not expected to understand this.
(
Kirchner, 2022)

Linked List - Removing by M Kirchner, 2022. [link]

Subtle notational changes can therefore flip the representation of a conceptual entity. Rather than being separated from purpose (in the case of mathematics, that function being proving a theorem), aesthetics are integrated into it by facilitating the understanding of the connection between, and the reasoning for mental or computational operations. For instance, writing about elegant mathematical proofs, John Barker argues that aesthetics are involved in implicit understanding:

Grasping a proof, understanding its gist, seeing why it works, is an important further step, and an essential step if one is to become a competent mathematician. However, by simply following each move in a proof, one has learned everything that is explicitly stated in the proof. Therefore, in really understanding a proof, one must be learning something that is not explicitly stated in it. ( Barker, 2009)Mathematical beauty by John Barker, 2009.

Still, whether an aesthetic judgment relies on perceived qualities, or if it only relies on the quality of an idea, is still up for debate. For instance, Starikova that " [A]lthough visual representations are involved and understanding does rely on them, it is clearly non-perceptual beauty that initiates aesthetic judgment " (
Starikova, 2018)

Aesthetic Preferences in Mathematics: A Case Study by Irina Starikova, 2018.

, pointing back to the distinction above as to whether beauty is perceived as intrinsic to the mathematical object, or intrinsic to its representation.Here, we argue that, when it comes to source code, adequate representation of the idea is necessary in order to elicit an aesthetic experience, following our conception of understanding through an embodied lens. However, aesthetic judgments also depend on the nature of background knowledge that the reader holds when engaging with a program text. As we saw in
, a beginner might appreciate the conceptual beauty of the linked list, while an expert might appreciate the beautiful representation of the linked list.

linked_list_remove

```
void remove_cs101(list *l, list_item *target)
{
list_item *cur = l->head, *prev = NULL;
while (cur != target)
{
prev = cur;
cur = cur->next;
}
if (prev)
prev->next = cur->next;
else
l->head = cur->next;
}
void remove_elegant(list *l, list_item *target)
{
list_item **p = &l->head;
while (*p != target)
p = &(*p)->next;
*p = target->next;
}
```

- A comparison of how to remove an element from a list, with elegance depending on the skill level of the author . You are not expected to understand this.
(
Kirchner, 2022)

Linked List - Removing by M Kirchner, 2022. [link]

On one side, the lack of pre-existing knowledge involves the deciphering of symbols and thus immediate attention to form. On the other side, the pre-existence of knowledge allows one to focus on the quality and details of the presentation, such as when mathematicians decide to find more beautiful proofs to an existing theorem. In this case, the knowledge of the theorem, and how its intellectually-perceived simplicity can be translated into a sensually-perceived simplicity and an aesthetic judgment on the form. Here, the aesthetic judgment precedes the intellectual judgment, all the while not guaranteeing a positive intellectual judgment (e.g. the abstract object, whether program function or mathematical theorem, is presented in an aestheticlly-pleasing manner, but remains shallow, boring, non-sensical or wrong).

We argue here that both intellectual pleasure and aesthetic pleasure happen in a dialogic fashion, considering the symbols and the meanings reciprocally, until intellectual and aesthetic judgments have been given. This is in line with Rota's critique of the term "enlightenment" or "insight" in his phenomenological account of beauty in mathematics. The process of discovery and understanding is a much longer one than a simple stroke of genius experienced by the receiver (
Rota, 1997)

The Phenomenology of Mathematical Beauty by Gian-Carlo Rota, 1997. [link]

.An aesthetic experience in mathematics involves uncovering the connections between aesthetic and epistemic value being represented through a mathematical symbol system. However, such a conception seems to take place as a gradual process of discovery, both from the writer and from the reader, rather than intrinsic aesthetic value existing in a given mathematical concept. Seen in the light of skill-based aesthetic judgment, this chronological unfolding points towards a final aspect of aesthetics in mathematics specifically, and in the sciences in general: aesthetics as heuristics for knowledge acquisition.

So far, we had been looking at how aesthetics are evaluated in a finished state—that is, once the form of the object (whether a proof or a program text) has stabilized. In doing so, we have left aside a significant aspect of the matter. Aesthetics in mathematics do not need to be seen exclusively as an end, but also as a mean, as a part of the cognitive process engaged to achieve a result. As such, we will see how they also serve as a useful heuristic, both from a personal and social perspectives. Since the ultimate purpose of mathematics specifically, and scientific activities in general, is the establishment of truths, one can only follow that beauty has but a secondary role to play—though that is not to say superfluous.

Complementing the opinions of mathematicians at the turn of the 20**nope! cmd**century, Nathalie Sinclair offers a typology of the multiple roles that beauty plays in mathematics. Beyond the one that we have investigated in the previous sections, which she calls the evaluative role of beauty, in determining the epistemic value of a conceptual object, she also proposes to look at a generative role and at a motivational role (
Sinclair, 2011)
^{159}
. According to Root-Bernstein, the informal insights of aesthetic intuition precede formal logic. Only when we explicitly recognize that the “tools of thinking” and the “tools of communication” are distinct can we understand the intimate, yet tenuous, connection between thought and language, imagination and logic (
Root-Bernstein, 2002)

Aesthetic Considerations in Mathematics by Nathalie Sinclair, 2011.

. The latter helps the mathematician direct their attention to worthy problems—something which is of limited equivalence in source code, since programming mostly derives from external constraints. The former holds a guiding role during the inquiry itself, once the domain of inquiry has been chosen. It helps in generating new ideas and insights as one works through a problem. This aesthetic sense can be productive both in its positive evaluations—implying one might be treading a fruitful path—as well as negative—hinting that something might not be conceptually well-formed because it is not formally well-presentedAesthetic cognition by Robert S. Root-Bernstein, 2002.

.This is echoed in Norbert Wiener's perception of aesthetics in mathematics as a way to structure a knowledge that is still in the process of being formed, in order to optimize short-term memory as the mental model of the conceptual object being grasped is still being built^{160}
. This description of a sort of landmark item, in the geographical sense, echoes the role of beacons described by Détienne (
Detienne, 2001)
, One can therefore consider an aesthetically pleasing element to serve as a sort of beacon used by programmers to construct a mental representation of the program text they are reading or writing.

Software Design Cognitive Aspect by Francoise Detienne, 2001.

and mentioned in
The psychology of programming
A representation does not need to be of an effective proof in order to be nonetheless considered functional. A sketch of a concept might even evoke more in certain readers than a fully detailed implementation, offering a direction into which further fruitful inquiry.

For instance, the listing
shows such a sketch, as it represents the essential components of a regular expression matcher, as featured in the Beautiful Code edited volume. Regular expressions are a form of linguistic formal pattern that serve as an input to a regular expression matcher in order to find particular patterns of text in an input string. Given a input text file, a regular expression matcher could find a pattern such as " any consecutive list of characters, starting with any number of alphanumeric characters, followed by a dot, followed by at least one character and at most seven characters "—in essence a rough description of a file name and extension. Building such a system is not a trivial endeavour.

regex

```
/* match: search for regexp anywhere in text */
int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp + 1, text);
do
{ /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
return 0;
}
/* matchhere: search for regexp at beginning of text */
int matchhere(char *regexp, char *text)
{
if (regexp[0] == '\0')
return 1;
if (regexp[1] == '*')
return matchstar(regexp[0], regexp + 2, text);
if (regexp[0] == '$' && regexp[1] == '\0')
return *text == '\0';
if (*text != '\0' && (regexp[0] == '.' || regexp[0] == *text))
return matchhere(regexp + 1, text + 1);
return 0;
}
/* matchstar: search for c*regexp at beginning of text */
int matchstar(int c, char *regexp, char *text)
{
do
{ /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}
```

- A regular expression matcher by Rob Pike, praised for its elegance and conciseness, but not for its practical utility
(
UNKNOWN AUTHOR, 2007)

Beautiful Code: Leading Programmers Explain How They Think by Andy Oram, Greg Wilson, 2007.

In this case, the essential components of the matcher are implemented, in a clear and concise way. It highlights the overall structure (a general match
function, with matchhere
and matchstar
handling separate cases), the process of looping over an input string, the fundamentals of handling different patterns, and within those the fundamentals of handling different characters in relation to the current pattern. Each part is clearly delineated (and fit for its separate purposes) and contributes to an understanding of the whole, by limiting itself to displaying its essence.

regex

```
/* match: search for regexp anywhere in text */
int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp + 1, text);
do
{ /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
return 0;
}
/* matchhere: search for regexp at beginning of text */
int matchhere(char *regexp, char *text)
{
if (regexp[0] == '\0')
return 1;
if (regexp[1] == '*')
return matchstar(regexp[0], regexp + 2, text);
if (regexp[0] == '$' && regexp[1] == '\0')
return *text == '\0';
if (*text != '\0' && (regexp[0] == '.' || regexp[0] == *text))
return matchhere(regexp + 1, text + 1);
return 0;
}
/* matchstar: search for c*regexp at beginning of text */
int matchstar(int c, char *regexp, char *text)
{
do
{ /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}
```

- A regular expression matcher by Rob Pike, praised for its elegance and conciseness, but not for its practical utility
(
UNKNOWN AUTHOR, 2007)

Beautiful Code: Leading Programmers Explain How They Think by Andy Oram, Greg Wilson, 2007.

It must be pointed out here that the regular expression is functional at its core: in less than 50 lines, it performs the core operations of the system it represents, while a fully-functional implementation, such as the one in Python's re
module, is more than 2000 lines (
Secret Labs AB, 2001)
^{161}
.

_Parser.py by Secret Labs AB, 2001. [link]

. The beauty found by Brian Kernighan in this program text is that the core of the idea is represented elegantly, while leaving avenues for exploration to the readerMathematics, like source code, therefore pay close attention to how formal presentation facilitates the cognitive grasping of abstract concepts. Reducing and organizing literal tokens into conceptually coherent units, and meaningful relations to other units—for instance, having the code in
reversed, with the match()
function at the bottom of the document would represent a different level of importance of that entrypoint function, which would complicate the understanding of how the source code functions.

regex

```
/* match: search for regexp anywhere in text */
int match(char *regexp, char *text)
{
if (regexp[0] == '^')
return matchhere(regexp + 1, text);
do
{ /* must look even if string is empty */
if (matchhere(regexp, text))
return 1;
} while (*text++ != '\0');
return 0;
}
/* matchhere: search for regexp at beginning of text */
int matchhere(char *regexp, char *text)
{
if (regexp[0] == '\0')
return 1;
if (regexp[1] == '*')
return matchstar(regexp[0], regexp + 2, text);
if (regexp[0] == '$' && regexp[1] == '\0')
return *text == '\0';
if (*text != '\0' && (regexp[0] == '.' || regexp[0] == *text))
return matchhere(regexp + 1, text + 1);
return 0;
}
/* matchstar: search for c*regexp at beginning of text */
int matchstar(int c, char *regexp, char *text)
{
do
{ /* a * matches zero or more instances */
if (matchhere(regexp, text))
return 1;
} while (*text != '\0' && (*text++ == c || c == '.'));
return 0;
}
```

- A regular expression matcher by Rob Pike, praised for its elegance and conciseness, but not for its practical utility
(
UNKNOWN AUTHOR, 2007)

Beautiful Code: Leading Programmers Explain How They Think by Andy Oram, Greg Wilson, 2007.

One of the virtues of the listing is that it is particularly beneficial to students, helping them grasp the important parts without being overloaded with too many technical details. Nathalie Sinclair further develops the importance of aesthetically pleasing textual objects representing mathematical concepts in order to facilitate learning. She positions her argument as a response to the strict focus of the studies in mathematics on the perceptions and reports of highly successful individuals. If individuals like Poincaré, Hardy and Dirac can self-report their experiences, she inquiries into the ability for individuals of a different skill level to experience generative aesthetic experiences, experiences where the encountering of an aesthetic symptom generates new directions for ideas. In a subsequent work, she describes the perception of mathematics students as such:

The aesthetic capacity of the student relates to her sensibility in combining information and imagination when making purposeful decisions, regarding meaning and pleasure. ( Sinclair, 2011)Aesthetic Considerations in Mathematics by Nathalie Sinclair, 2011.

Emotion and intellect are no longer antitheses, and can be reported by students as well. From her investigations, then, it seems that the heuristic value works across skill levels, whether one holds a Fields medal or a high-school degree. Doing similar work, Seymour Papert aimed at evaluating the functional role of aesthetics by documenting a group of non-experts working through a proof that the square root of 2 is an irrational number. After a series of transformative steps, the subjects of the study manged to eliminate the square root symbol by elevating the two other variables to the power of two^{162}
, as in
.

irrational-proof

irrational-proof

Papert conceptualizes such an observation as a phase of play, a phase of playing which is aesthetic insofar as the person doing mathematics is delimitating an area of exploration, qualitatively trying to fit things together, and seeking patterns that connect or integrate (
Papert, 1978)

The Mathematical Unconscious by Seymour A. Papert, 1978.

, and thus looking to identify parts which would seem to fit a yet-to-be-determined whole. This also seems to confirm the perspective that there are some structures that are meaningul to the mathematician.An interesting aspect of this conception of aesthetics by both Papert and Sinclair is their temporal component. While, for evaluative aesthetics, one can grasp the formal representation of the mathematical object in one sweep, this generative role hints at a more important need to develop over time. This opens up a new similarity with source code, by shifting from the reader to the writer. On one side, Sinclair connects this unfolding over time with Dewey's theory of inquiry and with Polanyi's personal knowledge theory, connecting further the psychological perception with the role of aesthetics. Both Dewey and Polanyi offer a conception of knowledge creation which relies particularly on a step-by step development rather than immediate enlightenment (
Polanyi, 1969
Sinclair, 2004)

Knowing and being; essays by Michael Polanyi, Marjorie Grene, 1969.

The Roles of the Aesthetic in Mathematical Inquiry by Nathalie Sinclair, 2004.

; it is precisely this distinction which Papert addresses with his comparison of aesthetics as gestalt (evaluative) or sequential (generative).Taking from Dewey's proposal of what an aesthetic experience is^{163}
, we can connect it back to a sequential aesthetic perception in Papert's term, one of learning and discovery, but also to the practice of writing good source code.

In programming practice, the process of working through the establishment of a valuable epistemic object through the sequential change of representations is called refactoring . As described by Martin Fowler, author of an eponymous book, refactoring consists in improving the textual design of an existing program text, while retaining an identical function. The crux of the process lies in applying a series of small syntactical transformations, each of which help to sharpen the fitness of the parts to which these transformations are applied. Ultimately, the cumulative effect of each of these syntactical transformations ends up being significant in terms of program comprehension, bringing it closer to a sense of elegance (
Fowler, 1999)
^{164}
.

Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts, Erich Gamma, 1999.

Finally, extending from this personal and psychological perspective on the development of epistemic value through the pursuit of aesthetic perceptions, we can note a final dimension to aesthetics in mathematics: a social component. Shifting our attention away from the modes of mathematical inquiry of individual mathematician, Sinclair and Primm have highlighted the practices of the community as a whole, including how truths are named, manipulated and negotiated. (
Sinclair, 2011)

Aesthetic Considerations in Mathematics by Nathalie Sinclair, 2011.

.This amounts to uncovering the fact that scientific problems are being decided upon and researched based on particular values and conventions, conventions which then trickle down into the presentation of results, highlighting trends and social formations both in terms of content of research and style of research (
Depaz, 2023)

Stylistique de la recherche linguistique en IA: De LISP à GPT-3 by Pierre Depaz, 2023.

. The interpretation provided by Pimm and Sinclair is that aesthetics, through "good taste" subtly reify a power relationship and exclude practitioners by delimiting what is proper writing and proper research (
Sinclair, 2010)
The Many and the Few: Mathematics, Democracy and the Aesthetic by N. Sinclair, David Pimm, 2010.

.While one could argue for a similar power dynamic when it comes to programming style, one notable difference we see with programming is the highly interactive collaborative environment in which the productive work can be done. Particularly in the case of software engineering, the fact that a given program text is being worked on by different individuals of different skill levels and at different moments also suggests a social function of aesthetics as a means to harmonize social processes. The evaluative posture of the reader in giving a positive value judgment on a given program text or mathematical proof also implies that this positive judgment was given as a generative role; that is, the aesthetic symptoms are made visible by a writer in search of elegant function and epistemic communication, and appreciated by the reader as an indicator of a work well-done (
Tomov, 2016)

The Role of Aesthetics in Software Design, Development and Education: Review and Definitions by Latchezar Tomov, 2016.

. This implies a certain sense of care that was being given to the program text, or to the mathematical proof, which in turn suggests a certain functional quality in the finished object. Beautiful mathematics, as beautiful code, can therefore be seen as a sign that someone cared for others to understand it clearly.-

Aesthetics are thus closely involved in considering mathematical objects, in appreciating their symbolic representation, and as a guide towards a positively-valued representation. Particularly, the dichotomy between the mathematical entities (theorems) and their representations (proofs) echoes the distinction we have seen in programming between algorithm and implementation. While abstract entities do possess specific qualities that are positively valued, it is their implementation—that is, their textual manifestation—which tends to be the locus of aesthetic judgment. Aesthetics also complement the more common notion of scientific rational thinking, in which an individual reasons about a problem in a linear, step-by-step manner. Instead, we have seen that the appearance, and the judgment of such appearance, also acts as a guide towards establishing true and elegant mathematical statements.

Ultimately, aesthetics in mathematics contribute to representing a mathematical object, thus enabling access to the conceptual nature and implications of this object, as well as providing useful heuristics in establishing a new object. What remains, and what will be taken up in the next chapter, is to " reify this meta-logic as a set of rules, axioms, or practices. " (
Root-Bernstein, 2002)

Aesthetic cognition by Robert S. Root-Bernstein, 2002.

, by establishing which mathematical approaches fit with source code aesthetics.- - -

In this chapter, we have established a more thorough connection between aesthetics and cognition. First at the philosophical level, we established how source code fits within Nelson Goodman's conception of what is a language of art, before complementing this ability for an aesthetic experience to communicate complex concepts with more contemporary research, including contribution from cognitive sciences.

We then moved to more specific domains, examining both how their aesthetic properties engage with cognition, but also how these might relate to those held by source code. Looking at literature, we paid attention to how metaphors, embodied cognition and spatial representations are all devices allowing for the evokation of complex world spaces and cultural references, facilitating the comprehension of (electronic) poetry and prose.

Turning to architecture, we acknowledged the role of function in the conception of modernist aesthetics, one which focuses on the plan rather than on the building, before contrasting this approach with the theories of Christopher Alexander. His concepts of patterns and habitability have been widely transposed in programming practice, highlighting a tension between top-down, abstract design, with bottom-up, hands-on engagement. This notion of direct material engagement led us to further examine how craft folds ties to architecture, and how it facilitates a particular kind of knowledge production and value judgment.

Finally, turning to mathematics, we distinguished two main approaches: an evaluative aesthetics, where the representation of a mathematical object has an epistemic function, and a generative aesthetics, which works as a heuristic from a writer's perspective, and often remains unseen to the reader, as it is presented in its final form, without the multiple steps of formal transformations that led to the result.

Throughout, we compared how these specific aesthetic approaches related to source code. Since source code is presented by programmers as existing along these domains of practice, this has allowed us to further refine a specific aesthetics of source code. The next chapter brings the concepts identified in these domains into a dialogue in order to constitute a coherent view. To do so, we will start from source code's material: programming languages.