On compositionality (2017)
julesh.com
julesh.com
The woman is pretty.
But if you wanted to nest the statment "pretty woman" you would "encode" it by switching to Japanese like so: The kirei onna is nice.
This example is absurd, but how is it any different than HTTP's ad-hoc approach to nesting, really? The HTTP approach quickly bogs down, while formats with high compositionality like JSON or YAML can be extended even to very complex structures; for example, the docker-compose.yml file or package.json.Well, it's complicated. Quoting Gerald Sussman from https://wingolog.org/archives/2018/01/11/spectre-and-the-end...
> The work of engineers used to be about taking small parts that they understood entirely and using simple techniques to compose them into larger things that do what they want.
> But programming now isn't so much like that. Nowadays you muck around with incomprehensible or nonexistent man pages for software you don't know who wrote. You have to do basic science on your libraries to see how they work, trying out different inputs and seeing how the code reacts. This is a fundamentally different job.
Thinking about it some more, I think that emergence is not something to be avoided, but embraced. Emergence is what gives rise to abstractions. Embracing abstractions is the reason we need compositionality -- the ability to translate from one level of abstraction to another, and glue together different abstractions/pieces [2]. If you didn't have emergent behavior, and all your pieces have the same level of abstraction, then there's not much structure to be exploited in how you combine them.
Concretely, think of emergence as the reason why a function can become an atomic unit in a new effective description, even though it is composed of other units (statements/functions).
[1] http://robotics.cs.tamu.edu/dshell/cs689/papers/anderson72mo...
[2] John Hughes demonstrates how higher order functions and lazy evaluation are useful tools to glue together pieces, in "Why functional programming matters" -- https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.p...
On the coding side I think abstraction has pros/cons. Yes it is nice to just use a module without really needing to peek behind the scenes, but there is an elegant way to abstract things (think of Linux commands as simple compiled applications that absorb and emit text that can be chained together with pipes versus the nodeJS leftpad fiasco. The latter showed that a lot of packages were just hacked together in a web. Again, contrast the original Smalltalk implementation of IDE, compiler, word processor, games, graphics, audio, networking...etc, that had a good bit of what Windows can do in 10k loc versus Windows which has an order of magnitude of additional code in just Microsoft Word alone. Clearly we've been abusing abstraction as these systems are beyond anyone's understanding when that doesn't need to be so. Chuck Moore of FORTH fame has a great interview where he points out that an OS is a non-thing that shouldn't be as critical as it is. I don't think he is 100% right, but he is onto something.
> More generally, I claim that the opposite of compositionality is emergent effects. The common definition of emergence is a system being ‘more than the sum of its parts’, and so it is easy to see that such a system cannot be understood only in terms of its parts, i.e. it is not compositional.
For example it's easy to compose two functions of type a -> b and b -> c but two functions of type MonadX m => a -> m b and MonadY m => b -> m c suddenly require you to weave together something that provides the full context.
And obviously in practice the tangle of constraints can be more complex... especially with (even common and useful) complications like MultiParamTypeClasses.
Not sure why this is sinking so fast.