Whitespace (programming language): Difference between revisions

Content deleted Content added
Monkbot (talk | contribs)
m Task 18 (cosmetic): eval 4 templates: hyphenate params (8×);
date format audit, link maintenance
Line 1:
{{Use dmy dates|date=FebruaryApril 20112021}}
[[File:Whitespace in vim2.png|right|206px|thumb|Whitespace [[hello world program]] with syntax highlighting {{legend|#0000ab|tabs}} {{legend|#ab0000|spaces}}]] <!-- make SVG file -->
 
'''Whitespace''' is an [[esoteric programming language]] developed by Edwin Brady and Chris Morris at the [[University of Durham]] (also developers of the [[Kaya (programming language)|Kaya]] and [[Idris (programming language)|Idris]] programming languages). It was released on 1 April 2003 ([[April Fool's Day]]). Its name is a reference to [[whitespace character]]s. Unlike most programming languages, which ignore or assign little meaning to most whitespace characters, the Whitespace interpreter ignores any non-whitespace characters. Only [[Space character|spaces]], [[Tab character|tabs]] and [[linefeed]]s have meaning.<ref name="whitespace">{{cite web|url=http://compsoc.dur.ac.uk/whitespace/tutorial.html|title=Whitespace|website=Compsoc|access-date=2015-10-26|url-status=dead|archive-url=https://web.archive.org/web/20151101230744/http://compsoc.dur.ac.uk/whitespace/tutorial.html|archive-date=1 November 2015|df=dmy-all}}</ref> A consequence of this property is that a Whitespace program can easily be contained within the whitespace characters of a program written in another language, except possibly in languages which depend on spaces for syntax validity such as [[Python (programming language)|Python]], making the text a [[polyglot (computing)|polyglot]].
 
The [[programming language|language]] itself is an [[imperative programming|imperative]] [[stack-based language]]. The [[virtual machine]] on which the programs run has a stack and a [[dynamic memory allocation|heap]]. The programmer is free to push arbitrary-width integers onto the stack (currently there is no implementation of floating point numbers) and can also access the heap as a permanent store for variables and [[data structuresstructure]]s.
 
== History ==
Whitespace was created by Edwin Brady and Chris Morris in 2002. [[Slashdot]] gave a review of this [[programming language]] on 1 April 2003.<ref>{{Cite web |url=http://developers.slashdot.org/story/03/04/01/0332202/New-Whitespace-Only-Programming-Language |title=New Whitespace-Only Programming Language |date=2003-04-01 |website=Slashdot |author=Timothy |access-date=2014-01-23}}</ref>
 
The idea of using whitespace characters as operators for the [[C++]] language was facetiously suggested five years earlier by [[Bjarne Stroustrup]].<ref>{{cite web |url=http://www.stroustrup.com/whitespace98.pdf |title=Generalizing Overloading for C++2000 |first=Bjarne |last=Stroustrup |publisher=AT&T Labs |___location=Florham Park, NJ, USA |access-date=2014-01-23}}</ref>
Line 14 ⟶ 15:
Data is represented in [[Binary code|binary]] using spaces (0) and tabs (1), followed by a linefeed; thus, space-space-space-tab-space-tab-tab-linefeed is the binary number 0001011, which is 11 in decimal. All other characters are ignored and thus can be used for comments.
 
Code is written as an ''Instruction Modification Parameter'' (IMP) followed by the operation.<ref name="tutorial">{{cite web|url = http://compsoc.dur.ac.uk/whitespace/tutorial.html|title = Whitespace Tutorial|website = CompSoc.dur.ac.uk|access-date = 2015-12-08|url-status = dead|archive-url = https://web.archive.org/web/20151101230744/http://compsoc.dur.ac.uk/whitespace/tutorial.html|archive-date = 1 November 2015|df = dmy-all}}</ref> The table below shows a list of all the IMPs in Whitespace.
{| class="wikitable"
|-
Line 83 ⟶ 84:
==Sample code==
<!--NOTE: Please be careful when copying/editing the code below. Some user agents may automatically insert linefeed characters for text wrapping, which will cause the code to run incorrectly.-->
The following is a commented Whitespace program that simply prints [[Hello_world_programHello world program|"Hello, world!"]], where each <span style="color:#ffffff;background:#ff9999">Space</span>, <span style="color:#ffffff;background:#9999ff">Tab</span>, or Linefeed character is preceded by the identifying comment "S", "T", or "L", respectively:
S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>L&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L&#10;L&#10;L&#10;
 
Line 107 ⟶ 108:
*[https://github.com/hostilefork/whitespacers/ Collection of Whitespace interpreters in various script languages]
*[http://metacpan.org/module/Acme::Bleach Acme::Bleach] A [[Perl]] module that rewrites the body of your module to a whitespace-only encoding ("for ''really'' clean programs").
{{Use dmy dates|date=February 2011}}
 
[[Category:Non-English-based programming languages]]