Skip to content
/ kite Public

Source code for the "Kite" programming language. Contributions are always welcome! (WIP)

License

Notifications You must be signed in to change notification settings

ElisStaaf/kite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kite Programming Language

Kite is a pure and minimalistic programming language written in C. It can be a lot, but if I'd have to classify it, it's a functional programming language with imperative elements. This is a sample of what code written in Kite might look like:

let loop = fun(func, times, until)
    if times < until do @(func, times + 1, until)
    else func

let incr = fun(num)
    num + 1

let mainloop = fun(k, j, i)
    loop(incr(k), j, i)

loop(mainloop(1, 5, 25), 0, 10)

Simple program to print the number "100":

# To print without newline:
write(tostring(100)
# or
import io
io.print(100)

# To print with a newline:
writeln(tostring(100))
# or
import io
io.println(100)

It also includes functions:

let println = fun(v)
    writeln(tostring(v)

let sum = fun(x)
    if x < 2 do x
    else x + sum(x - 1)

println(sum(3))

This does the same thing as the last example:

let println = fun(v)
    writeln(tostring(v))

println((fun(x) if x < 2 do x else x + @(x - 1))(3))

Oh, almost forgot about Modules:

import io
io.print(10)
io.println(20)
io.print(30)

stdlib/io.kite:

let export print = fun(val)
    write(tostring(val))
let export println = fun(val)
    writeln(tostring(val))

Another module; func:

import func

let test = fun()
    writeln(tostring(100))

func.loop(test(), 0, 10)

stdlib/func.kite:

let export loop = fun(func, times, until)
    if times < until do @(func, times + 1, until)
    else func

Another one; math:

import math

writeln(tostring(math.facto(5)))
writeln(tostring(math.fib(10)))

stdlib/math.kite:

let facto = fun(n)
    if n == 1 do n
    else n * @(n - 1)

let fib = fun(x)
	if x < 2 do 1
	else @(x - 1) + @(x - 2)

All modules should be located in lib. This means that you can create your own Kite project, and you can import other files by putting all libraries in lib.

Requirements

Installation

To install, firstly clone the repo:

# git
git clone https://github.com/ElisStaaf/kite

# gh
gh repo clone ElisStaaf/kite

Then build an executable using make:

cd kite
sudo make

# NOTE: To only build the project,
#       not install it, run:
make build