ArticleslgStudy

science

Whitespace (programming language)

Whitespace (programming language) is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Whitespace (programming language) rather than just read about it. In short: Whitespace is an esoteric programming language with syntax where only whitespace characters (space, tab and newline) have meaning – contrasting typical languages that largely ignore whitespace characters. As a consequence of its syntax, Whitespace source code can be contained within the whitespace of code written in a language that ignores whitespace – making the text a polyglot.

Whitespace (programming language) — main illustration
Whitespace (programming language) — illustration

Key takeaways

  • Whitespace (programming language) belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Whitespace (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Whitespace (programming language) from memory before moving on to harder problems.

Reference excerpt

Whitespace is an esoteric programming language with syntax where only whitespace characters (space, tab and newline) have meaning – contrasting typical languages that largely ignore whitespace characters. As a consequence of its syntax, Whitespace source code 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 values onto a stack and access a heap to store data. An interpreter, along with its Haskell 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. 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 sequence of whitespace characters. For example, [tab][space][space][space] 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 of the value – space for positive and tab for negative. Subsequent characters before the terminator represent the binary digits of a value. For example:

[space][tab][space][space][tab][space][tab][tab][linefeed] (STSSTSTTL) is positive since it starts with space and represents 1001011 in binary, which is 75 in decimal. [tab][tab][tab][space][space][tab][space][linefeed] (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. It is a linefeed-terminated sequence of spaceand 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 Official website Release announcement on Slashdot The Whitespace Corpus A collection of interpreters, compilers, and programs for Whitespace Collection of Whitespace interpreters in various script languages Whitespace.NET compiler - a compiler of Whitespace programs to .NET bytecode Acme::Bleach A Perl module that rewrites the body of your module to a whitespace-only encoding ("for really clean programs").

Illustrations

Whitespace (programming language): Whitespace hello world program with syntax highlighting .mw-parser-output .legend{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .legend-color{display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;text-align:center;border:1px solid black;background-color:transparent;color:black}.mw-parser-output .legend-text{}  tabs   spaces
Whitespace hello world program with syntax highlighting .mw-parser-output .legend{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .legend-color{display:inline-block;min-width:1.25em;height:1.25em;line-height:1.25;margin:1px 0;text-align:center;border:1px solid black;background-color:transparent;color:black}.mw-parser-output .legend-text{}  tabs   spaces

Worked examples

Example 1 — a first encounter with Whitespace (programming language)

Start with the simplest possible case. Write down what Whitespace (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Whitespace (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Whitespace (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Whitespace (programming language)

In research
Whitespace (programming language) appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Whitespace (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Whitespace (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Esoteric programming languages, Non-English-based programming languages, Programming languages created in 2002, so understanding it makes those chapters shorter.
In everyday life
Look for Whitespace (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Whitespace (programming language)” →

How to study Whitespace (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Whitespace (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Whitespace (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Whitespace (programming language) in simple terms?

Whitespace is an esoteric programming language with syntax where only whitespace characters (space, tab and newline) have meaning – contrasting typical languages that largely ignore whitespace characters. As a consequence of its syntax, Whitespace source code can be contained within the whitespace…

Why does Whitespace (programming language) matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Whitespace (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Whitespace (programming language).

Tags

  • Esoteric programming languages
  • Non-English-based programming languages
  • Programming languages created in 2002
  • Stack-oriented programming languages
  • Whitespace

Keep exploring