HQ9+-

Introduction

HQ9+- is the long awaited extension of the excellent language HQ9++ created by David Morgan-Mar, which itself is an object-oriented extension of the esoteric HQ9+ authored by Cliff L. Biffle.

Motivation

When the HQ9++ specification was unveiled, it was perceived by many to be the final step in the development of esoteric languages, and for good reasons. HQ9++ is elegant, simple, and yet powerful enough to accomplish every esoteric task. Much of its gracefulness is due to the transparent inclusion of the object-oriented paradigm.

There is, however, a fatal flaw in both of the parent languages: there hardly is any machinery to assist in the debugging of the code. HQ9+- alleviates this problem by introducing a concept which makes debugging and quality control easy and straightforward.

Language Concepts

HQ9+- maintains the backwards compatibility with both HQ9++ and HQ9+, as long as interpreters (compilers) are treating undocumented characters as comments. Strictly speaking, any correct HQ9+- program is also a correct HQ9++ program and will produce an identical output.

There are five operators:

H, Q, 9, +, -

The first four are the same as in the original specification.

Hello World!

H prints "Hello World!".

Quines

Q prints the text of the program.

99 Bottles Of Beer On The Wall

9 prints the (canonical) text of the song "99 Bottles Of Beer On The Wall".

Arithmetic And Objects

+ increments the counter. As in HQ9++, ++ increments the counter twice and creates an object of a new subclass of the generic superclass.

Quality Control

In order to facilitate the quality control, one new operator is added: - (minus sign). It is interpreted as follows:

  1. If it is the very first operator, then it is a syntax error.
  2. When preceded by H, it results in an I/O error.
  3. When preceded by Q, it enters the infinite recursion (a good implementation will crash when out of stack).
  4. When preceded by 9, it enters the infinite loop.
  5. When preceded by +, it divides 1 by 0.
  6. When preceded by ++, it throws a virtual exception, which itself is a method of an object of a new subclass of the generic superclass. In line with the best data-hiding principles, there is no way to intercept this exception.

Implementation Notes

Since HQ9+- is backwards compatible, it only makes sense to extend the existing development tools with this new functionality. A compiler is recommended over interpreter (or a HQ9+- to C++ translator), as it would accentuate the quality control capabilities.

Resources

Original specification of HQ9+ by Cliff L. Biffle.

Original specification of HQ9++ by David Morgan-Mar.

See the Info page for copyright information.