Nil

From Esolang
Jump to navigation Jump to search

Nil is the world's first Nihilistic programming language. Essentially, it parses commands of any complexity, and then ignores them.

Examples

Here is the traditional Nil program:

I wandered lonely as a cloud.

A more practical program:

Please, give a NOP if life is either meaningful or not meaningful.

The shortest known Nil quine:


Implementations

One of the most widely deployed Nil interpreters is true, which is shipped as standard with many popular operating systems including GNU/Linux and Mac OS X. The traditional Nil program above (wordsworth.nil) can be invoked thus:

true wordsworth.nil

Alternatively, since the language syntax allows the use of 'shebang' lines, Nil programmers may wish to adopt the following convention to make their programs directly executable:

#!/usr/bin/true -w
I wandered lonely as a cloud.
./wordsworth.nil

Notice the use of the -w option in the above example, which turns on compiler warnings; novice Nil programmers are strongly encouraged to make use of this feature. There is also a scratch interpreter:







and a C/C++ interpreter:

int main(){
    return 0;
}

and a Python interpreter:

pass

and an even shorter Python interpreter:


, which is also the shortest possible Python program. In fact, it works on many other languages (e.g. JavaScript, brainfuck) as well. It is even a self interpreter, but that isn't surprising because any program is a self interpreter. However, this one is the shortest possible.

Bootstrapping

Incredibly, despite not being Turing-complete, the Nil language is expressive enough to implement an interpreter for itself, much more concisely than many 'proper' languages can. The example presented here is a simple implementation, but using advanced compression techniques Nil developers have been able to produce working interpreters in as little as 0 lines of code.

#!/usr/bin/true -w
My mother had a Flit gun
'Twas not devoid of charm
A bit of Flit
Shot out of it;
The rest shot up her arm

This can be seen to run any Nil program successfully, including our example programs from above:

> ./nil_interpreter.nil wordsworth.nil
> ./nil_interpreter.nil quine.nil

External resources