Skip to content

KraitDev/Krait

Krait

Version

Krait is a fast, memory-safe, and highly productive systems programming language.

Designed under the philosophy "Reduce cognitive noise without reducing power," Krait combines the elegant, indentation-based readability of Python with the raw execution speed and control of C and Rust. It compiles directly to native machine code via a highly optimized LLVM-IR backend.

What Makes Krait Different?

Rust-like Memory Safety (Zero-Cost Abstractions)

Krait does not use a garbage collector. Instead, it implements a strict compile-time Ownership Memory Model:

  • Move Semantics: Assigning a heap variable (set a = b) transfers ownership. The compiler invalidates b at compile time to prevent double-free bugs.
  • Auto-Drop: When a variable goes out of scope, the compiler automatically generates a native @free invocation to deallocate heap memory, guaranteeing zero memory leaks.

LLM-Friendly & Vibe-Coder Ready

Krait is designed from the ground up for modern AI-assisted engineering and automated workflows:

  • Actionable Compiler Diagnostics: Errors are printed as beautifully formatted, descriptive blocks explaining exactly why the bug occurred and presenting multiple concrete code resolutions. LLMs read these diagnostics and can fix code immediately.
  • Standard Code Formatter (krait fmt): Standardizes style and indentation instantly, ensuring generated and human code always align perfectly.

True Native Speed for All Hardware

Krait links directly to your native system toolchain with optimal compile-time performance passes:

  • Optimal Optimization: Automatically passes -O3 and -flto (Link-Time Optimization) flags to LLVM/Clang.
  • Broad Hardware Compatibility: Explicitly compiles with -march=x86-64-v2, making executables blazingly fast and compatible on high-end developer rigs as well as legacy and energy-efficient systems (e.g. Intel Celeron, 10th Gen Core i3 laptops).

Features

  • Clean Pythonic Syntax: Indentation-based blocks, minimal punctuation, and low cognitive noise.
  • Modular Imports: Split code bases into clean modules and reuse them with recursive import statements.
  • Built-in Package Scaffolding: Scaffold new structures instantly using krait new.
  • Stand-alone REPL (IDLE): An interactive shell for fast prototyping and instant calculation.
  • Stand-alone Interpreter: Run .kr scripts instantly via krait run without needing a compilation toolchain.
  • VS Code Extension: Premium, built-in colorizer support.

Installation

3d11909 (Release: v1.0.0)

You do not need Cargo or Rust to run Krait. Install the pre-compiled binary directly to your system from the Github releases or install via Terminal:

Linux & macOS

curl -fsSL https://getkrait.pages.dev/install.sh | bash

Windows PowerShell

irm https://getkrait.pages.dev/install.ps1 | iex

Windows Command Prompt

curl -sL https://getkrait.pages.dev/install.bat | cmd

Note for Native Compilation: While the Krait Interpreter (krait run) is completely standalone, using the krait build command to generate optimized hardware executables requires clang to be installed on your system path.

Getting Started

1. Interactive Shell (REPL)

Launch the interactive environment:

$ krait
Krait 1.0.0 Interactive Shell
Type 'exit' to quit.

>>> set greeting = "Hello, Krait!"
>>> show greeting
"Hello, Krait!"

2. Scaffold a New Project

krait new my_app
cd my_app
krait run src/main.kr

3. Compiling Natively

Compile a script to a highly optimized hardware executable:

krait build examples/calculator.kr
./calculator

Syntax Spotlight

Here is an example demonstrating Krait's clean syntax, standard imports, FFI functions, and recursive functions:

# examples/test_math.kr
import math

# abs(-42) -> 42
set a = abs(0 - 42)
show a

# power(2, 10) -> 1024
set p = power(2, 10)
show p

VS Code Extension

To enable official syntax highlighting in VS Code:

  1. Download the vscode-krait.zip file from the repo and extract it.
  2. Copy the extracted vscode-krait folder to your VS Code extensions directory:
    • Windows: %USERPROFILE%\.vscode\extensions\
    • Mac/Linux: ~/.vscode/extensions/
  3. Restart VS Code. Your .kr files will now be properly colorized!

Architecture & Roadmap

With the release of v1.0.0, Krait's roadmap is fully realized:

  • Phase 1: Prototype Engine (Lexer, Parser, AST, Basic Tree-Walking Interpreter)
  • Phase 2: Compiler Backend (LLVM Text IR Generation, Native Linking, Advanced Type Inference)
  • Phase 3: Ownership & Auto-Drop (Compile-time Move analysis, Scope-based stack deallocations)
  • Phase 4: Ecosystem & Tooling (REPL, Project Manager, Actionable Diagnostics, standard math/io libraries, krait fmt)

Contributing

We welcome contributions only through issues.

See CONTRIBUTING.md to learn more.

License & Project Policies

Krait is an open-source project managed by KraitDev. The core compiler, standard libraries, and runtime are dual-licensed under the terms of both the MIT License and the Apache License 2.0.

To protect the integrity of the ecosystem and ensure fair attribution, all users, forks, and contributors are bound by our official project policies:

  • Copyright & Ownership: KraitDev retains exclusive ownership of the core Krait codebase. Contributors maintain authorship of their specific code but grant KraitDev a permanent license to distribute it. Review the full fork and attribution boundaries in COPYRIGHT.
  • Trademark & Identity: The phrase "Krait Programming Language" and the official logos are protected brand assets. You are fully permitted to use them to brand community tools, libraries, and extensions built for the ecosystem, provided it is clear they are independent creations. Deceptive core forks or commercial passing off are strictly prohibited. Review the full domain boundaries in TRADEMARK.

See LICENSE-MIT and LICENSE-APACHE for the underlying open-source license texts.