HQ9 Plus

HQ9+ is a simple but elegant programming language that is very efficient for coding certain classes of computer programs. It has four commands, each represented by a single character: H, Q, 9, and + (hence the name).

  • The H command prints out "Hello, world

  • The Q command prints out a copy of the source code of the program (i.e., it's a quine).

  • The 9 command prints out the lyrics for 99 Bottles of Beer on the Wall.

  • The + command increments the accumulator.

An example HQ9+ program would be: "HHQ+HQ++"

This program would output "Hello, world! Hello, world! HHQ+HQ++ Hello, world! HHQ+HQ++" as well as incrementing the accumulator three times.

It is vacuously true that all useful programs written in HQ9+ run over twice as fast as the same programs written in any other language.

Of course, HQ9+ is a joke; each command represents a common task that beginners are given when learning a new programming language. A common exercise, for example, is to write a computer program that prints "Hello, world. There are some programming languages in which this is actually quite difficult; however, in HQ9+ the task is elementary, since the program "H" will accomplish the task. One of the hardest tasks in many programming languages is to print a quine, or print its own source code. However, in HQ9+, this is also trivial.

HQ9+ interpreters are extremely simple to write, so there have been many written. For example, HQ9+ interpreter was written (in python) in around five minutes yet it is only 18 lines long. And, HQ9+ compiler (in C, compiles HQ9+ programs to C code) is only about 40 lines long.


">
" size=20>

 
 

Browse articles alphabetically:
#0">0 | #1">1 | #2">2 | #3">3 | #4">4 | #5">5 | #6">6 | #7">7 | #8">8 | #9">9 | #_">_ | #A">A | #B">B | #C">C | #D">D | #E">E | #F">F | #G">G | #H">H | #I">I | #J">J | #K">K | #L">L | #M">M | #N">N | #O">O | #P">P | #Q">Q | #R">R | #S">S | #T">T | #U">U | #V">V | #W">W | #X">X | #Y">Y | #Z">Z