Skip to content

ūüć謆 an interpreter of the HQ9+ programming language, written in¬†C++20


Notifications You must be signed in to change notification settings


Folders and files

Last commit message
Last commit date

Latest commit


Repository files navigation


CodeFactor Gitpod: ready to code Run on Google: ready to build Codeac C++ CI Super-Linter CodeQL analysis GPLP

This is an interpreter of the entire HQ9+ programming language, implemented in C++20. The output of 9 is Rosetta Stone-compliant and takes a balanced approach to the recursion-versus-readability problem.


This interpreter can be built and tested with almost any C++ compiler built since the 2010s. Testing beyond compilation was completed using Clang 12.0.0 on macOS 11.0 beta and GCC 8.3.0 on Alpine Linux 3.10.0 on iSH 1.0 (73) on iOS 14.0 beta.

  1. Open a terminal and get the code
git clone --verbose --recurse-submodules --progress \
  --branch main
  1. move to the newly downloaded content
cd HQ9 || return 1
  1. build the executable for your machine
clang++ -std=c++2a --verbose -v -Wall -Wextra -pedantic -g -lm -lstdc++ -O0 \
  -fcaret-diagnostics -fdiagnostics-fixit-info -fdiagnostics-parseable-fixits \
  -fdiagnostics-print-source-range-info -fdiagnostics-show-option -fident \
  -fno-builtin -fshow-column -fshow-source-location -fstandalone-debug \
  -ftime-report -ftrapv -integrated-as -pthread -save-stats -save-temps \
  ./*.cpp -o HQ9+ || ./
  1. run the executable
  1. try any combination of input specified in the language. My favorite’s 9:


HQ9+ is a programming language written by Cliff L. Biffle in the early 2000s.


C, written by Dennis¬†Ritchie and Ken¬†Thompson in the¬†mid‚ÄĎ1900s, is the more popular successor to the B¬†programming¬†language.


C89 is the functional equivalent of ANSI C and was published in the late 1900s. In 2020, v0.3.1 of this HQ9+ interpreter was published in C89.


There has long been an excellent public radio station in Seattle broadcasting at¬†89¬Ĺ¬†MHz. In spoken vernacular, it, too, is often referred to as¬†C89. Please support their important¬†work.


C++ is a grandchild language of the B programming language and a superset of its parent language, C.


The release of the version of the C++ programming language whose features were finalized just prior to a pandemic, but which at release time, had still not been incorporated into an ISO standard. In 2020, v1.0.0 of this HQ9+ interpreter was published in C++20.


Where a specification omits implementation details¬†‚Äď where a language‚Äôs behavior is undefined¬†‚Äď it is the interpreter‚Äôs right or responsibility to map conditions to specific behavior where agnosticism¬†fails. That is, unspecified conditions must result in implementation-defined¬†behavior.

For example, the HQ9+ specification implies the machine running it has infinite memory and that the length of input itself have asymptotic similarity to infinity. The devices on which this interpreter was tested had unclear limits, but in all cases, those limits were unambiguously finite, as are the lengths of primitive variable types in C and C++.

Similarly, the specification does not detail how the accumulator’s value is accessed after its initialization at 0. In an abundance of caution, and without drawing conclusions, this implementation is responsive to the ambiguity by tracking the accumulator’s value, but preventing accession to it. Further research must verify whether this is a safer alternative than writing to /dev/null, which may raise concerns about data loss.