Skip to content

Kria-Labs/kria-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kria

Kria

A small, fast programming language — Rust bytecode VM, .krx sources.

Quick start · Language · Examples · Contributing · License


Quick start

Requirements: Rust (2021 edition)

git clone <repo-url> && cd kria-lang
cargo build --release
Command What it does
kria Interactive REPL
kria program.krx Run entry file (+ imported modules)
kria -h Help
./target/release/kria test.krx
./target/release/kria examples/13_imports/main.krx

REPL: persistent session, auto-print for expressions, multi-line blocks, :help / :reset / :exit.


Language overview

Core

  • Dynamic typing · set bindings · print() · type() · wait(ms) · // and /* */ comments · "..." / """...""" strings · newline-terminated statements
  • Operators: arithmetic, comparisons, and / or / not
  • Control flow: if / elseif / else, while, break, continue
  • Functions: fn name(...), lambdas fn(...) { }, return, closures (copy-on-create captures)

Data

Feature Summary
Arrays Mutable [...], immutable #[...], index, .length, push / pop, for item in arr
Objects { key: value }, dot / bracket access, property assign, rmv(), deep equality, for key, value in obj
Input input<str>, input<int>, input<float> with prompts

Modules (multi-file)

Run one entry file; other .krx files load only via import:

import math from "./math.krx"
print(math.add(2, 3))
  • export fn — visible to importers; other functions stay private
  • Relative paths only (./, ../); circular imports are rejected
  • Package manager (KPM) is planned later

Examples

Runnable samples live under examples/:

File Topic
01_basics.krx Variables, print, operators
02_conditionals.krx if / elseif
03_loops.krx while, for-in
04_functions_basic.krx Functions, closures
11_arrays.krx Arrays
12_objects.krx Objects
13_imports/main.krx Multi-file imports
14_type_wait.krx type(), wait()
15_comments_strings.krx Block comments, multiline strings

Architecture

Source (.krx) → Lexer → Parser → Compiler → Bytecode → Stack VM
  • Flat bytecode, constant pool, call frames for functions
  • Hot-loop optimizations (OP_LOOP_INC_LESS, combined global ops)
  • Implementation: src/ (lexer, parser, compiler, vm, repl, modules, project)

Benchmarks

cargo build --release
./benchmarks/benchmarks.sh

Results are written to benchmarks/benchmark_results.txt. Override warmup and runs with BENCH_WARMUP=3 BENCH_RUNS=10.


Install (binary)

Linux / macOS — from the repo root (or any directory):

./release/build.sh install    # build + copy to ~/.kria/bin

install updates ~/.bashrc / ~/.zshrc when needed. Open a new terminal or run source ~/.bashrc, then kria --help.

If kria is still unknown in the current window:

export PATH="${PATH}:$HOME/.kria/bin"

Other commands: ./release/build.sh (build only), ./release/build.sh package (tarball in release/).

Windowscargo build --release, then NSIS via release/kria-setup.nsi.


Contributing

See CONTRIBUTING.md for setup, code style, and pull request guidelines.


License

MIT — Copyright (c) 2026 Piotriox

About

Kria Programming Language. Custom programming language written in Rust. Vs Code extension: https://github.com/Kria-Labs/Kria-vscode

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors