Functional Programming Takeaways 2
Functional Programming
Functional programming breaks down into two actions:
- pattern matching
- text replacement & manipulation
Pattern Matching
Pattern matching is parsing.
Currently, the easiest parsing method is PEG.
My favorite variant of PEG is Ohm-JS.
Ohm-JS claims to simplify PEG parsing, through various complicated means (upper-case vs. lower-case rules).
The real gems in Ohm-JS are:
-
Separation of Concerns (grammar separated from semantics, unlike in other variants of PEG)
-
the Ohm-editor.
The Ohm-editor simplifies the act of building parsers.
If I were to use any other PEG library, I would use the Ohm-editor first.
Text Manipulation
Functional programming, and mathematical notation, imposes the restriction that there can be no side-effects.
In fact, this is only a subset of the more important idea of isolation.
You can allow mutation, and, you can build components that are arbitrarily complex, as long as the components are isolated.
Isolation
Isolation is more important than complexity.
Isolation is more important than immutability.
Scalability
Isolation provides scalability.
Black Boxes
Isolation means that you can treat Components as black boxes - input & outputs, we can’t care about what is inside.
Everything Is A Fractal
Everything is a fractal.
Everything can be further sub-divided.
That includes everything I write. Nothing I write is absolute, it is relative, and, it can be broken down.