<(^.^)> tsuki

Some of my best programming language that I have designed

Throughout my years with programming, I have designed 12 programming languages. Some of them I think are pretty interesting and has some potential. But most of them is either straight up copies from the language that it was based on, or not very interesting to talk about. So, in this post, I will select out some of my best designed programming languages.

1. 3xn

3xn is one of my very first programming languages (and the best one). It is a stack-based esolang where you are limited to only have the first three letters on each line as commands. Any character after that is comments. Here is a Hello world! in 3xn:

'He // Add the string 'He' to the stack
'o  // There is a whitespace after the 'o'
$@. // Merge all things in stack together and print

As you can see, the Hello world! string has to be splitted into smaller parts to fit within the rule using '. And at the final line, we merge all the small strings together ($) and then print it out (@).

You may have (not) noticed the . at the final line, it is basically the no-op operator: It does nothing. It turns out to be pretty useful for single-line comments.

... This is a line of comment

Here is another one, the Counter example:

1:a // Assign a to 1
[.. // Start while loop
^a1 // Load a to stack and push 1
+:a // Plus 2 number on the stack and assign it back to a
^a@ // Outputs a
]0. // Jumps back to the start of the while loop

This one makes a bit less sense to me. There is a 0 after the ], which I honestly don't know why is it there. The line +:a should mean 'assign the + operator to a' (as from the assignment at the first line), but here it means 'add a to 1 and assign the result to a'.

I think the reason why this is interesting to me is because of the design: You are forced to limit to use only 3 commands on each line, which is kinda frustating and dumb. But also, it forces you to come up with solutions to fit within the rule.

2. Nook

Nook is a concatenative, interpreted programming language. It is heavily inspired by GNU dc. Here is a Hello world! example:

{Hello world!} w # Print "Hello world!" after push it to the stack
{Hello world!} p # The same as above, but does not pop the string

Nook uses the curly brackets to contain strings and functions, similiar to dc's square brackets. Nook uses two different operators for priting to output (w and p), while dc uses 1 (p).

Here is a more interesting example, the abs example:

i d { 0 > } { _1 * w } { w } ?

The example takes an integer input, then prints the absolute value of the number. At here, there are a few other operators to introduce. There is the d operator, which is short for duplicate. And the more important one, the ? or (if) operator.

In this example, assuming we give the input -50. The program will:

In our example, the program will print out 50, which is the result of the expression -50 * -1.

I think it is interesting because this is the only language that has been actually implemented so far. You can see the repo on GitHub and run all the examples by yourself. It is also a language that is practical (compare to other ones) and have sets of examples (in the examples/ directory) and a CHANGELOG which you can use as a source of documentation.


So that is the design of Nook and 3xn. They are, in my opinion, two of the best programming languages that I have designed. If you are more interested in other languages that I made, here is a GitHub repo containing all of my notes and examples.

#post #programming-language