Kavun (кавун, watermelon) is a lightweight, high-performance, embeddable scripting language for Go, built around expression-oriented programming and consistent language design principles. Its feature set, including f-strings, arrow-function lambdas, data-type member functions, and fluent chaining, enables transformation-heavy code to be written as clear expressions instead of loop-and-branch boilerplate. It runs on a bytecode VM implemented in Go, making embedding and sandboxing straightforward in Go services and tools.
Install the cli with Go's toolchain:
go install github.com/jokruger/kavun/cmd/kavun@latestOr download a prebuilt binary from the latest release:
Then you can run Kavun scripts with the kavun command or using hashbang:
#!/usr/bin/env kavun
fmt = import("fmt")
result = [1, 2, 3, 4, 5, 6]
.filter(x => x % 2 == 0)
.map(x => x * x)
.reduce(0, (sum, x) => sum + x)
fmt.println(f"sum of even squares: {result}")See more examples.
Full benchmark results are available in the Kavun Benchmarks report. A summary is shown below:
| Rank | Engine | CPU geomean | Avg rank | Worst ratio | Wins | Mem geomean | Tasks run | Missing |
|---|---|---|---|---|---|---|---|---|
| 1 | kavun0 | 1.03× | 1.44 | 1.16× | 5 | 1.20× | 9 | 0 |
| 2 | kavun | 1.09× | 1.78 | 1.25× | 3 | 1.04× | 9 | 0 |
| 3 | gopherlua | 1.63× | 3.78 | 3.98× | 1 | 208.63× | 9 | 0 |
| 4 | golua | 1.68× | 4.33 | 2.40× | 0 | 291.49× | 9 | 0 |
| 5 | starlark | 2.62× | 5.11 | 5.15× | 0 | 202.66× | 9 | 0 |
| 6 | tengo | 3.30× | 5.33 | 59.98× | 0 | 1502.91× | 9 | 0 |
| 7 | goja | 5.35× | 7.22 | 11.08× | 0 | 379.43× | 9 | 0 |
| 8 | risor | 6.55× | 7.00 | 180.74× | 0 | 3958.94× | 9 | 0 |
- Installing - Instructions for installing the Kavun CLI.
- Embedding - Guide to embedding the Kavun runtime in Go applications.
- Language Reference - Syntax, expressions, statements, functions, modules, built-ins, and diagnostics.
- Type Reference - Detailed builtin type semantics, conversions, and member functions.
- Standard Library - Overview of standard library modules and their APIs.
- Examples - Short, runnable snippets showcasing key language features.
- Virtual Machine - Virtual machine specifics and limitations.
- Project Structure - Explanation of the repository layout and development workflow.
- Coding Conventions - Guidelines for code style and contributions.
Before contributing, please review docs/project.md and docs/conventions.md
for project layout, coding standards and repository contracts.
- Fork the repository and clone your fork locally.
- Make your changes in a focused branch.
- Run the test suite.
- Add or update tests in
tests/unitfor any change that affects language or runtime behavior. - Open a pull request describing the motivation for the change and any new or changed semantics.
This project is licensed under the MIT License. See the LICENSE file for details.
This project is based on script language Tengo by Daniel Kang. A special thanks to Tengo's creator and contributors.