2025-10-07 10:16:28 +11:00
2025-10-06 18:33:12 +11:00
2025-10-04 14:54:32 +10:00
2025-10-07 10:15:59 +11:00
2025-10-07 10:15:59 +11:00
2025-09-30 21:29:06 +10:00
2025-09-30 21:29:06 +10:00
2025-10-06 11:57:49 +11:00
2025-10-02 12:50:21 +10:00

Kyn programming language

Kyn is a simple, easily extensible scripting language written in C++. The syntax is inspired by C and shell languages. It is quite fast. Kyn uses the .kyn file extension.

Features

  • Speedy: 20-40% faster than Python
  • Simple Syntax: A small amount of keywords makes Kyn easier to master
  • Small Codebase: 931 lines of code at the time of writing
  • Easily Extensible: The modules system allows anyone to write and contribute their own modules
  • Flexible Licensing: Kyn is licensed to you under the Mozilla Public Licence v2.0, meaning you can develop your own modules and keep them to yourself, while keeping the core interpreter open.

Compiling

Install make and your favourite C++ compiler. Then, run make. Change the compiler variable if required. Ensure that your compiler supports C++14.

Syntax

Kyn is made up of "modules", which you can call on to collect, process, and output data. Use the println module to print something to the console:

println "Hello from Kyn!"

You can use the output from one module inside another by enclosing it with (parenthases), similar to how some shells work.

println (math 10 * 3 + 2)

This will print the result of 10 * 3 + 2 (which happens to be 32.)

You can initialise variables with the let module, and access variables by prefixing a $ dollar sign.

let myVar = "hello!"
println $hello

Reassigning variables is done like most programming languages.

let myVar = "hello!"
myVar = "goodbye!"

Control flow can be done through if and while (which are technically also modules, but they work in a special way.) The compare module can be used for comparisons between things. When using if and while, there's no need to surround your condition in brackets.

let varA = 120
let varB = 130

if compare $varA < $varB {
    println "This code will run!"
} else {
    println "This code won't run."
}

let counter = 0

while compare $counter <= 10 {
    counter = ($counter + 1)
    println $counter
}

Full details of the syntax is in docs/syntax.md.

Developing Modules

Modules are held in the src/modules folder. There are three steps to implementing a module:

  1. Write the module code: Add all the logic and processing in a new folder, with a header file and C++ source file.

  2. Update src/defs/defs.cpp, src/executor/executor.cpp and src/defs/defs.h: In these files add references to your new module, to integrate it into the Kyn interpreter.

  3. Run make to build again. make should automatically detect your new module and compile it, as well as recompiling defs.cpp and executor.cpp, before building the executable.

A full tutorial on writing modules will be released later.

License

Kyn is licensed under the Mozilla Public Licence v2.0.

Description
A simple, easily extensible scripting language
Readme 225 KiB
Languages
C++ 96%
Vim Script 2.5%
Makefile 1.3%
C 0.2%