
Whitespace is an
esoteric
Western esotericism, also known as the Western mystery tradition, is a wide range of loosely related ideas and movements that developed within Western society. These ideas and currents are united since they are largely distinct both from orthod ...
programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
with
syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
where ''only''
whitespace characters
A whitespace character is a character (computing), character data element that represents White space (visual arts), white space when text string, text is
Rendering (computer graphics), rendered for display by a computer.
For example, a ''Space ...
(
space
Space is a three-dimensional continuum containing positions and directions. In classical physics, physical space is often conceived in three linear dimensions. Modern physicists usually consider it, with time, to be part of a boundless ...
,
tab and
linefeed) have meaning contrasting typical languages that largely ignore whitespace characters.
As a consequence of its syntax, Whitespace
source code
In computing, source code, or simply code or source, is a plain text computer program written in a programming language. A programmer writes the human readable source code to control the behavior of a computer.
Since a computer, at base, only ...
can be contained within the whitespace of code written in a language that ignores whitespace making the text a
polyglot.
Whitespace is an
imperative,
stack-based language.
The programmer can push arbitrary-width
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
values onto a
stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
and access a
heap to store data.
An
interpreter, along with its
Haskell
Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
source code, is provided by the Whitespace creators.
History
Edwin Brady and Chris Morris, who also developed the Kaya and
Idris languages, created Whitespace in 2002 at the
University of Durham
Durham University (legally the University of Durham) is a collegiate public research university in Durham, England, founded by an Act of Parliament in 1832 and incorporated by royal charter in 1837. It was the first recognised university to ...
.
Slashdot published a review on
April Fool's Day 2003.
The idea of using whitespace characters as operators for the
C++ language had been facetiously suggested five years earlier by
Bjarne Stroustrup.
Syntax
Whitespace defines a command as a sequences of whitespace characters. For example,
abSpace] paceSpace]
performs arithmetic addition of the top two elements on the stack.
A command is written as an instruction modification parameter (IMP) followed by an operation and then any parameters.
IMP sequences include:
Operator sequences, organized by IMP, include:
*Due to Haskell being lazily evaluated, the effect of the stack being too small may only show when, for example, invoking the ''outputting a number'' side-effect.
**The ''copy'' and ''slide'' operations were added in Whitespace 0.3.
Comments
Characters other than
space
,
tab
and
linefeed
are ignored and thus can be used for comments.
Numbers
A numeric value is represented as a sequence of
space
and
tab
characters that represent 0 and 1 respectively and terminated by a
linefeed
. The first character represents the
Sign (mathematics), sign of the value
space
for positive and
tab
for negative. Subsequent characters before the terminator represent the binary digits of a value.
For example:
*
pacetab]
pacespace]
abpacetab]
ablinefeed] (STSSTSTTL) is positive since it starts with
space
and represents 1001011 in binary, which is 75 in decimal.
*
abtab]
abpacespace]
abpacelinefeed] (TTTSSTSL) is negative since it starts with
tab
and represents -110010 in binary which is −50 in decimal.
Labels
A label is used for
control flow
In computer science, control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated. The emphasis on explicit control flow distinguishes an '' ...
. It is a
linefeed
-terminated sequence of
space
and
tab
characters. As there is only one namespace, all labels must be unique.
Sample code
The following source code is for a Whitespace
"Hello, world!" program. For clarity, it is annotated with
S
,
T
and
L
before each
space
,
tab
, and
linefeed
.
S
S
S
T
S
S
T
S
S
S
L:Push_+1001000=72='H'_onto_the_stack
T
L
S
S
:Output_'H';_S
S
S
T
T
S
S
T
S
T
L:Push_+1100101=101='e'_onto_the_stack
T
L
S
S
:Output_'e';_S
S
S
T
T
S
T
T
S
S
L:+1101100=108='l'
T
L
S
S
S
S
S
T
T
S
T
T
S
S
L:+1101100=108='l'
T
L
S
S
S
S
S
T
T
S
T
T
T
T
L:+1101111=111='o'
T
L
S
S
S
S
S
T
S
T
T
S
S
L:+101100=44=','
T
L
S
S
S
S
S
T
S
S
S
S
S
L:+100000=32=Space
T
L
S
S
S
S
S
T
T
T
S
T
T
T
L:+1110111=119='w'
T
L
S
S
S
S
S
T
T
S
T
T
T
T
L:+1101111=111='o'
T
L
S
S
S
S
S
T
T
T
S
S
T
S
L:+1110010=114='r'
T
L
S
S
S
S
S
T
T
S
T
T
S
S
L:+1101100=108='l'
T
L
S
S
S
S
S
T
T
S
S
T
S
S
L=+1100100=100='d'
T
L
S
S
S
S
S
T
S
S
S
S
T
L:+100001=33='!'
T
L
S
S
:Output_'!';_L
L
L:End_the_program
When Whitespace source code is displayed in some browsers, the horizontal spacing produced by a tab character is not fixed, but depends on its location in the text relative to the next
horizontal tab stop. Depending on the software, tab characters may also get replaced by the corresponding variable number of space characters.
References
External links
*
Release announcement on SlashdotThe Whitespace CorpusA collection of interpreters, compilers, and programs for Whitespace
Collection of Whitespace interpreters in various script languagesAcme::BleachA
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
module that rewrites the body of your module to a whitespace-only encoding ("for ''really'' clean programs").
Non-English-based programming languages
Esoteric programming languages
Whitespace
Programming languages created in 2002
Stack-oriented programming languages
{{Esoteric programming languages