Do you want to learn a new way to think? And a new way to write? Do you want to learn how to look at everything from a new perspective?
If so, read on.
I will try to explain to you how to "think in Parsers". I'll also then go into "writing with Parsers", a computer language we've made. It might not click immediately, but when it finally does I think you'll find it wonderfully useful.
No matter what topic you want to learn, from music to math, chemistry to carpentry, mechanics to quantum mechanics, thinking in parsers gives you another path to understanding any domain.
Look for a tree. (If you're inside, you may need to go to a window)
Did you see one? Great! That means you have a "TreeParser" in your brain that is capable of recognizing trees.
Now, look for a rock. See one? Great! You brain also has a "RockParser".
Parsers are things that match certain patterns and are inert to others.
Your TreeParser fired when you saw a tree, but not when you saw a rock, and vice versa.
The tree you looked at may have also activated another Parser specific to that species. I am writing this in Massachusetts and so for me that was my PineTreeParser. Usually I am in Hawai'i and my PalmTreeParser activates. For you it might be another kind. The point is parsers can be derivatives of other Parsers.
But that's not the only way Parsers can compose.
For example, you can also have Parsers that parse parts of a pattern. Think of a BranchParser or a LeafParser.
Parsers can combine in many ways.
Imagine taking a leaf from the tree and looking at it under a microscope. If you remember your biology class, your "CellParser" may activate. But if you were given a blurry image and not told its source, your "TurtleShellParser" may activate instead.
Because you have context you know which Parser is the one to use.
Imagine pulling the tree you saw out of the ground and into the sky. Now imagine throwing the rock into the sky.
I bet when you imagined lifting the tree, you imagined pulling up roots, but you didn't imagine roots attached to the rock.
You can attach knowledge to parsers that can be used in combination with the pattern that activated the parser.
The patterns that trees or rocks or turtles emit exist whether or not we have a parser that recognizes them. Patterns exist without parsers.
A baby starts with very few parsers and things for them are largely a blur until they have developed the parsers to make sense of their sensory data.
Often, especially when growing up, we see and record raw patterns that we don't fully understand. Eventually we stumble upon parsers that match those patterns and give us deeper understanding of what we witnessed earlier.
Sometimes we only notice a pattern after we've learned a parser for it. For example, if you've ever gotten a new car, you've probably experienced the phenomena of suddenly noticing that model of car all around you. This is because you have acquired more parsers for that pattern that are now getting activated when you encounter it.
And often the parsers we have don't actually best fit the universe's patterns and we update them later. The pattern of the earth revolving around the sun has existed always, for example, even though humans previously had parsers that parsed it in a different way.
Let's recap so far. Parsers:
So far we've been talking about Parsers for objects in the real world that are stored in the neural networks of your brain. These Parsers are neat, and you don't even have to be human to have them (dogs, for example have parsers to recognize their master) but Parsers work the same way in the symbolic world.
For example, you have an oParser that:
And then you can have a WordParser that recognizes words, such as "color".
You can then have a PropertyParser that recognizes a pair of words like "color blue".
Parsers never stop composing like this. If you were to look at the source code of this post you would even see that this sentence is parsed by a ParagraphParser.
It's Parsers all the way down! And all the way up!
One thing you'll notice about parsing objects is that all Parsers assume membranes. Whether it's the edges of the tree or the space around words, there are lines, either visible or invisible, that separate what is being parsed versus not parsed.
Now let's combine the sections above by making a language of symbolic parsers about things we encounter in the physical world.
First, we need to set some rules as to the membranes of our language - where do we draw the lines around the atomic units that we will parse? For this, we'll use Particle Syntax (aka Particles). Particles splits our writings into atoms (words), particles (lines), and subparticles (indented lines that belong to the "scope" of the parent line). The nice thing about Particles is that there is no visible syntax at all, and yet it gives us the building blocks to represent any kind of structure.
Now, imagine we wrote the lines below on a walk in the woods.
pineTree
height 20ft
circumference .5ft
pineTree
height 10ft
circumference .3ft
oakTree
height 30ft
circumference .8ft
Right now all we have is some patterns, but no parsers.
Let's write some parsers to parse the lines above:
abstractTreeParser
pattern *Tree
heightParser
atoms lengthAtom
circumferenceParser
atoms lengthAtom
calculateVolume
return height * surfaceArea
pineTree extends abstractTreeParser
oakTree extends abstractTreeParser
Now we have five parsers with which to understand our original program.
Of course, the parsers themselves also make use of various parsers (such as "pattern" and "atoms"), which I've left out, so in reality there would be quite a bit more.
I've left out some details to focus on the core ideas of how you can define Parsers symbolically that match patterns, are composable, context-sensitive, and hold logic.
You may notice that the Parsers language is not very much concerned with computers and fitting the world to match the structures in a computer. Although the parsers can carry logic to execute on computers, Parsers is really focused more on organizing knowledge into parsers. Parsers is a knowledge storage language first--a way to think first--and a computational language second. Parsers does not say "here is a set of structures that work well on the computer, fit your knowledge of the world into them." Instead the approach of Parsers is to "mine the minimal, ideal set of symbols to represent the patterns you see, and then we'll have the computer adjust to those".
Now, if you want to dive deeper into Parsers, an ever evolving language, the Scroll website is a good place to visit next.
But now let's keep going and connect the dots.
Now I'm going to get to the fun claim of this essay: every subject can be represented as a list of simple parsers in the Parsers language.
Parsers are the building blocks of knowledge, much like atoms are the building blocks of molecules.
It doesn't matter how "complex" the subject is, everything can be broken down (and built up) by simple parsers.
Now, don't get me wrong, I'm not saying quantum mechanics is the same thing as arithmetic. What I'm saying is that quantum mechanics is merely a larger list of parsers. Each parser in quantum mechanics is not more complex than the parsers in arithmetic, it's just that there are more of them.
If you are struggling to master a new subject, you can just start writing out all the parsers in the subject in a flat list. You can then work on your understanding of each one, refining your parser definition as you go. You'll find that before you can understand some parsers, you'll have to understand some other parsers it uses.
You can also organize parsers by which ones are used the most. (Often you'll find many parsers that are taught in books are not very important, and you'll start to pick up on the core set that are heavily used and should be mastered).
Eventually you'll have a long list of parsers that together describe a subject in a very accurate, precise, and computable way. It's like an encyclopedia but better, because the parsers are linked in ways that can be logically computed over.
This was a brief introduction to my primary mode of thinking: "thinking in parsers". I've personally found this a universally useful way to think about the world. The great thing about it is it works for both understanding objects in the 4D world and also for objects in the symbolic world (including 2D math).
When I was younger I was overwhelmed by the amount of symbolic knowledge we have in our world. Now that I'm able to think in parsers, I find it all far less intimidating, because I know it's just a big list of parsers, and I can take it one parser at a time.
I hope you find thinking in parsers as useful as I do.
From an OO perspective, think of Parsers as ClassDefinitions initialized with particles that always have methods for parsing subparticles. Like OO, parsed particles can have methods and state and communicate via message passing. But with Parsers the focus is on parsing and patterns.
From a functional programming perspective, you can think of Parsers as a function that takes pattern matching and other logic and returns functions that can parse patterns.
From a Lisp perspective, you can think of Parsers as like Racket with its "Language Oriented Programming", but with Particle syntax which compose better than S-Expressions.
From an XML perspective, think of Parsers as XML with a much slimmer syntax and a built-in language for defining schemas.
No. First, you can have Parsers like a PoemParser that are very loose in what they accept. Second, no matter what, symbols are a poor approximation to patterns in the physical world, and so it's better to optimize for efficiency in symbolic patterns over looseness.