KARKAIN
← Technology Ecosystem
Developer PreviewProgramming Languagev1.1.0

Karkain

A programming language for the next generation of computing.

Karkain is an independently developed, statically typed systems programming language. It compiles .kark source to C23 and delegates to GCC, Clang or MSVC for final machine code — built around ownership-based memory safety, native concurrency, and a heterogeneous computing vision spanning CPU, GPU and quantum hardware.

  • .kark source extension
  • C23 native backend
  • Self-hosting compiler
  • Borrow checking memory safety
  • v1.1.0 released
HELLO, KARKAIN

Written in .kark

A Karkain program is ordinary text in a .kark file. The compiler reads it, analyzes it, and turns it into a native binary. This exact program was verified against the current Karkain toolchain.

  • Not a managed language — no garbage collector, no VM.
  • Not an interpreted language — source compiles to a native binary.
  • Not LLVM-based — delegates to GCC, Clang or MSVC for machine code.
  • Not the last compiler — Karkain's own front-end is written in Karkain.

The .kark extension is canonical in the Karkain project. Tooling, the package manager and the test framework all treat .kark as the source extension.

DESIGN PRINCIPLES

Why Karkain?

Karkain is built on four non-negotiable principles. They shape the language, the compiler and the runtime.

01

Fast

Zero-cost abstractions, value semantics and no garbage collector. Source compiles to C23 and is optimized by mature C compilers.

02

Safe

Compile-time ownership and borrow checking. No null pointers, no use-after-free, no data races. Option and Result replace exceptions.

03

Heterogeneous

CPU code and GPU compute kernels written in the same .kark file, with quantum circuits targeting OpenQASM and QIR. One language, a spectrum of hardware.

04

Independent

The ultimate goal: karkain compiles itself. No dependency on Go, Rust or any other toolchain for day-to-day development.

COMPILER PIPELINE

From .kark source to a running binary

A deterministic, multi-stage pipeline. Karkain performs its own lexing, parsing, semantic analysis and optimization; only the final machine-code lowering is delegated to a mature C compiler.

.kark sourceLexerParserMacro expandSemantic analysisSSA IROptimizerVerifierC23Binary
Frontendpkg/lexer · pkg/parser

Lexer & Parser

Tokenizes .kark source into a token stream and builds an AST with arena allocation and line tracking.

Analysispkg/sema

Semantic analysis

Borrow checking, type checking and macro expansion validate the program before code generation.

IRpkg/ir · pkg/codegen

SSA IR pipeline

Source lowers to SSA form; constant folding and dead-code elimination run before a verifier checks the result.

Backendpkg/codegen

C23 → native

The C emitter produces C23, linked with GCC, Clang or MSVC into a native binary.

The CPU path is the production pipeline behind Karkain 1.1. GPU shaders (WGSL, SPIR-V, OpenCL) and quantum circuits (OpenQASM, QIR) are part of the documented architecture and represent the project's heterogeneous direction.

ARCHITECTURE VISION

One language. Many computing models.

Karkain is designed so that a single .kark program can speak to a spectrum of hardware — not only one architecture.

CPU

Current

Compiles to C23 and links with GCC, Clang or MSVC. Full native support with Karkain’s own target-triple model (x86_64, aarch64).

SIMD

Evolving

AVX2-aware intrinsics and optimized matrix operations for performance-critical kernels.

WASM

Active

A wasm32-wasi target whose module is emitted directly, without an external linker.

GPU

Evolving

Kernel-driven design aiming to emit WGSL, OpenCL and SPIR-V shaders from the same source file.

Quantum

Direction

Gate-level circuits targeted at OpenQASM 3.0 and QIR as part of the long-term heterogeneous architecture.

Hardware reach

Future

NPU, FPGA, DPU and neuromorphic-class targets remain long-term research horizons on the project’s abstraction agenda.

Status reflects the Karkain roadmap: what ships today, what is actively being built, and where the project is headed.

INTERMEDIATE REPRESENTATION

An IR Karkain owns

Instead of delegating its representation layer to an external compiler framework, Karkain lowers source to its own SSA intermediate representation. The IR pipeline is part of the project and evolves with the language.

Programs can also be emitted as Karkain module bytecode (.kbc) and executed by Karkain's own stack-based VM and JIT engine — a separate execution path from native C23 compilation.

AST → SSA IR

Lowered to SSA form with variable cells and a control-flow graph. Packages: pkg/ir, pkg/codegen/lower.go.

Optimizer → Verifier

Constant folding and dead-code elimination run on the IR before a verifier checks types and control flow. Packages: pkg/ir/ssa.

Two execution paths

Emit C23 and link with GCC/Clang/MSVC, or emit .kbc bytecode and run on the Karkain VM (pkg/jit).

SELF-HOSTING

The compiler is learning to build itself

Karkain's ultimate independence goal: karkain compiles itself. A self-hosted front-end written in Karkain is being brought up through a bootstrap path, and it is already the language's default engine.

