esolang

blo

Go with nothing but bits. Even the byte is a struct you declare yourself.

2015 · Turing complete: no · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: cat

The idea

blo is from 2015 and reads like Go, with type, func, var, if, for, break and return. But it has no numbers, no strings and no arrays. The only data is the bit, and a type is a struct of bits or of other structs. A program that prints declares its own byte, and the specification names the eight bits after their hex weights, as in type byte { 1, 2, 4, 8, 10, 20, 40, 80 }.

Read the story

Every value is a reference. Assigning to a variable points it at the same bits; assigning to a field copies them. A struct may not hold itself, so the only memory that can grow is the call stack, and the specification files blo under push-down automata.

The machine

StatementDoes
type t { a, b; c u }A struct with bits a and b and a field c of type u
var x tA variable, given fresh cleared bits when first used
set x.a clear x.aSet or clear one bit
if x.a { } else { }Branch on a bit
for { } breakLoop until a break or a return
x = yPoint x at the bits of y
x.c = yCopy the bits of y into x.c

import func putByte(b byte) prints the first 8 bits of its argument, lowest first. getByte reads a byte into them and sets the ninth bit at the end of the input. A line break ends a statement, as in Go.

Example

A cat.

A cat. The ninth field, EOF, is the bit getByte sets when the input runs out.

References at work. a holds 0x41, the letter A. After b = a both names share the same bits, so setting a bit through b turns a into 0x43.

Expected: C

A copy needs a field or a call on the left. In this program id hands back its argument, so id(c) = a copies the bits of a into c, and a stays an A.

Expected: AC

The Hello world program has 29 lines of set and clear between its 13 calls of putByte, and prints Hello world! and a line feed.

Patterns it teaches

  • Turing completeness: without a struct that holds itself, only the call stack grows, which makes it a push-down automaton.

Further

Also in Turing tarpits

Write your own in Run Convert a program from blo

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: blo.

Command line

shib run blo -e 'import func putByte(b byte)
import func getByte(b byte)

type byte { 1, 2, 4, 8, 10, 20, 40, 80, EOF }

func main() {
    for {
        var b byte
        getByte(b)
        if b.EOF {
            break
        }
        putByte(b)
    }
}' --input 'hello, blo'
shib manual blo

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/blo.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org