KonLang Tiếng Việt

Ownership you can read.

Kon compiles to native code with no garbage collector. Every call shows whether data is read, changed or handed over, and there are no lifetimes to learn.

The goal is a language as safe as Rust, as fast as C and easier to read than both. It is a goal, not yet a result: Kon is still being built.

struct Player {
    name: String
    health: i32
}

// view reads, edit changes, take hands over.
func describe(player: view Player) {
    print(player.name)
    print(player.health)
}

func heal(player: edit Player, amount: i32) {
    player.health += amount
}

func main(): i32 {
    var hero = Player { name: String("An"), health: 80 }
    heal(edit hero, 20)
    describe(hero)
    return 0
}
An 100

Safe first

Code without unsafe is meant to be unable to corrupt memory. Moves and borrows are checked when you compile, and errors point at the exact line.

Readable next

The words view, edit and take appear in the code that uses them. There are no lifetime annotations to learn, and one syntax with no statement semicolons.

Then fast and light

List access is compiled inline with its bounds check kept. Small programs stay small, with no heavy runtime behind them.

1.0×C's time on five integer workloads, release builds
~90 KBa simple program, against about 64 KB for C and 4.9 MB for Rust, unstripped, on the benchmark programs
0wrong results in 1,133 generated test programs, on a limited set of language forms
1 filethe toolchain on Windows: compiler, library, formatter and test runner

Five programs on one machine do not rank languages in general. How these were measured.

Where to go next

Language tourThe whole language by example. Every example on this site is compiled to check it. LibraryText, JSON, files, paths, processes, data structures, graphics and sound. ToolsOne command for building, running, testing and formatting, and a VS Code extension. PerformanceMeasurements against C and Rust, with the method and the limits. CompareNext to Rust, C and Go, including when not to choose Kon. GamesFour small games written in Kon to test the language. Status and roadmapWhat works, what does not yet, and the order of work ahead. QuestionsCan I use it yet? How is it different from Rust?