Kinglet v0.1.0
Kinglet 0.1.0 is the first public release of the Kinglet language and its C++
bootstrap compiler. It includes a lexer, parser, static type checker, typed
intermediate representation, and LLVM native backend for Linux, macOS, and
Windows.
Kinglet explores language ideas inspired by C++ proposals while deliberately
adapting their syntax and semantics into a smaller, more coherent language. This
is an early release: it is ready for experimentation, examples, and compiler
work, but the language and toolchain remain pre-1.0 and may evolve.
Highlights
Language
- Static type checking for integers, floating-point values, booleans,
strings, arrays, maps, nullable values, structs, enums, and user-defined
types. - Structs and payload enums, including generic structs and pattern-based
enum payload extraction. - Generic functions and concepts with monomorphized native code generation.
- Pattern matching with bindings, guards, payload destructuring, and
exhaustiveness checking. - Modules and visibility with
export module,import,using namespace,
aliases, and public declarations. - Function overloading and UFCS-style calls with conversion-based overload
ranking. - Control-flow features including expression-bodied functions, implicit
returns,guard, typedtry/catch, pipeline expressions, and chained
comparisons. - Ownership-oriented semantics with references, transfer checking, borrow
conflict detection, resource types,@init/@destroy, and definite
assignment analysis. - Standard runtime facilities for console I/O, strings, arrays, maps,
filesystem access, text encodings, and native resource-backed files.
Diagnostics
Kinglet 0.1.0 introduces a unified, source-aware diagnostic system:
- rustc-style source snippets with line and column information;
- primary and secondary labels for related source locations;
- consistent error and warning rendering across the lexer, parser, checker, and
compiler pipeline; - bounded parser recursion and error recovery for malformed input;
- control-flow analysis for incomplete returns and unreachable statements; and
- 21 stable diagnostic codes covering common syntax, name-resolution, type,
ownership, borrow, initialization, call, control-flow, optional, pattern,
module, and compiler-limit errors.
Examples include K2001 for assignment type mismatches, K4001 for use after
transfer, K5001 for conflicting borrows, K7007 for incomplete non-void
returns, K13001 for non-exhaustive matches, and K19001 for excessive source
nesting.
Diagnostic codes are stable identifiers: message wording may improve in future
releases, but an assigned code will not be reused for a different meaning.
Native compilation
- LLVM-backed native code generation on all published platforms.
- Native lowering for integers, floating-point operations, strings, arrays,
maps, structs, enums, optionals, resources, and filesystem operations. - Static LLVM linkage keeps the compiler distribution compact and avoids a
separate LLVM installation for running the compiler. - The runtime library is shipped alongside the compiler and linked into programs
produced bykinglet build,kinglet run, or--native.
Command-line tools
The kinglet and klet commands provide:
kinglet <file.kl>— compile and run a source file;kinglet init [path]— create a project;kinglet build [target]— build the default or named binary target from the
nearestkinglet.nestproject;kinglet run [<file.kl> | args...]— compile and run a source file, or run
the already-built default project target while forwarding program arguments;kinglet fmt [--check] [paths...]— format Kinglet source files, or report
files that would change;kinglet prune— remove stale native object-cache entries (--allremoves
the project's complete.kingletbuild directory); and--check,--tokens,--ast,--ir, and--nativecompiler modes.
klet is an alias of the same executable.
Platforms
Prebuilt archives are published for:
| Platform | Archive |
|---|---|
| Linux x86-64 | kinglet-linux-x64.tar.gz |
| macOS Apple Silicon | kinglet-macos-arm64.tar.gz |
| Windows x86-64 | kinglet-windows-x64.tar.gz |
Each archive contains:
bin/
kinglet
klet
lib/
Kinglet runtime library
The Windows archive also contains the MinGW runtime DLLs required by
kinglet.exe.
Install
macOS and Linux
curl -fsSL https://kinglet-lang.org/install.sh | shWindows PowerShell
irm https://kinglet-lang.org/install.ps1 | iexThe installers download the matching archive, verify it against the published
SHA256SUMS file when available, install under ~/.kinglet, and add the binary
directory to PATH.
To install manually, extract an archive and add its bin directory to PATH.
The native backend invokes a host C++ linker when producing user executables, so
clang++ or another compatible C++ compiler must also be available.
Quality and testing
Every change is validated with:
- Linux, macOS, and Windows builds;
- the full compiler test suite;
- LLVM native release builds;
- address and undefined-behavior sanitizers;
- lexer, parser, and full-pipeline fuzz smoke tests;
- clang-format and clang-tidy;
- coverage reporting; and
- benchmark smoke checks.
Known limitations
- Kinglet is pre-1.0. Source compatibility is not yet guaranteed between minor
releases, although assigned diagnostic codes are intended to remain stable. - Published binaries currently target Linux x86-64, macOS Apple Silicon, and
Windows x86-64 only. - Producing native user programs requires a compatible host C++ linker. On
Windows, MinGWclang++is recommended so its ABI matches the packaged
runtime. - Concept constraints are statically checked, but concept-typed values do not
yet provide dynamic dispatch or heterogeneous concept collections
(#94). - Machine-readable diagnostics, warning-control flags, and automated FixIt edits
are not included in this release. - A known malformed parser fuzz input can still cause excessive memory growth;
this is tracked in
#103. - Editor integrations are developed separately and are not included in these
compiler archives.
Checksums
SHA-256 checksums for all release archives are published in the attached
SHA256SUMS file.
Source and license
Kinglet is released under the MIT License. The reference compiler source,
build instructions, language documentation, and issue tracker are available at
kinglet-lang/bootstrap.