esolang

GolfText

Plain text, packed with LZMA. The program is the compressed file.

None1, 2024 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: Hello, World!

The idea

None1 made GolfText in 2024 to print repetitive text with less code. A program is an .xz file, and running it prints what the file unpacks to. The 99 bottles of beer is 11,884 bytes of text and 544 bytes of GolfText, 4.6% of the size. Short text goes the other way. Hello, World! is 13 bytes of text and 72 bytes of GolfText, and the NOP, which unpacks to nothing, is already 32 bytes.

Read the story

The interpreter on the specification is two lines of Python, print(lzma.decompress(...).decode()). So the text must be UTF-8, the output always ends with a line feed, and the NOP prints an empty line.

The machine

There are no commands. The bytes are read the way Python's lzma module reads them.

PartHolds
Stream headerThe bytes FD 37 7A 58 5A 00, the kind of check, a CRC32
BlockA header that names LZMA2, the chunks, a CRC64 of the text
LZMA2 chunkStored bytes, or range coded literals and copies of earlier text
Index and footerEach block's sizes once more, and the way back to the index

The older .lzma format, a 13-byte header and one LZMA stream, runs too. A program is written as the specification writes it, one hex byte per word.

Example

The text sits in the file as it is, 48 65 6C 6C 6F and on.

The text sits in the file as it is, 48 65 6C 6C 6F and on. The chunk before it, 01 00 0C, says 13 stored bytes, as LZMA does not pay off for so little. The FizzBuzz and 99 bottles use real LZMA chunks, starting E0, and unpack to 412 and 11,884 bytes. Each file's own CRC64 confirms the text.

Patterns it teaches

  • Code golf: the shortest program for a fixed text is its compressed form.
  • Encoding tricks: a general compressor stands in for a language.

Further

Golfing languages

Write your own in Run Convert a program from GolfText

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run golftext -e 'FD 37 7A 58 5A 00 00 04 E6 D6 B4 46 00 00 00 00 1C DF 44 21 1F B6 F3 7D 01 00 00 00 00 04 59 5A'
shib manual golftext

Source

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

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

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