# Word® vs. Mathematics

## Immutability and Mathematical Notation

Mathematical notation relies on immutability.

If you have immutability, you can replace patterns with impunity.

Note that I’m not describing *all* of mathematics, just the notation part^{1}.

## Search and Replace

The *notation* part of mathematics boils down to a simple set of principles

- find a pattern
- replace the pattern
- repeat.

### Word®

Word® does *search and replace*.

Can Word® do mathematical manipulation for us?

## Recursive Search and Replace

It is easier if your searcher-and-replacer works recursively.

REGEX is flat (non-recursive).

Parsers are recursive.

### PEG vs REGEX

PEG^{1} does recursive parsing and is “better” than REGEX in that regard.

## UNIX® Immutability

Immutability is, actually, *isolation*.

You can re-arrange things if you can guarantee that rearranging doesn’t cause unintended side-effects.

UNIX® provides *isolation*.

Using C, yet.

UNIX® commands are completely stand-alone. If you change the source for `cat.c`

, the operation of `sed.c`

doesn’t change.

UNIX® creates *isolation* at runtime by piping (isolated) commands together.

### What’s Inside?

Who cares what’s inside?

Do we care if a UNIX® command is written in C or in Haskell?

No.

We only care that the commands are isolated from each other. We can make the internals of the commands better, later.

Achieving isolation - immutability - at compile-time is just icing-on-the-cake (aka optimization).