Skip to content

Philosophy

Thomas Kwa edited this page May 26, 2019 · 1 revision

A golfing language should enable one to create programs that accomplish a task in the shortest number of bytes possible. In a good golfing language, the size of these programs is close to the Kolmogorov complexity of the task, writing programs is reasonably efficient and fun, and the programs are human-readable.

Most dedicated code-golf languages employ a 256-character code page with single-character commands. A typical example of Jelly code is 9s3’Ẓæ*³FṀ. To write in Jelly, one typically will use tio.run and abrudz's language bar to type in each character, searching the documentation when necessary for the command.

Sledgehammer simply compresses an existing language, Wolfram Language (WL). When golfing in Sledgehammer, one will write WL code and use the interactive Mathematica tool to compress it.

Advantages

  • World-knowledge: The Wolfram Knowledgebase allows Sledgehammer to have access to data about the world for nearly free.
  • Builtins: Wolfram Language is well-known for its thousands of builtins.
  • No special characters: WL can be written entirely in ASCII.
  • Less wasted entropy: Rather than fixing commands to be 8 or 16 bits in length, the effective length of Sledgehammer commands can be adjusted to their frequency; ideally a token with a frequency of 0.2% takes exactly -log2(0.002) = 8.97 bits.
  • Adjustable compression algorithm: Sledgehammer can be equipped with a prediction model to improve compression ratios.
  • Suitable for long programs: Using most golfing languages becomes difficult once programs exceed about 100 bytes, but WL scales into the kilobytes.
  • Lower barrier to entry: WL is known by hundreds of thousands rather than dozens of people, and is somewhat human-readable even to those who don't.

Disadvantages

  • WL not designed for maximum compressibility: Many WL builtins take verbose arguments (e.g. part specs), WL lacks overloading; etc. These sources of inefficiency will be difficult to address.
  • Lack of golfing-specific builtins: Until the golfing library is developed, Sledgehammer will lack golfing-specific builtins that other languages have.
  • Difficulty in development: Compared to Python (source language for many golflangs including Jelly, Charcoal, and Oasis), Wolfram Language is slightly tedious to work with. Can be mitigated in Mathematica v11.3+ with ExternalEvaluate[].
  • Cost of commands not clear: The size of a Jelly or Charcoal command is simply its number of characters, but Sledgehammer has no human-readable compressed representation. One can only tell that Map[] is a 6-bit command by testing it.
Clone this wiki locally