Composition
Table of Contents
Zach Tellman - Always Be Composing: https://youtu.be/3oQTSP4FngY?t=192
- execute immediately, no downstream composition
- upstream composition only with other macros
https://youtu.be/3oQTSP4FngY?t=286
Function (Programming) can be composed downstream. i.e. its composition can be deferes and invoked later.
But functions are:
- completely opaque (we can call them but we cannot look inside them)
- mostly untestable
Data:
- are transparent
- compose easily
1. Conclusion
Data > Functions > Macros
In terms of generality, but
Macros > Functions > Data
In terms of Execution
2. Regular Expression
May be most popular Domain Specific Language in computer science.
- composable only through string concatenation
- opaque (i.e. their inner mechanism is not exposed. though its simply finite state automaton)
Implementing a library that is composable would use
Data: [(? 1) (* 3) (+ 3)]
like this to represent regex. but then it is not execuatable. It is not compiled beforhand like a standard regex like
Macro: #"1?2*3+"
So, for small problems at hand macro regex are good. And where the problem is complex and composition helps an redirection with using data then compiling and executing would be benefitial. (e.g. like in HTTP routing)
3. Composable Tools
Tools I use that compose with each other to satisfy my workflows:
- rclone
- syncthing
- org-mode and org-roam
- gpg encryption in emacs
- recoll
- dash/zeal docset