esolang

niblet

Brainfuck's 30,000 cells, filled half a byte at a time by a pointer that will not stand still.

2015 · Turing complete: unknown · ●●● hard · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: H

The idea

niblet, from 2015, keeps a stack of one nibble, four bits. It writes a byte into a cell in two halves. The first v puts the stack in as the high nibble, the second merges it in as the low one, and each v inverts the stack after it.

Read the story

The cell pointer moves one cell on after every command, whatever the command is. So +++ raises the stack and also walks three cells away. To come back, < moves back two, which after the step forward is one back. All but one line of the Hello World count the stack with + or - and then step back over the count with as many <. The fifth line takes one step more, to write a used cell again.

The machine

CommandDoes
+ -Count the stack up or down, modulo 16
<Move the cell pointer back 2
vPut the stack as the high nibble, or merge it as the low nibble; then invert the stack
. ,Print the cell; read a byte into it
$Run the next command only if the cell is not 0
[Go back one command; a run of k [ goes back k

A v on a cell that is already merged clears it and puts again. Every other character is ignored. The pointer wraps around the 30,000 cells, and reading past the end of the input ends the run.

Example

The first two lines of the Hello World.

The first two lines of the Hello World. Four + make the stack 4, four < walk back to cell 0, and v puts 0100 as the high nibble, 64, leaving the stack 1011. Three - make it 1000, the second v merges it in for 72, and . prints H.

The cat. It reads a byte, prints it, and four [ send it back four commands to the start.

Expected: cat

Patterns it teaches

  • Encoding tricks: a byte built from two nibbles on a stack that inverts itself after every write.

Further

Cell-based

Stack-based

Write your own in Run Convert a program from niblet

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run niblet -e ',<.<[[[[' --input 'cat'
shib manual niblet

Source

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

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

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