1 unstable release

0.1.4 May 26, 2022

#698 in Programming languages

MIT license

285KB
7.5K SLoC

Welcome to Kaon

Rust

A little scripting language written in rust.

Examples

Hello, World

A simple hello world program:

System.println("Hello, World!")

Class

A slightly more convoluted example using classes:

class Vector {
    // A field
    var x = 0
    var y = 0

    // A constructor
    create new(a, b) {
        self.x = a
        self.y = b
    } 

    fun add(other: Vector) {
        self.x = self.x + other.x
        self.y = self.y + other.y
    }

    // A method
    fun to_string() {
        return "{ x: " + self.x + " y: " + self.y + " }"  
    }
}

fun main() {
    var v1 = Vector.new(4, 5)
    var v2 = Vector.new(6, 7)

    v1.add(v2)

    print(v1.to_string()) // -> { x: 10 y: 12 }
}

main()

More examples can be found in scripts or tests/kaon.

Features

  • object-oriented
  • Bytecode compiler and VM
  • Simple, straightforward syntax
  • Strongly typed; the compiler does its best to eliminate runtime errors

  • Getting Started

    To get started using kaon, first make sure you have cargo installed, then run the following commands:

    git clone https://github.com/PlutonianHacker/kaon-lang.git
    cd kaon-lang
    cargo build
    

    Usage

    Currently the only way to run a Kaon script is with cargo run inside the kaon-lang directory. To run a file, use cargo run <FILE.kaon>, if no file is provided, interactive mode is run instead. To see a list of options, run cargo run -- --help.

    Contributing

    All contributions are welcome! If you find any bugs or have ideas to make the language better, you can open up an issue.

    License

    Kaon is avaliable under the permissive MIT license.

    Dependencies

    ~290–640KB