#scripting #language #koto


A Koto library for working with random numbers

11 releases (breaking)

0.9.1 Nov 1, 2021
0.8.1 Aug 18, 2021
0.7.0 Mar 27, 2021
0.5.0 Dec 17, 2020

#913 in Development tools

Download history 22/week @ 2021-08-05 46/week @ 2021-08-12 11/week @ 2021-08-19 2/week @ 2021-08-26 1/week @ 2021-09-02 3/week @ 2021-09-09 4/week @ 2021-09-16 11/week @ 2021-09-30 4/week @ 2021-10-07 14/week @ 2021-10-14 24/week @ 2021-10-21 23/week @ 2021-10-28 14/week @ 2021-11-04 3/week @ 2021-11-11 9/week @ 2021-11-18

52 downloads per month
Used in koto_cli

MIT license



Docs Crates.io CI Discord

Koto is an embeddable scripting language, written in Rust. It has been designed for ease of use and built for speed, with the goal of it being an ideal choice for adding scripting to Rust applications.

Koto is versatile enough to be useful in a variety of applications, although there has been a focus during development on interactive systems, such as rapid iteration during game development, or experimentation in creative coding.

Current State

The language itself is far enough along that I'm happy to share it with the wider world, although you should be warned that it's at a very early stage of development, and you can expect to find missing features, usability quirks, and bugs. Parts of the language are likely to change in response to it being used in more real-world contexts. We're some distance away from a stable 1.0 release.

That said, if you're curious and feeling adventurous then please give Koto a try, your early feedback will be invaluable.

Getting Started

A Quick Tour

import io.print, test.assert_eq

# Numbers
x = 1 + 2.5 + 100.sqrt()
assert_eq x, 13.5

# Strings
name = "Koto"
print "Hello, $name!"

# Functions
square = |n| n * n
print "8 squared is ${square 8}"

add_squares = |a, b| (square a) + (square b)
assert_eq (add_squares 2, 4), 20

# Iterators, ranges, and lists
fizz_buzz = (1..100)
  .keep |n| (10..=15).contains n
  .each |n|
    match n % 3, n % 5
      0, 0 then "Fizz Buzz"
      0, _ then "Fizz"
      _, 0 then "Buzz"
      else n
  ["Buzz", 11, "Fizz", 13, 14, "Fizz Buzz"]

# Maps and tuples
x = {peaches: 42, pears: 99}
  ("peaches", "pears")

y = # Maps can also be defined using indented `key: value` pairs
  apples: 123
  plums: 99

fruits = x + y # Maps can be combined using the `+` operator

fruit, amount = fruits.max |(_, amount)| amount
print "The highest amount of fruit is: $amount $fruit"

Learning the Language

While there's not yet a complete guide to Koto, there are some code examples that are a good starting point for getting to know the language.

Reference documentation for Koto's core library can be found here.

You're also welcome to ask for help in Discussions, or on the discord server.


The most recent release of the Koto CLI can be installed with Cargo:

cargo install koto_cli


A REPL is provided to allow for quick experimentation. Launching the koto CLI without providing a script enters the REPL.

» koto
Welcome to Koto v0.1.0
» 1 + 1
» io.print "{}, {}!", "Hello", "World"
Hello, World!

A help system is included in the REPL. Run help for instructions.

Language Goals

  • A clean, minimal syntax designed for coding in creative contexts.
  • Fast compilation.
    • The lexer, parser, and compiler are all written with speed in mind, enabling as-fast-as-possible iteration when working on an idea.
  • Fast and predictable runtime performance.
    • Memory allocations are reference counted.
    • Currently there's no tracing garbage collector (and no plan to add one) so memory leaks are possible if cyclic references are created.
  • Lightweight integration into host applications.
    • One of the primary use cases for Koto is for it to be embedded as a library in other applications, so it should be a good citizen and not introduce too much overhead.

Editor Support


~48K SLoC