8000 GitHub - callmesalmon/kite: Source code for the "Kite" programming language. Contributions are always welcome! (WIP)
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

callmesalmon/kite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 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))

Note

Pro tip: Shebangs work just fine with kite! If you can't be bothered to run kite run file.kite, just put #!/usr/local/bin/kite run in file.kite, run chmod +x file.kite and then you can run file.kite by ./file.kite!

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)

Note

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

Requirements

Installation

To install, firstly clone the repo:

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

# gh
gh repo clone callmesalmon/kite

Then build an executable using make:

cd kite
sudo make

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