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:
- 
Write the module code: Add all the logic and processing in a new folder, with a header file and C++ source file. 
- 
Update src/defs/defs.cpp,src/executor/executor.cppandsrc/defs/defs.h: In these files add references to your new module, to integrate it into the Kyn interpreter.
- 
Run maketo build again.makeshould automatically detect your new module and compile it, as well as recompilingdefs.cppandexecutor.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.