The FizzBuzz from Outer Space Explained

Composed on the 30th of November in the year 2014, at 5:16 PM. It was Sunday.

A lot of scorn was heaped on the poor applicant who wrote the FizzBuzz from Outer Space, all of it undeserved. Of course it looked alien to most programmers because the interviewee had gone out of his way to learn an alien programming language, and a little googling would have sufficed to show anyone the truth: the FizzBuzz is written in the Vogon programming language, or V--.

There are a few key things to understand about V-- that give human programmers trouble, which is why most don't bother to learn it: just like Vogon poetry and python, white space is very important; variables are radically typed except when they're implicitly or fuzzily typed, and the math engine is bistromathic.

For readability, I've typed out the code as it would appear on a human computer, although of course true Vogon code is handwritten and can only be compiled in a warm cup of coffee hooked up to a Megabrantian interpreter.

Int (main (*`) -------------- 1 2 Fizz Wrapper -> first statement ------- 1,2 Fizz 1,5 Buzz --------------- Character output { Int (main) (1,2) { (+) 5 + 3 ----- (| STD out / 8.14) Count <c 8.14 ----------------------------- 1 - 100 Integer --------------------- Fizz = 1 - 100 ------- |Fizz| \1 Buzz \1 ------ \1 \5 \5 ------ 3.14

One of the striking achievements of V-- is the dash operator (this is where the "--" part of "V--" comes from). Single dashes literally mean "dash to this number" while longer series of dashes (which are simplified to lines in actual, handwritten V--; the precise number of dashes in a line is implicitly handled during run time) are used to separate "Characters" which are not characters as we think of them in standard languages, but can be understood as "objects acting in their own best interests." Within a character, this versatile symbol further operates as a kind of two way pipe, ensuring the information from the underlined operations can travel freely back and forth to the rest of the program (there's also a relationship between how far the dash line extends past the primary operation and the temperature of the coffee, but it only matters at compile time, so it's not worth getting into here).

The first line of a V-- program always throws C programmers off. The confusion comes from "Int" and the seeming syntax error with an unclosed parenthesis. "Int" in romangon (romanized Vogon) is short for "Internal," which should be obvious as true integer typing is explicitly written as "Integer" later in the program. Internal declarations state that the following code is to be compiled prior to runtime, as opposed to External code, which is dynamically compiled during execution. External code has access to bitnaive operations, but at great expense to execution speed, so it's standard practice to put most of the heavy lifting into Internal logarithms and save External logarithms for terminators (terminators are operations that pass program output to other programming languages). "main" is just the logarithm name, and "*" gives the program access to star charts, which are used for calculating the current rate of expansion of the universe and hence relativistic effects on FTL navigation. It's rarely used in small Internal scripts, but always good to be safe, since do you want to shove your navigation program in the coffee and find out it doesn't have star charts? I didn't think so.

Since all Internal and External logarithms open with a parenthesis, programs that use parenthesis need the "`)" instruction, telling them not to terminate when the compiler encounters a closing parenthesis. Once this is done, the actual terminal parenthesis is considered superfluous and usually left out (although there is a vocal minority that calls for explicitness in this matter, they have yet to make it through the bureaucratic process that would allow them to make their case in reputable programming forums).

"1 2 Fizz" warns the compiler that the following wrapper character will be outputting numbers that increment by one and two strings. The Vogon language lacks a concept for irony, hence they never developed quotation marks, so anything that looks like a word in romangon is a string unless it's a word that's an operation. This can be confusing to humans, but remember that Vogon culture is intensely rule-centric, and even non-programmers have memorized all V-- syntax and reserved words before they're out of the Vogon equivalent of high school.

On to the wrapper. Wrapper means what you'd expect it to mean: everything here is one logarithm until the next wrapper declaration. "-> first statement" means this is the first logarithm that will produce output in the program. It's odd that he chose to be explicit here, since he left out the final closing parenthetical, and declaring the wrapper to be the first statement is usually considered unnecessary when there's only one wrapper. I expect he was trying to impress the interviewers, but fell back on more standard practice once he got going.

Next we declare the the important values we'll be using. Many people thought there was a relationship between the 1,2 here and the 1,2 declared below the initial Int. There is none: 1,2 Fizz and 1,5 Buzz here are simply detailing that an integer comprised of multiple positive 1s will have a future relationship with the following string. It's confusing because due to recipriversexclusion calculations, the first number declared to have an effect on any other part of the system cannot be the number it actually needs to be. Most V-- veterans try to get the number fairly close to its actual value, and here it's confusing because it looks like the Int declaration.

"Character output" specifies that what follows is the primary calculation performed by the Character (the Wrapper in this case), and then we get to work. Int (main) (1,2) adds a pipe interface back to the main abstraction, hooking up input to the Int logarithm to this Character and allowing output from the Character to be accessed by other Ints. This is non-negotiable even if there's nothing else to communicate; due to the mind-bogglingly complex network protocols in Vogon architecture, it is a syntax error to have any calculation that can't send information back to the program as a whole. At first glance this would seem like a scoping nightmare, but V-- trades the concept of scope for tape, wherein all output is automatically has its parent Character and logarithm IDs taped to it (you might think of this as "tagging") so output can be reliably identified and traced back to its producer, or, as is more often the case, ignored. A program with multiple Ints and Exts would have an extra section of declarations detailing what to do with information from all other statement Characters.

The next line is where we compensate for the recipriversexclusion produced by the bistromathics operations with "{ (+) 5 + 3" which states that our real numbers are 5 and 3. The compiler will match 5 to the existing 5 declared at the start of the wrapper and implicitly recognize that the 3 is the real number and replace the 2. "+" symbols in V-- are not addition operators: they're relationship managers. Here, "(+)" specifies these two numbers have a relationship to other number declarations within the Int (obviously in an Ext, the syntax would be ")+("), and the regular + specifies that the two numbers have a relationship with each other, meaning something special happens when both number occur in loops. The "{" symbol just designates a line as betadata, or data that's used either above or below the declaration. After any betadata declaration, you dash out where this data is going to go, in this case, it's going to be piped to STD out with a standard pipe operator, and the parenthesis once again indicate this is an Interior relationship.

Here we encounter the first use of .14, which is confusing until you understand the clear specification that 3 and 5 are the important integers, and that at the very beginning of the Character it was stated integers are going to increment by one, so of course there aren't going to be floats. In this case, "." serves as a tape operator, meaning you can link it to other points in the program that also have .14. 14 also serves as a bit mask specifying that the output can be either a string or a number. 8, as the sum of 3 and 5, reminds the compiler of the important relationship between these numbers, and it's all reverse taped to the STD out pipe with the "/" operator.

Now that the boilerplate architecture is out of the way, we get to a standard V-- loop, here a Count loop, which always look odd to human programmers because the operations inside V-- loops are laid out horizontally, due to the complexity of the piping syntax. "<c" links the output of the loop to the STD pipe—identified by the 8.14 ID—followed by a standard dash from 1 to 100 Integer values statement. The Fizz = 1 - 100 may seem redundant, but it's actually necessary to make sure the potential string output is firmly linked to the the possible values of the dash count.

After that we just forward pipe our strings to the dashing integers. Fizz is our anchor string, since it's always first, hence our primary potential output, and wrapped in pipe brackets, indicating the string can propagate up to the primary output but may also receive data from following dashed input. When performing an initial modulo operation, the modulo has to be specified in a series of # marks, where # is the incrementing value specified at the beginning of the Character, all adding up to the first modulo number (this is an artifact of the caffeine language used by most compilers, and related to bistromathic principle "are you sure you counted it?"; people complain, but again, bureaucracy). After that, additional modulo values can be stated with their sum value. So, modulo 3, pipe the Fizz string back to the output pipe, and simultaneously at modulo 5, dash the Buzz string to the input pipe on Fizz, according to the modulo ID dashed into the Buzz modulo at the bottom, where 3 ties it to the first modulo value and .14 is a fuzzy tape ID to tell the compiler that its value is allowed to be used in the STD out. The double back pipe 5 beneath the Buzz dash just tells the loop that it can both append Buzz to Fizz and output Buzz by itself, and it's implicit in all V-- loops that if they're dashed to an output pipe they print out the number unless otherwise specified.

I hope this clears things up a bit. Though V-- is an odd choice when applying to human companies, I applaud the audacity, and am disappointed his work couldn't be appreciated because of simple human ignorance.

When potential jobs ask me to fax a resume, I just stop taking their calls.

Hi there! You should totally go buy my book for the low low price of 6.66! It's like buying me a beer at an out-of-the-way dive bar in Brooklyn! Not in Manhattan. Manhattan prices are ridiculous, though there are a couple of decent Irish dives where you can snag a drink for five bucks. Otherwise, you're looking at a two or three book beer.