Hello, World! in INTERCAL

Example for versions J-INTERCAL 0.11, J-INTERCAL 0.12, c-intercal 28.0

INTERCAL is one of the languages in which even writing “Hello, World!” is a torture. The trick is, C-INTERCAL’s command READ OUT implements character output on Turing Tape method. To use it, the output argument must be an array, which we have stored in ,1 (, means that the variable is an array of 16-bit integers). The values of the array produce output one by one, from left to right. To figure out what character to output based on i-th element of the array, the compiler performs the following actions:

  1. Bit-reverse ASCII-code of previous printed character (assuming it’s 8-bit) to get rev(i-1). When outputting first element of the array, this is assumed to be 0.
  2. Get the i-th element of the array array(i).
  3. Subtract array(i) from rev(i-1) to get rev(i).
  4. Bit-reverse rev(i) to get ASCII-code of the character to be printed i-th.

Another thing to note is the usage of PLEASE modifier. This program must contain 4 or 5 PLEASE, the lines where they are located don’t really matter. 3 or less PLEASE result in “ICL079I PROGRAMMER IS INSUFFICIENTLY POLITE” error, while 6 or more yield “ICL099I PROGRAMMER IS OVERLY POLITE” error.

Other commands and expressions are trivial (at least compared to previous ones): # is a constant prefix, <- is assignment, SUB is subscript of an array. The first line of the example states that ,1 is an array of 16-bit integers, and it will have 13 elements.

DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
PLEASE DO ,1 SUB #7 <- #48
DO ,1 SUB #8 <- #26
DO ,1 SUB #9 <- #244
PLEASE DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP