From Esolang
Jump to: navigation, search

MetaGolfScript is a family of programming languages, designed to allow zero length programs to be written, in order to win code-golf contests.


The family consists of multiple languages, all named MetaGolfScript-N, where N is any integer.

For every task which can be solved with GolfScript:

  1. All languages in the family can solve the task as well
  2. There exists a language in the family, in which a zero length program solves the task.


A non-empty MetaGolfScript-N program behaves identically to the same program in GolfScript, regardless of N.

An empty MetaGolfScript-N program behaves identically to the Nth possible GolfScript program. Programs are enumerated first by size, then by lexicographic order. E.g. program 0 is empty, program 1 contains a single NUL character, and so forth.


'Hello, World!'

Prints "Hello, World!" in all MetaGolfScript-N languages.

The empty program prints "Hello, World!" in the MetaGolfScript-209180605381204854470575573749277224 language.

Computational class

All MetaGolfScript languages are Turing-complete, as it can be shown to be computationally equivalent to GolfScript: any non-empty MetaGolfScript langauage behaves identically to the same program in GolfScript.

The interpreter

The following Python script implements MetaGolfScript-N, based on an existing GolfScript interpreter. The interpreter should be saved in a file named, to interpret the MetaGolfScript-N language.

import sys, os, tempfile
def ns(n):
	while n>=256**l:
	return "".join(chr(n/(256**i)%256) for i in range(l-1,-1,-1))
p = sys.argv[1]
if os.stat(p).st_size == 0:
	tmp = tempfile.NamedTemporaryFile()
	tmp.write(ns(long(sys.argv[0].split('.')[-2])))		# Script name =
	p =
os.system("%s %s"% (gs, p))