INTERCAL
From Wikipedia, the free encyclopedia
INTERCAL, programming language parody, is the canonical esoteric programming language created by Don Woods and James M. Lyon, two Princeton University students, in 1972. It satirizes aspects of the FORTRAN and COBOL programming languages, as well as the proliferation of proposed language constructs and notations in the 1960s. Consequently, the humour may appear rather dated to modern readers brought up with C or Java.
The current version, C-INTERCAL, is maintained by Eric S. Raymond. INTERCAL is said by the original authors to stand for "Compiler Language With No Pronounceable Acronym".
Contents |
[edit] Introduction
INTERCAL is purposely different from all other computer languages. Common operations in other languages have cryptic and redundant syntax in INTERCAL. From the INTERCAL Reference Manual[1]:
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:
DO :1 <- #0¢#256Any 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 have happened to turn up, as bosses are wont to do. The effect would be no less devastating for the programmer having been correct.
The INTERCAL reference manual is a work of humor, containing many paradoxical, nonsensical, or otherwise humorous instructions:
Caution! Under no circumstances confuse the mesh with the interleave operator, except under confusing circumstances!
It contains a "tonsil", as explained in this footnote: "4) Since all other reference manuals have Appendices, it was decided that the INTERCAL manual should contain some other type of removable organ."[1]
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 identifiers such as "PLEASE". This last identifier enables 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 too often, the program is considered groveling. Although this feature existed in the original INTERCAL compiler, it was undocumented.[2]
The INTERCAL manual gives unusual names for all non-alphanumeric ASCII characters: single and double quotes are "sparks" and "rabbit ears" respectively. (The exception is the ampersand: as the Jargon File states, "what could be sillier?") The assignment operator, represented as a "half mesh" or equals sign in many other programming languages, is in INTERCAL a "<-", referred to as "gets" and made up of an "angle" and a "worm".
The original Princeton implementation used punched cards and the EBCDIC character set. In order to allow INTERCAL to run on computers using ASCII, substitutions for two characters had to be made: $ substituted for ¢ as the mingle operator to "represent the increasing cost of software in relation to hardware" and ? was substituted for ∀ as the unary exclusive-or operator to "correctly express the average person's reaction on first encountering exclusive-or".[1]
The Usenet newsgroup alt.lang.intercal is devoted to the study and appreciation of INTERCAL and other esoteric languages.
Despite the language's being intentionally obtuse and wordy, INTERCAL is nevertheless Turing-complete: given enough memory, INTERCAL can solve any problem that a universal Turing machine can solve. It does this very slowly, however. A Sieve of Eratosthenes benchmark, computing all prime numbers less than 65536, was tested on a Sun SPARCStation-1. In C, it took less than 0.5 seconds; the same program in INTERCAL took over seventeen hours.[3]
It should be noted that almost any programming language allows notational horrors as great as or greater than INTERCAL's, as demonstrated in contests such as the International Obfuscated C Code Contest. However, these are generally intentional efforts to create unreadable code, in contrast to INTERCAL's design forcing virtually all code to be unreadable.
According to the INTERCAL manual, "the aim in designing INTERCAL was to have no precedents", supposedly neither in flow control features, nor in data manipulation operators. The designers were partially successful; the only known precedent is a machine instruction [1] in a Soviet mainframe computer BESM-6, released in 1967, that is effectively equivalent to INTERCAL's "select" operator.
[edit] Dialects
The original Woods–Lyon INTERCAL was very limited in its input/output capabilities: the only acceptable input was numbers with the digits spelled out, and the only output was an extended version of Roman numerals[1].
The C-INTERCAL reimplementation, being available on the Internet, has made the language more popular with devotees of esoteric programming languages.[citation needed] The C-INTERCAL dialect has a few differences from original INTERCAL and introduced a few new features, such as a COME FROM statement and a means of doing text I/O based on the Turing Text Model[2].
The authors of C-INTERCAL also created the TriINTERCAL variant, based on the ternary system and generalising INTERCAL's set of operators.[2]
A more recent variant is Threaded Intercal, which extends the functionality of COME FROM to support multithreading.[4]
[edit] Hello, world
The traditional "Hello, world!" program demonstrates how different INTERCAL is from standard programming languages. In C, it could read as follows:
#include <stdio.h> int main(void) { printf("Hello, world!\n"); return 0; }
In other languages it can be even simpler, as in this PHP example:
<?php echo "Hello, world!\n"; ?>
The equivalent program in C-INTERCAL is longer and harder to read:
DO ,1 <- #13 PLEASE DO ,1 SUB #1 <- #234 DO ,1 SUB #2 <- #112 DO ,1 SUB #3 <- #112 DO ,1 SUB #4 <- #0 DO ,1 SUB #5 <- #64 DO ,1 SUB #6 <- #194 DO ,1 SUB #7 <- #48 PLEASE DO ,1 SUB #8 <- #22 DO ,1 SUB #9 <- #248 DO ,1 SUB #10 <- #168 DO ,1 SUB #11 <- #24 DO ,1 SUB #12 <- #16 DO ,1 SUB #13 <- #214 PLEASE READ OUT ,1 PLEASE GIVE UP
[edit] Abandon all sanity
In the article "A Box, Darkly: Obfuscation, Weird Languages, and Code Aesthetics"[5] INTERCAL is described under the heading "Abandon all sanity, ye who enter here: INTERCAL". The compiler and commenting strategy are among the "weird" features described:
- The compiler, appropriately named "ick," continues the parody. Anything the compiler can’t understand, which in a normal language would result in a compilation error, is just skipped. This “forgiving” feature makes finding bugs very difficult; it also introduces a unique system for adding program comments. The programmer merely inserts non-compileable text anywhere in the program, being careful not to accidentally embed a bit of valid code in the middle of their comment.
Paradoxically, other authors seem to have missed the joke. In one report,[6] INTERCAL is described as an instructional language, with the further remark that "INTERCAL was the only one developed for general use like our language CAL."
In The New Hacker's Dictionary,[7] Lyon's name is pluralized to Lyons, but he's used to that. This edition inherits the error from the jargon file of edition 3.0.0 or later; version 2.2.1 included both the correct and pluralized names. The jargon file comments that "INTERCAL has many other peculiar features designed to make it even more unspeakable."
[edit] References
- ^ a b c d INTERCAL reference manual
- ^ a b c C-INTERCAL supplemental reference manual
- ^ Stross, Charles. "Intercal -- the Language From Hell", Computer Shopper (UK), 1992-09.
- ^ Threaded Intercal
- ^ Michael Mateas and Nick Montfort, "A Box, Darkly: Obfuscation, Weird Languages, and Code Aesthetics", PDF
- ^ Abhinav Bhatele and Shubham Satyarth, "Compiler Algorithm Language (CAL): An Interpreter and Compiler", CS499 B.Tech. Project Report IIT, PDF
- ^ Eric S. Raymond, Guy L. Steele (editors), The New Hacker's Dictionary third edition, circa 2000.
[edit] External links
- INTERCAL home page on the Web.
- INTERCAL Resources on the Web, including several implementations
Part of an earlier version of this article contains text from The Jargon File 4.2.3 Mar 2001.