Boostrapped through C, the self-hosted front-end then builds Karkain programs by emitting C23 and linking with a system C compiler.

lexer.kark

Tokenizes Karkain source, written in Karkain.

parser.kark

Builds the AST from the token stream.

ast.kark · atypes.kark

Syntax tree and attribute type definitions.

sema.kark · checker.kark

Type checking and analysis in Karkain.

codegen.kark

Emits C23 from the analyzed program.

ECOSYSTEM

More than a compiler

The Karkain ecosystem grows together: a language, a compiler, a runtime, a standard library, a toolchain and developer tooling.

Language

Published · 1.1.0

Static typing, ownership and borrow checking, algebraic data types, pattern matching, and a spec tracked in SPEC.md.

Compiler

Published · 1.1.0

The self-hosted engine lexes, parses, analyzes, optimizes and emits C23.

Runtime

Published · 1.1.0

A concurrency runtime with tasks and channels. No garbage collector. A JIT tier remains planned.

Standard Library

Published · 1.1.0

.kark modules for core semantics, strings, collections, I/O, encoding, crypto, math and more.

Toolchain

Published · 1.1.0

run, build, check, test, fmt, lint, bench, prof, plus package manager and workspaces.

Developer Tools

Partial

A language server providing hover and go-to-definition. Some semantic features are not yet provided by the server, and the editor extension is not part of this public repository.

STANDARD LIBRARY

A native standard library

The standard library is written as .kark modules — the same language applications use — and is an active area of development.

Core foundation

stdlib/core

Identity, conversions, comparison and fundamental operations over owned types.

String & text

stdlib/string

Text processing built on owned byte strings.

Collections

stdlib/collections

A growing set of container and algorithm primitives.

I/O & files

stdlib/io · stdlib/system

Console, filesystem and system-facing operations used by native programs.

Encoding & data

stdlib/encoding

Structured encodings for data exchange.

Crypto & math

stdlib/crypto · stdlib/math

Cryptographic primitives and numerical helpers under active development.

DEVELOPER EXPERIENCE

Built for developers

From a first program to a packaged project, the Karkain toolchain is designed around a simple loop.

write
hello.kark

Write plain .kark source.

check
karkain check hello.kark

Validate syntax and semantics.

build
karkain build hello.kark

Compile to a native executable.

run
karkain run hello.kark

Compile and execute in one step.

test
karkain test <path>

*_test.kark files are auto-discovered.

package
karkain pkg add <pkg>

Resolve dependencies, write lockfile, fetch.

Also part of the toolchain
  • fmt
  • lint
  • bench
  • prof
  • lsp
  • workspace
  • pkg
WHERE KARKAIN IS TODAY

An honest status report

Karkain 1.1.0 is a published release. The compiler, language, standard library and toolchain below ship today; further engineering continues after the release, and planned areas are labelled as such rather than presented as available.

Current status of Karkain components
AreaStatusNotes
Compiler core · Karkain 1.1Published · 1.1.0The project’s own release gate passed and version 1.1.0 was published as its release line. Further engineering continues after the release. No independent performance or reliability assessment has been carried out.
Self-hostingPublished · 1.1.0The compiler’s Karkain-written front-end is the default engine and builds Karkain programs today.
Language & core pipelinePublished · 1.1.0The core language and pipeline ship in 1.1.0. Additional type-system features, autodiff and quantum safety remain in development for later phases.
Concurrency runtimePublished · 1.1.0Task model, channels and synchronization primitives ship in 1.1.0. A JIT tier remains planned.
Standard libraryPublished · 1.1.0Core, string, collections, I/O, encoding, crypto, math and system modules ship in 1.1.0 as .kark.
Cross-compilationPublished · 1.1.0An owned target-triple model covering x86_64, aarch64 and wasm32 over windows, linux and wasi. Running foreign targets is refused for honesty.
Heterogeneous backendsDirectionGPU and quantum backends are documented in the compiler architecture and on the roadmap.
ROADMAP

Where it is heading

Current

Consolidating 1.0

  • Deepening the core language and compiler pipeline.
  • Self-hosted front-end as the daily driver.
  • Extending the standard library modules.
  • Expanding the package ecosystem and lockfile workflow.
Developing

Heterogeneous reach

  • WASM/WASI as a first-class deployment target.
  • GPU kernel compilation from the same source file.
  • Cross-compilation and target triples maturing.
  • An even richer standard library and LSP experience.
Future

Quantum & beyond

  • Quantum circuits compiling to OpenQASM and QIR.
  • Unified representations across CPU, GPU and quantum backends.
  • Long-term research into broader hardware abstractions.
TECHNOLOGY ECOSYSTEM

Part of QuantsMind

Karkain is one of a family of technologies being engineered by QuantsMind. Explore its neighbors in the ecosystem.

GET INVOLVED

Explore Karkain

Follow the project on GitHub. The language, the compiler, the standard library and the documentation evolve together — and the repository is the source of truth.

Documentation — the language spec and engineering reports — live in the repository and evolve alongside the language.