x
X: A programming language that only accepts identifiers that look like the letter 'x'.
Based on the idea from xkcd 2309.
About
In the X language, only characters that closely resemble the letter 'x' can be used to define variables or functions. Any attempt to use a character that does not closely enough resemble an 'x' will result in a syntax error.
X currently provides the following 40 possible identifiers which may be used to define variables or functions:
ฮง, ฯ, าณ, ๐ต, ๐, ๐, ๐ฉ, ๐ก, ไน, ๏พ, โ, โ, โ, โ, ๐, ๐ด, แท, ๐
, ๐, ๐ท, ๐ฑ, ๐, ๐, ๐
, ๐ซ, ๐ฅ, ๐, ๐, ๐, ๐ฟ, ๐, ๐, ๐น, ๐, ๐, ๐ณ, ๐, ๐ญ, ๐, ๐ง
Additionally, X has four further identifiers which have a reserved or built-in use:
x
, which is the entry point of the program. All X programs should have at least onefunc x(){}
.X
, which is used to print tostdout
.ั
, which takes integer inputs fromstdin
.ำฝ
, which takes string inputs fromstdin
.
The X compiler only supports ASCII characters in the source code, with the only exception being that identifiers may be a Unicode character, as long as it closely resembles the appearance of the letter 'x'. Any attempts to use a non-ASCII character that does not resemble an 'x' will result in a compilation error.
Usage
X programs can be compiled with the following command:
./x file.x [-h] [-s] [-o outfile=x.out] [-c compiler=clang]
X source code is first transcompiled into C, before being compiled to an executable.
-h
displays these options and exits.-o
specifies the output file, which isx.out
by default.-s
outputs the file as C source code and does not compile to an executable.-c
specifies the compiler which is used to compile the C source code into an executable. The compiler isclang
by default, but this can be changed to another compiler such asgcc
.
Installing
The X compiler can be downloaded and built into a standalone binary using Pyinstaller as follows:
$ git clone https://github.com/lduck11007/x.git
$ cd x/src
$ pyinstaller --onefile main.py -n x
$ cd dist
$ mv x ../..
$ cd ..
$ rm -rf dist build x.spec __pycache__
Examples
helloworld.x
func x(){
X("hello world!\n",);
}
greet.x
func x(){
let ฮง = "Hello, " + ำฝ("What is your name? ",);
X(ฮง,);
X("\n",);
}
randomNumber.x
func แท(){
return 4; /* chosen by fair dice roll. */
} /* guaranteed to be random */
func x(){
X(แท(),);
X("\n",);
}
fibonacci.x
func ๐ฉ(โ){
if(โ<=1)
return โ;
return ๐ฉ(โ-1,)+๐ฉ(โ-2,);
}
func x(){
let ๐ = ั
("Enter a number: ",);
X(๐ฉ(๐,),);
X("\n",);
}
fizzbuzz.x
func x(){
let ฮง = 1;
while(ฮง<101){
if(ฮง%15==0)
X("FizzBuzz",);
if((ฮง%3==0)&&(ฮง%5!=0))
X("Fizz",);
if((ฮง%3!=0)&&(ฮง%5==0))
X("Buzz",);
if((ฮง%3!=0)&&(ฮง%5!=0))
X(ฮง,);
X("\n",);
ฮง = ฮง+1;
}
}
FAQ
Why?
Good question.