Whitespace (programming language)

  • Tabs
  • Spaces

Whitespace is a relatively new esoteric programming language. The commands and control statements consist in contrast to conventional programming languages ​​defined sequences of spaces, tabs and newlines (English whitespaces ). In addition to these obvious peculiarity Whitespace used the usual dual system for data only; the program code is in a trivalent end system ( "l", "t", "u" or English. " s", " t", " l" ) shown.

  • 5.1 Whitespace assembler

Syntax

The commands and control statements consist of defined sequences of spaces ( l), tabs (t) and line breaks (u).

There is no syntax element for marking comments. Instead, comments can not contain white spaces themselves, be entered at any point in the source code. The interpreter ignores all characters that have no meaning for him.

Commands

The commands can be roughly divided into five areas:

A detailed description of the individual commands including expected parameter is located on the site below.

Data

While the commands use a trivalent points system, the data in the dual system are shown: The first character from the left is a t for a negative number; an l for a positive. In the course of t is 1, and l is 0, the specification states that numbers can have any bit length, but can compilers and interpreters here to set a reasonable upper limit. A date is terminated by a newline.

Language

Whitespace is an imperative, stack-based programming language that provides programmers a stack and heap available.

All operations work internally to integers of arbitrary bit length. However, there is the possibility to output a character that is identified by its ASCII code value ( outchar ).

History and Background

White Space was developed in late 2002 by Edwin Brady and Chris Morris. Slashdot reported on April 1, 2003 on this programming language. In mid-2003, with the completion of a Whitespace Whitespace interpreter in the language has left the nursery. Five years before Bjarne Stroustrup had mentioned the idea in a draft C 2000. His basic idea was that mathematicians usually write down a space instead of the mark. This space could therefore assign in C 2000 the meaning of multiplication.

Whitespace shows a certain similarity to Python programs and make files, because there the line begins with a tab control the program flow. Most other programming languages ​​ignore whitespaces. However, for the human observer, they serve a useful structure that can make the code more readable.

Benefits are, according to the inventors that mass printouts of source code, save ink and spies who have stolen code, this can not decrypt. However, there are still problems remain, if you want to enter the code after printing again.

Whitespace is particularly well suited to hide program code in plain text similar to steganography. An example of this is found in an article of the International Obfuscated C Code Contest.

Hello World

The above shown "Hello, world! " Program:

Lllullltlltllluttlllltulllttlltltuttlllltlulllttlttlluttllllttulllttlttlluttllll   tllulllttlttttuttlllltltullltlttlluttllllttlullltllllluttlllltttullltttltttuttll   lltlllulllttlttttuttlllltlltullltttlltluttlllltltlulllttlttlluttlllltlttulllttll   tlluttllllttllullltlllltuttllllttltulllttltuttlllltttlullltltluttllllttttullllut   tllllluulllltulultttlulutlltlutullllltutlllululltuullltluuuu development environments

The Vim editor offers of house to a syntax highlighting for whitespace, so the programming is greatly simplified. However, this runs a design goal of the language to use as little ink when printed, against. A mode for Emacs, there are at the links.

The above and below "Hello, world!" can be converted to one of the following scripts in real Whitespace:

#! / bin / sh   sed " s / / / g; s | / / * | | g,. s / \ \ n / / g ' $ 1 | tr -d' \ n '| sed " s / l / / g; s / t / \ t / g, b / u / \ n / g "     #! / bin / sh   sed " s | / / * |. | g " <$ 1 | tr -d "\ t \ n" | tr ltu "\ t \ n" sed is a Unix tool for processing text.

Whitespace assembler

Since dealing with trinary coded machine instructions is relatively cumbersome, an equivalent assembler dialect is often used:

/ / "Hello, world!" Write to memory   lllu / / push 0 / / memory location 0   llltlltlllu / / push 'H ' / / 'H' character   ttl / / store / / into memory   llltu / / push 1 / / ...   lllttlltltu / / push 'e'   ttl / / store   llltlu / / push 2   lllttlttllu / / push 'l'   ttl / / store [ ... ]   lllttllu / / push 12   llltlllltu / / push '!'   ttl / / store   lllttltu / / push 13   lllttltu / / push \ r   ttl / / store   llltttlu / / push 14   llltltlu / / push \ n   ttl / / store   lllttttu / / push 15   llllu / / push 0   ttl / / store     / / Output loop:   llllu / / push 0   ulllltu / / 1: / / / Loop      lul / / dup / / | -.      investigate --- top of the stack | ttt / / pop / /      lul / / dup / / | - '      utlltlu / / jz 2 / / | ----> at 0 we are done      tull / / outchar / / | ---- > Output      llltu / / push 1 / / | -. _. Hochzaehlen location      tlll / / add / / | - '   ululltu / / jmp 1 / / \ of next run   ullltlu / / 2: / /   uuu / / halt / / end literature

  • Oliver Lau: Rocket Science - A Plea for esoteric programming languages ​​: in: c't 22/2007, pp. 192-199.
818985
de