Buffalo!

From Esolang
Jump to navigation Jump to search
Buffalo!
Paradigm(s) imperative, literate, pseudonatural, low-level, thematic
Designed by User:Ecatmur
Appeared in 2022
Type system untyped
Memory system Minsky machine
Dimensions one-dimensional
Computational class Turing complete tarpit
Reference implementation buffalo.py
Dialects Standard Buffalo!, Numeric Buffalo!
Influenced by Ook!
File extension(s) .Buffalo!

Supposedly, "Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo" is a grammatically correct sentence in English. Buffalo! takes that and runs with it.

Overview

Despite sharing a coincidence of letters, Buffalo! is not a Brainfuck derivative; instead it models an unbounded natural number register machine, with the following operations:

  • Intransitive imperative Buffalo!: increment the accumulator (implicit second person subject)
  • Transitive imperative (e.g. Buffalo buffalo!): swap the accumulator (implicit second person subject) with the object register (here "buffalo")
  • Intransitive indicative (e.g. Buffalo buffalo.): swap the program counter with the subject register (here "buffalo")
  • Transitive indicative (e.g. Buffalo buffalo Buffalo buffalo.): copy the subject register (here "buffalo" to the object register (here "Buffalo buffalo"), then decrement the subject register.

Buffalo! has branching through syntactic ambiguity: Buffalo buffalo buffalo. could either be in the intransitive indicative (exchange "Buffalo buffalo" with the accumulator) or in the transitive indicative (copy "buffalo" to "buffalo", then decrement it). The language selects between the possible interpretations dependent on the value of the accumulator (it's fully deterministic).

Buffalo! is Turing-complete (proof), but is extremely verbose to program in and pretty much a write-only language.

Examples

Hello World!

Hello world program in esoteric languages (B-C)#Buffalo!

Truth-machine

Truth-machine#Buffalo!

Cat program

Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo! Buffalo Buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo! Buffalo Buffalo buffalo buffalo buffalo. Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo. Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo! Buffalo Buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo. Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo. Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo. Buffalo! Buffalo Buffalo buffalo Buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo Buffalo buffalo buffalo buffalo buffalo Buffalo buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo! Buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo Buffalo buffalo buffalo! Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo Buffalo buffalo buffalo buffalo buffalo buffalo. Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo! Buffalo buffalo Buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Buffalo buffalo buffalo Buffalo buffalo. Buffalo Buffalo buffalo! Buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo Buffalo buffalo buffalo buffalo buffalo buffalo! Buffalo Buffalo buffalo buffalo buffalo.

99 bottles of beer

[1]

Deadfish

Deadfish#Buffalo!

Style guide

The parser is quite permissive and will happily ignore unrecognized tokens i.e., anything other than Buffalo, buffalo, Buffalo!, buffalo!, Buffalo. or buffalo.. This means that comments can freely be interspersed with program text. Unfortunately, this doesn't really help legibility, since any semantic content is lost in the sea of indistinguishable text.

Canonical style wraps and justifies paragraphs to 120 characters, but this can freely be ignored.

Source files must use the extension .Buffalo!; the reference implementation will reject any file with the wrong extension.

Disaffordances

Buffalo! runs on a Minsky machine with registers indexed by noun phrases, plus two extra registers: the accumulator, and the program counter. All registers (including accumulator and program counter) store natural numbers, so decrement saturates at 0, and data types other than naturals must be encoded, using e.g. Church pairs for integers. The interpreter resolves semantic ambiguity as follows: all possible interpretations of a sentence are listed in the order generated by the grammar, then the accumulator indexes into that list (0-based, saturating). This makes conditional jumps and jump tables fairly straightforward; find a set of semantically ambiguous registers, store the desired destinations into them, set the accumulator appropriately, then invoke the intransitive indicative. In practice, a pair of ambiguous registers are enough.

The program counter indexes sentences, again 0-based. Because the language has no way to enter numbers other than repeatedly incrementing the accumulator, forward jumps are quite difficult; by the time you've incremented a register enough to reach the desired value of the program counter, you're already there. The preferred approach of the author is to write a gadget at a fixed address near the start of the program that adds a fixed offset to the address to which it was jumped from, and jump back; finding a form of this gadget that does not turn into an infinite loop during its initial evaluation takes some work (or just trial and error).

Avoiding semantic ambiguity in linear code can be annoying. One trick is to use transitive imperative sentences of the form Buffalo Buffalo buffalo (Buffalo buffalo)^n buffalo^n!, which are always unambiguous and allow access to an infinite set of registers, at the cost of some verbosity. This also means that e.g. copying one register to another takes a minimum of 7 instructions and 2 scratch registers. Another issue is that parsing is O(2^n) in the length of sentences, so the interpreter cheats by spotting sentences of this form and short-circuiting.

The transitive indicative permits using the same register as source and destination, with semantics of decrementing that register. This could have been removed (e.g. making the result a no-op), but the only consequence would have been users designating a junk register as target, so there didn't seem much point. Perhaps this will be restricted in future.

I/O is textual, reading and writing Unicode codepoints from a memory-mapped register, "buffalo". If you want to read and write raw bytes, maybe you can use environment variables to put the hosting language into an extended-ASCII encoding.

Numeric Buffalo!

There is an obvious embedding of Buffalo! sentences into the naturals: encode Buffalo and ! as binary digit 1, and buffalo and . as 0. This isn't implemented yet, but could form an intermediate encoding when writing a quine (not yet implemented).