Skip to content

MaxDobbs32/Axios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Axios

Axios is an extremely minimalistic programming language with two core operations. Its name comes from the Greek origin of the word "axiom", and this language is my attempt to explore the fundamental building blocks that can form any theoretical concept.

Axios was created with these goals in mind:

  • To have as few core operations as possible (two, excluding the I/O operations), such that...
    • Each operation is simple to explain
    • Each operation performs the same function(s) in all circumstances
  • To be Turing complete
  • To make writing invalid code impossible; all sequences of characters are valid in Axios and cannot yield a syntax or runtime error (except in instances of excessive memory use)

The implementation as found in axios.c can read program files and run a shell. For writing program files, text files are likely the easiest to work with, since they only contain character encodings. (This implementation assumes your computer saves files in UTF-8.)

All this can be done in the menu, which will pop up if you don't run the program with any arguments (e.g. just running axios.exe or ./axios.o). Alternatively, you can pass a file name as an argument as you execute the program, such as in the examples below:

axios.exe Example Programs/hello world.txt
./axios.o Example Programs/hello world.txt

The language is explained in much greater detail in the "Guide to Axios.pdf" document. Below is a fairly brief summary of how Axios works.

Axios operates on a list of cells that grows over time. Each cell has two possible values, zero or one (not to be confused with the 0 and 1 operators). In this implimentation, cells are stored as bits, but other data types like booleans can also serve this purpose. There is also a pointer located along the list.

In addition, code is always divided into states (similar to a Turing machine). At the beginning of each state, the cell at which the pointer is located is always changed.

The two core operators are 0 and 1, and 2 and 3 are used for output and input respectively. Note that Axios does not require these operators be Western Arabic numerals, as other numeral systems can be used to write programs. In my view, for a programming language with as few operations as Axios, there are no advantages to relying solely on one writing system. It is more important that as many people as possible can type valid code.

In short, the operators work as follows:

Program start: Initializes list containing one cell set to zero (note that the first state must immediately change this cell to one)

1: Divides the code into states. Thus, a different state can be found to the right and to the left of each 1 (even if it contains no operators). There is also the termination state, which lies after the last state visible in code.

0: Performs two functions

  • The presence of a 0 operator indicates the pointer remains where it is. The absence of a 0 operator indicates the pointer moves forward. If the pointer has to move when it is already at the end of the list, a new cell is added to the end, and the pointer returns to the beginning.
  • The number of 0 operators indicates the next state. By default (i.e. no 0 operators), the next state is the next one written in code. Otherwise:
    • If the current cell is one (after changing it), each 0 operator indicates that the next state moves back one. So one 0 repeats the current state written in code, two 0s goes to the state immediately before the current state as written in code, etc.
    • If the current cell is zero (after changing it), continues as normal to the next state written in code.

There are also two I/O operators:

2: Outputs the value of the current cell as a bit (after changing the value of the cell, before moving the pointer, and before changing states, if applicable). Each time 21 bits are output, the program displays a character so long as the output forms a valid UTF-32 encoding (in little-endian order). Attempting to output 21 ones also resets the list used for the 3 operator. (There is no valid character that can be output by 21 ones.)

3: Changes cells according to the individual bits contained in UTF-32 characters input by the user, which are stored in a list in little-endian order. The 3 operator only asks for user input when it uses all the bits in the list (21 bits per UTF-32 character; other bits stored in UTF-32 characters must always be zeroes and are therefore ignored). It is also possible to empty the contents of this list by attempting to output 21 ones. This operation occurs at the beginning of a state, and its presence within a state means the current cell will not be changed except according to user input.

Numeral systems supported by this Axios implementation currently include Western Arabic, Eastern Arabic, Devanagari, Persian, Bengali, Tamil, Thai, Lao, Tibetan, Burmese, Khmer, and fullwidth numerals.

For a proof that Axios is Turing complete, check out "Turing Completeness Proof" in the Example Programs section. If you run the program, it will implement Rule 110, a Turing complete cellular automaton.

About

An extremely minimalistic programming language with two core operations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages