2 ms·
I really like "minimalist" languages, and wrote about a few examples (and why Brainfuck is overly complicated) at http://chriswarbo.net/blog/2014-12-22-minimal_
by chriswarbo 5y ago
I really like "minimalist" languages, and wrote about a few examples (and why Brainfuck is overly complicated) at http://chriswarbo.net/blog/2014-12-22-minimal_languages.html http://chriswarbo.net/blog/2014-12-22-minimal_languages.html
My favourite language is SK (combinatory logic), which is both tiny (two symbols + parentheses; one rewrite rule each) and reasonably sane (unlike, say, Iota). It's also useful, since it's basically just function definition and application, which is applicable to pretty much every "proper" programming language. Hence the 'puzzle solving' we do in SK can give real insights into day-to-day understanding of programming. For example, to make an if/then/else branch in SK we end up using Church encoding, which was quite enlightening to me.
In particular, I always thought of booleans as bits: a fundamental component of our computers; and of languages "sitting above" those bits, controlling them (and, in turn, being controlled by them; since programs are stored as bits, and we can write self-modifying code). From that perspective, the idea of representing booleans as functions seems backwards.
However, I found it intriguing to go down this "backwards" rabbit-hole: if Church-booleans are functions/programs that make a choice, then a bit is also a program that makes a choice. Passing around bits, in a language like C, is just like passing around higher-order functions in a language like SK (or lambda calculus, or whatever). The main difference is that booleans/bits aren't "native": we can't call them directly. They must be interpreted, and the interpreter is called 'if/then/else'.
On the topic of Church-booleans, it can be similarly enlightening to see how Smalltalk implements branching using polymorphism, with a 'True' class and a 'False' class which override the 'ifTrue:ifFalse:' method of the 'Boolean' class in different ways. After a little pondering, we realise that those method definitions are the Church-booleans; and hence polymorphism/dynamic-dispatch is a higher-order function call. Then we find that objects are a poor man's closures, and that closures are a poor man's object. The deeper we go, the more blurred our once-crisp distinctions become, the more of our unconscious assumptions fall away, until everything can be twisted into anything else, and it all becomes a matter of perspective.
None of these perspectives are "more correct" than any other, although some are certainly more consistent and practical than others. Hence playing with esoteric/minimalist languages can force us to learn unfamiliar mechanisms, and learn new uses for familiar mechanisms. This can give us more flexibility and insight when approaching real-world challenges, where a shift in perspective might turn an unsolvable/incompatible mess into a straightforward solution.
- Qem 5y agoBy the way, regarding Smalltalk: https://news.ycombinator.com/item?id=27261379 https://news.ycombinator.com/item?id=27261379