Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

The Aya Programming Language


  • Terse, yet readable syntax
  • Standard library written in aya code
  • Key-value pair dictionaries and objects
  • Number types: double, arbitrary precision float, rational, and complex
  • Basic support for objects and data structures using metatables
  • Pre-evaluation stack manipulation (custom infix operators)
  • List comprehension
  • String Interpolation, Unicode, and special characters
  • Interactive GUI
  • Built in plotting, graphics, and gui dialog library
  • I/O operators for file streams, web downloads, tcp/sockets, and more
  • Interactive help and Documentation
  • Metaprogramming



Aya is a terse stack based programming language originally intended for code golf and programming puzzles. The original design was heavily inspired by CJam and GolfScript. Currently, Aya is much more than a golfing language as it supports user-defined types, key-value pair dictionaries, natural variable scoping rules, and many other things which allow for more complex programs and data structures than other stack based languages.

Aya comes with a standard library written entirely in Aya code. The standard library features types such as matrices, sets, dates, colors and more. It also features hundreds of functions for working working on numerical computations, strings, plotting and file I/O. It even features a basic turtle library for creating drawings in the plot window.

Aya also features a minimal GUI that interfaces with Aya's stdin and stdout. The GUI features plotting, tab-completion for special characters, and an interactive way to search QuickSearch help data.


Hypotenuse Formula

Given side lengths a and b of a right triangle, compute the hypotenuse c

  • x y ^: Raise x to yth power
  • x y +: Add x and y
  • x .^: Square root of x
{a b,
    a 2 ^ b 2 ^ + .^

aya> 3 4 hypot

Pure stack based (no local function variables)

aya> {J2^S.^}:hypot;
  • x y J: Wrap x and y in a list ([x y])
  • [] 2 ^: Broadcast 2 ^ across the list
  • [] S: Sum the list
  • z .^: Square root

Operator breakdown:

aya> 3 4 J
[ 3 4 ] 
aya> 3 4 J 2 ^
[ 9 16 ] 
aya> 3 4 J 2 ^ S
aya> 3 4 J 2 ^ S .^

Primality Test

Test if a number is prime (without using aya's built-in primaity test operator G)

Algorithm utilzing stack-based concatenative programming and aya's operators

Note that R, B, and S (and all other uppercase letters) are operators just like +, -, *, /, etc.

aya> { RB\%0.=S1= }:isprime;
aya> 11 isprime

Same algorithm using more verbose syntax

    n 2 < {
        .# n is less than 2, not prime
    } {
        .# n is greater than or equal to 2, check for any factors
        .# for each number in the set [2 to (n-1)] `i`, do..
        [2 (n 1 -),] #: {i,
            .# check if (n%i == 0)
            n i % 0 =
        .# If any are true (equal to 1), the number is not prime
        {1 =} any !
    } .?

Define a 2D vector type

Type definition:

struct vec {x y}

.# Member function
def vec::len {self,
    self.x 2^ self.y 2^ + .^

.# Print overload
def vec::__repr__ {self,
    .# Aya supports string interpolation

.# Operator overload
def vec::+ {self other,
    self.x other.x +
    self.y other.y +

Call constructor using ! operator and print using __repr__ definition:

aya> 3 4 vec! :v

Perform operations on the type:

aya> v.len

aya> 10 10 vec! v +

Generate a Mandelbrot Fractal

Complex numbers are built in to aya's number system can can be used seamlessly with other numeric types. Aya also includes a graphics library. The viewmat module uses it to draw a 2d intensity image.

import ::matrix
import ::viewmat

400 :width;
width 0.8* :height;

.# Create complex plane
[:2 0.5 width.linspace] matrix! :x;
[1 :1  height.linspace] matrix! .t :y;
y :0i1 * x + :a;

.# Generate the fractal
a E matrix.zeros {2^a+} 20 % .|

.# Display
{3 .>} O

Mandelbrot Fractal

Draw Using a Turtle

Use aya's turtle and color modules to draw a pattern

import ::turtle
import ::color

    color.colors.darkblue :bg_color;
} turtle!:t;

5 :n; :c;

    n t.fd
    89.5 t.right
    1 c.hueshift :c;
    c t.pencolor 
    n 0.75 + :n;
} 400 %

Turtle Example

Load, Examine, and Visualize Datasets

import ::dataframe
import ::plot
import ::stats

"Downloading file..." :P
dataframe.read_csv :df;

df.["time"] :x;
df.["value"] :y;

.# stats.regression returns a function
x y stats.regression :r;

plot.plot! :plt;
x y   {, "Water Level":label} plt.plot
x {r} {, "Trend":label} plt.plot

"Water Level of Lake Huron" plt.:title;
[575 583] plt.y.:lim;
1 plt.y.:gridlines;
"####" plt.x.:numberformat;
2 plt.:stroke;


Lake Huron

Interactive help

Search the interactive help from the repl using \? <hepl text> or from the IDE using Ctrl+Q

aya> \? cosine
MC (N) V
     N: inverse cosine
     overloadable: __acos__
Mc (N) V
     N: cosine
     overloadable: __cos__


See install instructions here:


If you find any bugs or have any feature or operator ideas, please submit an issue on the issue page. Alternively, implement any feature or bugfix yourself and submit a pull request.