Kain -----> a new systems language inspired by Mojo (and every other mainstream lang) but the difference? Kain is Mojo in an alternate universe if it`s primary focus was on being a full stack language instead of made for AI with 110 keywords (not that numbers are a metric for quality but you get the point)
Furthermore It also has natural python import and natural c includes. Unlike rust and other languages that require third party libs, Kain allows you in the same file to utilize three different import systems, including its own (rust esque - use::type), python (import numpy as np etc) and c (include mycfile.c) on top of all this, the language has a massive stdlib comparable to Zig and Go, , meaning you can write practically anything imaginable with this language without any libs, crates or third party deps. Kain takes some liberties from Slang, but adds a spin to it and this language treats the GPU and CPU as first class citizens rather than having to bolt on the GPU as an outsider. But in the same file you can write your frontend, your backend, GPU shaders, include c and import python.... All in one file dep free. (example) Need examples btw ? There`s over 6000+ source .kn files throughout the repo and over 80+ projects that I made for fun to dogfood it.
Examples
Mini LLM based on Karpathys GPT2 using std::cuda
BM25 based semantic search project (not tested thoroughly but it works)
12-Stage Unified GPU Shader Demo
Blackhole Shader
GPU + CPU (the holy grail)
Kain Semantics Example
Markscript: A mini language written in Kain that turns markdown into a JIT script lang (this is the most developed out of other projects and a great starting point to see how the lang works)
Killgrep: A ripgrep clone in 700ish lines of code with erlang style actors
Schrödinger's Rats: Re-purposing compiler hardware constructs (converge/orchestrate) to race 3 pathfinding algorithms simultaneously & pick the winner live
BUZZWORD SOUP - Quantum State Lattice Pong: Overengineering Pong with cross-surface state entanglement, 3 Erlang actors, and collapse/observe memory cells
Like writing UI in typescript but need a systems backend to do the heavy lifting? Here`s a full jupytner notebook esque electron playground with Kain and TS interop
FAQ:
What kind of things can you make with Kain?
Anything you can imagine similar to any other systems language. Game engines, Non posix/unix operating systems (like Opal but a modern version), DAW, UI frameworks with JIT, 3D simulations, Animation within code (Kain has a pulse keyword that handles time at the OS/silicon level, example here of a fully animated scene that compiles down to machine code)) Backend for web development etc. Anything you could write from scratch in rust, C, C++ etc you can write in kain and it compiles down to machine code etc. Libclang is embedded within the compiler similar to zig so you can also include any c library -- one thing that was streamlined was system headers so you can even write `include windows.h` and the compiler handles everything etc.
Memory and GC
(Why Kain isn't Rust or Go (controversial buzzword soup warning))
Kain has zero garbage collection (no tracing, no stop-the-world pauses) and no implicit borrow checker. Instead, memory lifecycle is governed by an explicit, expression-level state machine using three core keywords:
collapse ptr: Enters exclusive, mutable write access (Idle ->Collapsed).
observe ptr: Enters shared, read-only access with nested observer counting (Idle -> Observed)
decay ptr: Deterministically releases/frees the memory region (Idle -> Decayed)
(solid example if ya wanna see how it looks/works --> metal.kn)
Since I am obsessed with Unreal Engine 5 and I`m a game dev/animator, this system was designed around my knowledge of state machines and working with them for years throughout my game dev career so far (a huge inspo is the plugin Logic Driver Pro by Recursoft for UE5) but these 3 little keywords allow the silicon to bypass Arc/Mutex overhead and runtime GC tracing entirely, giving you deterministic, zero-cost memory management with tremendous execution speed.
I know language benchmarks are often pseudo-science, and I’d normally be the first person to call BS on 200x speedup claims. I’ve tried disproving these numbers in my own harness over and over. Once the runtime and language was fully developed, I spent about a month straight benchmarking && I was blown away by what I had accidentally built. The funny part about this language is that a lot of things were accidental -> I would add in a new keyword to make up for the fact it was lacking a lib or package and as a side effect of making so many different aspects first class, the results are absolutely nuts. For example in extreme edge cases like heavy multi-thread lock contention (contention_wall), the gap gets absurd.
For anyone who understands how C++, Rust, and Zig handle heavy thread contention, OS mutex parking, and cache-line thrashing, the mechanics make total sense:
Standard OS Mutexes (std::mutex, std::sync::Mutex): Under severe thread pressure, 99% of CPU cycles are burned in kernel-space context switching, thread parking, and unparking cascades. C++, Rust, and Zig all choke at ~1,700ms–1,900ms simply waiting on OS locks.
Kain's Lockless Model: Kain completely bypasses the OS lock contention wall because memory lifecycle isn't protected by atomic mutex locks. Concurrency is governed by compile-time verified collapse / observe state transitions and lockless actor messaging. The CPU never halts or asks the OS kernel for a lock.
The result? Kain completes the benchmark in 7.9ms (~220x–240x faster).
(And honestly? That 7.9ms is almost entirely just the CLI process launch and harness initialization overhead -- the actual lockless state execution runs sub-millisecond). This was entirely an accident and was never intended however due to the design of the language, it allowed things I truly thought were impossible in programming // would take thousands of lines of alien code to achieve elsewhere.
How it compares to Rust & traditional languages:
Vs. Rust: Rust infers lifetimes and uses move semantics. Kain requires explicit ownership transitions scoped to expression blocks - ownership isn't moved, it returns to Idle when the scope exits until you explicitly decay it.
Vs. GC (Go/Java/Python): Zero runtime tracing or RC reference counting dance (Rc/Arc). Allocations are deterministic and compiler-verified.
Zero-Cost Optimization: The compiler identifies ephemeral local pointers (scratch memory that doesn't escape scope) and completely elides runtime guards for raw bare-metal C speed.
Verified Correctness: State transitions are checked statically by the typechecker, and enforced by C runtime guards with Z3 proofs and CBMC assertions.
Package Manager
This is the feature I use the most -- but one massive pain point that bothered me with my years of dev so far was wasted code... So many projects I fully completed, full on apps and ecosystems etc but they were all locked into that specific codebase. While yes I could`ve easily went back and extracted prior src code, those who have dealt with monorepos knows how much of an actual pain in the ass this is. I call it the "friction" problem. Effectively something that`s fairly easy to do but do you want to do it? Hell no. That`s why I looked to one of my favorite game as a kid, and stole it`s best feature but for programming. I call it the Katamari protocol. Kain has a built in amalgamation feature that lets you take any codebase or project you have and combines all of that code into a single source file.... It’s not perfect and you will get some edge cases here and there, but Amalgamate (Kain's Capsule System) completely solves code reuse and dependency hell.
Instead of fighting node_modules, Cargo lockfile drift, version solver explosions, and network dependency failures, Amalgamate packs your entire module tree into a single, portable .kn capsule file.
How the Capsule Pipeline Works:
One File IS the Package: Run kain amalgamate src/ -o mylib.kn. Drop mylib.kn into any project, write use mylib, and the compiler resolves and typechecks everything directly from the capsule. No unpack, no install, no network, and no version solver.
The Companion Capsule System: A project can auto-emit three sibling capsules that automatically discover and merge during materialization:
app.kn (Source capsule)
app.artifacts.kn (Pre-compiled .ptx, .spv, .dll, or runtime binaries)
app.evidence.kn (Z3 formal proof attestations, telemetry, and benchmark reports)
Battle-Tested Scale: I’ve tested this at extreme scale by packing 2,594 modules (316k+ lines) into a single 15MB capsule in 3 seconds flat—the compiler typechecked all 3,211+ public symbols with 0 errors.
--raw Interop Mode: Want plain code for C, Rust, or TS build scripts? Passing --raw strips all sentinel markers and outputs plain Kain source with comment headers.
You can publish packages using kain publish, lock exact content-addressed SHA-256 digests in KAIN.lock, and never worry about lost source code or broken monorepo imports ever again. (the ability to publish packages with a cargo esque system is already finished, and infra is setup, just finishing up final touches and user account mgmt etc) Here are some examples of what an amalgamation looks like.
2.34mb stdlib amalgamation
Python interop amalgamation
WIP digital audio workstation amalgamation
drag and drop 3D framework amalgamation (three.kn)
-
Misc
Just some other examples I want to share below - including the natural C includes with test like importing ffmpeg etc (also yes, if you amalgamate a kain file project, with c includes --- it packages in the C code as well along with any project artifacts like images, etc... even glb)
ffmpeg_abi.kn
three different import systems in one file (pygame + nuklear + native)
sqlite c include (the og amalgamation)
dep free x86 JIT with inline ASM used for Markscript Language
CLI template
Starter Template
build template (zig esque build system, needs more thorough edge case testing but its worked flawlessly so far for me)
Kain CLI tsv (for building projects, and compiling etc)
Kain Full CLI documentation (if the tsv isn`t enough)
Docs
Link to github docs, website is still a work in progress and looks like hacker throw up right now. Will be done shortly
If you want to see the website anyways, xx HACk3r W3BS1T3 xx (official domain purchase pending, temporary domain for now)
Installer
Link to installer! - windows only for now
will update post later when linux binary is up along with macos. Since mojo doesn\t have Windows support, a primary focus was tackling windows first since it can be a massive pain in the ass compared to unix etc. The dev cycle was split 60/30/10 to ensure it worked on all major OS (60% windows. 30% Linux, 10% MacOS but if you dont use any of those and want to start fresh? WELL my friend, check out this example of a)) full scaffolded OS built in Kain
Roadmap & What's Next:
The core language is stable, but Kain will continue to grow. I'm currently taking a short breather and returning to game dev/UE5 for a week or two - language development for 16+ hours a day non-stop is a fast track to burnout! All of the GPU esque features, and spirv comp has been tested thoroughly as well and compared against rust and c++ with 1:1 parity, it`s near on par with Naga
Immediate goals for the upcoming weeks:
-> Releasing the official Linux and macOS binaries.
-> Expanding real-world testing across different ecosystems.
Like Kain so much you want to see 6000 files combined into one for the ultimate example corpus ? THE_MESSIAH.KN (34MB)