INTERCAL: Difference between revisions

Jump to navigation Jump to search
imported>IrisChronomia
 
imported>Ais523
Details: undo an old change of word quote within a quote – direct quotes should match the wording in the source, otherwise they wouldn't be direct quotes (see MOS:PMC), and the original source is not typoed either but was using an obscure word (wikt:wont) for effect (and thus shouldn't be silently corrected due to not being a typographic error)
 
Line 15: Line 15:
The original Princeton implementation used [[punched card]]s and the [[EBCDIC]] character set. To allow INTERCAL to run on computers using [[ASCII]], substitutions for two characters had to be made: <code>$</code> substituted for <code>¢</code> as the ''mingle'' operator, "represent[ing] the increasing cost of software in relation to hardware", and <code>?</code> was substituted for <code>⊻</code> as the unary [[exclusive-or]] operator to "correctly express the average person's reaction on first encountering exclusive-or".<ref name="manual72"/> In recent versions of C-INTERCAL, the older operators are supported as alternatives; INTERCAL programs may now be encoded in [[ASCII]], [[Latin-1]], or [[UTF-8]].<ref>{{cite web|url=http://c.intercal.org.uk/manual/atvm81sp.htm|archive-url=https://archive.today/20121224065530/http://c.intercal.org.uk/manual/atvm81sp.htm|url-status=dead|archive-date=2012-12-24|title=Princeton and Atari Syntax – C-INTERCAL 0.27 Revamped Instruction Manual|access-date=2012-11-12}}</ref>
The original Princeton implementation used [[punched card]]s and the [[EBCDIC]] character set. To allow INTERCAL to run on computers using [[ASCII]], substitutions for two characters had to be made: <code>$</code> substituted for <code>¢</code> as the ''mingle'' operator, "represent[ing] the increasing cost of software in relation to hardware", and <code>?</code> was substituted for <code>⊻</code> as the unary [[exclusive-or]] operator to "correctly express the average person's reaction on first encountering exclusive-or".<ref name="manual72"/> In recent versions of C-INTERCAL, the older operators are supported as alternatives; INTERCAL programs may now be encoded in [[ASCII]], [[Latin-1]], or [[UTF-8]].<ref>{{cite web|url=http://c.intercal.org.uk/manual/atvm81sp.htm|archive-url=https://archive.today/20121224065530/http://c.intercal.org.uk/manual/atvm81sp.htm|url-status=dead|archive-date=2012-12-24|title=Princeton and Atari Syntax – C-INTERCAL 0.27 Revamped Instruction Manual|access-date=2012-11-12}}</ref>


== Version numbers ==
== Details ==
C-INTERCAL swaps the major and minor version numbers, compared to tradition. The HISTORY<ref>{{cite web|url=https://gitlab.com/esr/intercal/-/blob/master/HISTORY|archive-url=https://web.archive.org/web/20200505203430/https://gitlab.com/esr/intercal/-/blob/master/HISTORY | title=HISTORY file for C-INTERCAL |date=12 June 2019 | archive-date=2020-05-05 | access-date=2020-05-05 }}</ref> file shows releases starting at version 0.3 and {{as of|2020|May|lc=1}} having progressed to 0.31, but containing 1.26 between 0.26 and 0.27.
INTERCAL was intended to be completely different from all other computer languages. In the words of the original manual:
 
CLC-INTERCAL version numbering scheme was traditional until version 0.06, when it changed to the scheme documented in the [[README]]<ref>{{cite web|url=https://sources.debian.org/src/clc-intercal/1:1.0%7E4pre1.-94.-2-5/README/|archive-url=https://web.archive.org/web/20200505200042/https://sources.debian.org/src/clc-intercal/1:1.0%7E4pre1.-94.-2-5/README/ | title=README file for CLC-INTERCAL | archive-date=2020-05-05 | access-date=2020-05-05 }}</ref> file, which says:
 
<blockquote>
  * The term "version" has been replaced by "perversion" for correctness


  * The perversion number consists of a floating-point number with
{{Quote|text=Any resemblance of the programming language portrayed here to other programming languages, living or dead, is purely coincidental.}}
    independent signs for the integer and fractional part. Negative
    fractions indicate pre-escapes (so 1.-94 means "94 pre-escapes to
    go before 1.00". Or you can just add the numbers together and get
    0.06, which is entirely a coincidence since 0.06 is not being
    developed)


  * The fractional part of a perversion number can be integer or floating
Common operations in other languages have cryptic and redundant syntax in INTERCAL. From the INTERCAL Reference Manual:<ref name="manual72" />
    point, with a similar meaning for the parts. The current pre-escape is
    1.-94.-2 which means "2 pre-pre-escapes to go before pre-escape 1.-94".
</blockquote>
 
== Details ==
INTERCAL was intended to be completely different from all other computer languages. Common operations in other languages have cryptic and redundant syntax in INTERCAL. From the INTERCAL Reference Manual:<ref name="manual72"/>


{{quote|text=It is a well-known and oft-demonstrated fact that a person whose work is incomprehensible is held in high esteem. For example, if one were to state that the simplest way to store a value of 65536 in a 32-bit INTERCAL variable is:
{{quote|text=It is a well-known and oft-demonstrated fact that a person whose work is incomprehensible is held in high esteem. For example, if one were to state that the simplest way to store a value of 65536 in a 32-bit INTERCAL variable is:
Line 44: Line 28:
</syntaxhighlight>
</syntaxhighlight>


any sensible programmer would say that that was absurd. Since this is indeed the simplest method, the programmer would be made to look foolish in front of his boss, who would of course happen to turn up, as bosses are expected to do. The effect would be no less devastating for the programmer having been correct. }}
any sensible programmer would say that that was absurd. Since this is indeed the simplest method, the programmer would be made to look foolish in front of his boss, who would of course happen to turn up, as bosses are wont to do. The effect would be no less devastating for the programmer having been correct. }}


INTERCAL has many other features designed to make it even more aesthetically unpleasing to the programmer: it uses statements such as "READ OUT", "IGNORE", "FORGET", and modifiers such as "PLEASE". This last keyword provides two reasons for the program's rejection by the compiler: if "PLEASE" does not appear often enough, the program is considered insufficiently polite, and the error message says this; if it appears too often, the program could be rejected as excessively polite. Although this feature existed in the original INTERCAL compiler, it was undocumented.<ref name="manualick"/>
INTERCAL has many other features designed to make it even more aesthetically unpleasing to the programmer: it uses statements such as "READ OUT", "IGNORE", "FORGET", and modifiers such as "PLEASE". This last keyword provides two reasons for the program's rejection by the compiler: if "PLEASE" does not appear often enough, the program is considered insufficiently polite, and the error message says this; if it appears too often, the program could be rejected as excessively polite. Although this feature existed in the original INTERCAL compiler, it was undocumented.<ref name="manualick"/>
Line 96: Line 80:
|}
|}


Contrary to most other languages, AND, OR, and XOR are [[Unary operation|unary]] operators, which work on consecutive bits of their argument; the [[most significant bit]] of the result is the operator applied to the least significant and most significant bits of the input, the second-most-significant bit of the result is the operator applied to the most and second-most significant bits, the third-most-significant bit of the result is the operator applied to the second-most and third-most bits, and so on. The operator is placed between the punctuation mark specifying a variable name or constant and the number that specifies which variable it is, or just inside grouping marks (i.e. one character later than it would be in programming languages like [[C (programming language)|C]].) SELECT and INTERLEAVE (which is also known as MINGLE) are infix binary operators; SELECT takes the bits of its first operand that correspond to "1" bits of its second operand and removes the bits that correspond to "0" bits, shifting towards the least significant bit and padding with zeroes (so 51 (1'''1'''0'''0'''1'''1''' in binary) SELECT 21 (10101 in binary) is 5 ('''101''' in binary)); MINGLE alternates bits from its first and second operands (in such a way that the least significant bit of its second operand is the least significant bit of the result). There is no operator precedence; grouping marks must be used to disambiguate the precedence where it would otherwise be ambiguous (the grouping marks available are <code>'</code> ("spark"), which matches another spark, and <code>"</code> ("rabbit ears"), which matches another rabbit ears; the programmer is responsible for using these in such a way that they make the expression unambiguous).<ref name="manual72"/>
Contrary to most other languages, AND, OR, and XOR are [[Unary operation|unary]] operators, which work on consecutive bits of their argument; the [[most significant bit]] of the result is the operator applied to the least significant and most significant bits of the input, the second-most-significant bit of the result is the operator applied to the most and second-most significant bits, the third-most-significant bit of the result is the operator applied to the second-most and third-most bits, and so on. The operator is placed between the punctuation mark specifying a variable name or constant and the number that specifies which variable it is, or just inside grouping marks (i.e. one character later than it would be in programming languages like [[C (programming language)|C]]).
 
SELECT and INTERLEAVE (which is also known as MINGLE) are infix binary operators. SELECT takes the bits of its first operand that correspond to "1" bits of its second operand and removes the bits that correspond to "0" bits, shifting towards the least significant bit and padding with zeroes: 51 (1'''1'''0'''0'''1'''1''' in binary) SELECT 21 (10101 in binary) is 5 ('''101''' in binary). MINGLE alternates bits from its first and second operands (in such a way that the least significant bit of its second operand is the least significant bit of the result).
 
There is no operator precedence; grouping marks must be used to disambiguate the precedence where it would otherwise be ambiguous (the grouping marks available are <code>'</code> ("spark"), which matches another spark, and <code>"</code> ("rabbit ears"), which matches another rabbit ears; the programmer is responsible for using these in such a way that they make the expression unambiguous).<ref name="manual72"/>


=== Control structures ===
=== Control structures ===
Line 108: Line 96:


=== Hello, world ===
=== Hello, world ===
The traditional [[Hello world program|"Hello, world!" program]] demonstrates how different INTERCAL is from standard programming languages. In [[C (programming language)|C]], it could read as follows:
The following is a [[Hello world program|"Hello, world!" program]] in INTERCAL.
 
<syntaxhighlight lang="c">
#include <stdio.h>
 
int main(void) {
    printf("Hello, world!\n");
 
    return 0;
}
</syntaxhighlight>
 
The equivalent program in C-INTERCAL is longer and harder to read:


<syntaxhighlight lang="basic">
<syntaxhighlight lang="basic">
Line 150: Line 126:
A more recent variant is Threaded Intercal, which extends the functionality of COME FROM to support [[Thread (computer science)|multithreading]].<ref name="manualthick">{{cite web|url=http://www.cse.unsw.edu.au/~malcolmr/intercal/threaded.html |title=Threaded Intercal |publisher=Cse.unsw.edu.au |date=2004-06-09 |access-date=2012-03-10}}</ref>
A more recent variant is Threaded Intercal, which extends the functionality of COME FROM to support [[Thread (computer science)|multithreading]].<ref name="manualthick">{{cite web|url=http://www.cse.unsw.edu.au/~malcolmr/intercal/threaded.html |title=Threaded Intercal |publisher=Cse.unsw.edu.au |date=2004-06-09 |access-date=2012-03-10}}</ref>


CLC-INTERCAL has a library called INTERNET for networking functionality including being an INTERCAL server, and also includes features such as Quantum Intercal, which enables multi-value calculations in a way purportedly ready for the first [[Quantum computing | quantum computers]].
CLC-INTERCAL has a library called INTERNET for networking functionality including being an INTERCAL server, and includes features such as Quantum Intercal, which enables multi-value calculations in a way purportedly ready for the first [[Quantum computing | quantum computers]].
    
    
In early 2017 a [[.NET]] Implementation targeting the [[.NET Framework]] appeared on [[GitHub]]. This implementation supports the creation of standalone binary libraries and interop with other programming languages. <ref name="componentintercal">{{cite web |url=https://github.com/jawhitti/INTERCAL|title=Official home of Simple Component Intercal for .NET |website=[[GitHub]] |date=30 September 2021 }}</ref>
In early 2017 a [[.NET]] Implementation targeting the [[.NET Framework]] appeared on [[GitHub]]. This implementation supports the creation of standalone binary libraries and interop with other programming languages. <ref name="componentintercal">{{cite web |url=https://github.com/jawhitti/INTERCAL|title=Official home of Simple Component Intercal for .NET |website=[[GitHub]] |date=30 September 2021 }}</ref>
Line 162: Line 138:


{{quote|If PLEASE was not encountered often enough, the program would be rejected; that is, ignored without explanation by the compiler. Too often and it would still be rejected, this time for sniveling. Combined with other words that are rarely used in programming languages but appear as statements in INTERCAL, the code reads like someone pleading.}}
{{quote|If PLEASE was not encountered often enough, the program would be rejected; that is, ignored without explanation by the compiler. Too often and it would still be rejected, this time for sniveling. Combined with other words that are rarely used in programming languages but appear as statements in INTERCAL, the code reads like someone pleading.}}
==In popular culture==
The Nitrome Enjoyment System, a fictional video game console created by British indie game developer [[Nitrome]], has games which are programmed in INTERCAL.


== References ==
== References ==