Quidra 0.5.0 · statically typed · native via LLVM · MIT
Quidra Maximum Meaning Per Token
A statically typed, natively compiled general-purpose language for humans and language models. Quidra keeps ordinary code familiar and compact, while making the distinctions that affect correctness explicit.
int factorial(int n)
if n <= 1
return 1
else
return n * factorial(n - 1)
print(factorial(5))
print(NL) 120
-
int factorial(int n)Types stay explicit where they carry meaning: this function takes an int and returns an int. -
if n <= 1Indentation defines the block. There are no braces or semicolons to carry around. -
print(factorial(5))Top-level code can run directly, while the file still compiles through LLVM to native machine code.
01 / semantic compression
Simple where it can be. Explicit where it matters.
Maximum Meaning Per Token is not code golf and it is not extra syntax for its own sake. Quidra removes ceremony the compiler can recover safely, then keeps the few tokens that actually change meaning.
int count = 3- a typed binding with familiar declaration syntax
auto name = "Quidra"- infer a type when the initializer makes it unambiguous
for auto value = values[]- iterate directly over values
Point(3.0, 4.0)- create a value and execute its class initialization
=- ordinary assignment has independent value semantics
&x- observable aliasing is requested explicitly
T(value)- representation changes are explicit
and / or / not- boolean logic uses readable words
The deeper safety rules stay out of ordinary code until they matter: copies remain independent, aliasing is requested explicitly, representation changes are written down, and visible names cannot be silently shadowed.
02 / design laws
Why Quidra
Ordinary code should look ordinary. Quidra becomes explicit exactly where hidden behavior would make a program harder to reason about: value versus storage, write authority, initialization, representation and name resolution.
-
01
Values are the default; storage is explicit.
Ordinary = means an independent value. Observable aliasing is written with &: T & is a mutable reference, while T and const T are values. Const references are not part of the language. The implementation may share storage or copy on write only when the difference cannot be observed.
values.qui int[] a = [1, 2, 3] int[] b = a b[0] = 9 print(a[0]) print(NL) print(b[0]) print(NL) int x = 1 int &writer = &x // A const value is an independent snapshot, even when x has a writable alias. const int snapshot = x writer = 5 print(snapshot) print(NL)output1 9 1
-
02
Authority is part of the call.
A T & parameter explicitly receives writable caller-owned storage. By-value parameters do not grant access to mutate the caller's original binding. The checker tracks what a call requires to be initialized and what it guarantees afterwards, so a writable parameter can safely initialize storage.
authority.qui void inspect(const int value) print(value) print(NL) void .initialize(int &value) value = 7 int value .initialize(&value) inspect(value)output7
-
03
State facts are tracked, not guessed.
Uninitialized does not mean zero, none or a hidden default. Initialization is tracked across branches, loops, references, fields and calls: definitely missing values fail at compile time, and uncertain reads are checked at runtime.
uninitialized.qui int x print(x) print(NL)quidra check uninitialized.quiuninitialized.qui:2:7: error[UNINITIALIZED] 'x' is read before it is initialized on every path. 1 error(s) generated.
-
04
Representation changes are explicit.
An already-typed numeric value never changes representation implicitly, even when the conversion would be lossless. Casts name their destination type. Fixed-width narrowing is range checked; converting a non-integral real to an integer requires an explicit rounding operation such as math.round, math.floor, math.ceil or math.trunc.
representation.qui import math int value = 100 int8 small = int8(value) real64 converted = real64(value) real64 ratio = converted / 3.0 int rounded = math.round(ratio) print(small) print(NL) print(rounded) print(NL)output100 33
-
05
Name resolution is monotonic.
Reserved names are never reusable, visible names are never shadowable, and otherwise names may be reused in disjoint scopes. Adding code near an existing reference can never silently change what that reference means, for a person or for a model editing the file.
names.qui int local_value() int x = 5 return x int x = 7 print(local_value() + x) print(NL)output12
03 / the language
Start familiar. Go as deep as you need.
Begin with bindings, functions, classes and iteration; reach for references, tensors or explicit errors only when the program needs them. Every example below is checked, canonically formatted and run with Quidra 0.5.0 before it is published.
Bindings, values and loops
Typed and auto bindings, string interpolation, an int[] copy that stays independent after mutation, a collection for loop and an explicit range header and an if/elif/else chain.
int count = 3
auto name = "Quidra"
print("Hello, {name}")
print(NL)
int[] original = [1, 2, 3]
int[] copy = original
copy[0] = 9
print("original[0] = {original[0]}, copy[0] = {copy[0]}")
print(NL)
int total = 0
for auto value = original[]
total += value
print("total = {total}")
print(NL)
for 0 <= int i < count
if i == 0
print("first")
print(NL)
elif i < count - 1
print("middle")
print(NL)
else
print("last")
print(NL) Hello, Quidra original[0] = 1, copy[0] = 9 total = 6 first middle last
Defaults, names and generics
A default parameter, a call with named arguments and a constrained generic T largest<T: ordered>(T[] values) whose type argument is inferred from typed int[] and real64[] variables.
int add(int a, int b = 1)
return a + b
bool within(int value, int minimum, int maximum)
return value >= minimum and value <= maximum
T largest<T: ordered>(T[] values)
T best = values[0]
for auto value = values[]
if value > best
best = value
return best
print(add(41))
print(NL)
print(add(a = 40, b = 2))
print(NL)
print(within(50, minimum = 0, maximum = 100))
print(NL)
int[] scores = [3, 9, 4]
print(largest(scores))
print(NL)
real64[] readings = [2.5, 1.5]
print(largest(readings))
print(NL) 42 42 true 9 2.5
Classes with value semantics
A class with initialization arguments and ordered field assignments, a public and a private method, an independent copy via =, an explicit Point &alias that writes through and value equality with ==.
class Point(local int x_value, local int y_value)
int x
int y
x = x_value
y = y_value
private int sum()
return x + y
string describe()
return "({x}, {y}) sum {sum()}"
Point a = Point(1, 2)
Point b = a
b.x = 9
Point &alias = &a
alias.y = 5
print(a.describe())
print(NL)
print(b.describe())
print(NL)
print("{a == b} {a == Point(1, 5)}")
print(NL) (1, 5) sum 6 (9, 2) sum 11 false true
Write authority at the call
A const int[] value parameter receives a snapshot; an int[] & parameter takes writable storage through the marked .double_all(&data) call.
void inspect(const int[] values)
int total = 0
for auto value = values[]
total += value
print("total {total}")
print(NL)
void .double_all(int[] &values)
for auto &value = &values[]
value = value * 2
int[] data = [1, 2, 3]
// Value parameters receive snapshots; mutable calls name the writable storage explicitly.
inspect(data)
.double_all(&data)
inspect(data)
print(data[2])
print(NL) total 6 total 12 6
Tensors with shape contracts
Exact-rank tensor<real32>{3, _, _} bindings, strict singleton broadcasting, .item() and .shape(), plus math.matmul and math.mean from the first-party Math package on 2-D tensors.
import math
tensor<real32>{3, _, _} pixels = tensor.zeros<real32>([3, 64, 64])
tensor<real32>{1, _, _} bias = tensor.ones<real32>([1, 64, 64])
tensor<real32>{3, _, _} shifted = pixels + bias
real32 sample = shifted[0, 10, 20].item()
print(sample)
print(NL)
nat[] shape = shifted.shape()
print(shape[0])
print(NL)
tensor<real32> a = tensor.ones([2, 3])
tensor<real32> b = tensor.ones([3, 2])
tensor<real32> c = math.matmul(a, b)
print(c[0, 0].item())
print(NL)
print(math.mean(c).item())
print(NL) 1.0 3 3.0 3.0
Declarative command line
One cli block declares a required positional argument(), an int option(default = 1) and a bool flag(); field names are the command-line names.
cli args
string source = argument()
int count = option(default = 1)
bool verbose = flag()
print(args.source)
print(NL)
print(args.count)
print(NL)
print(args.verbose)
print(NL) input.txt 3 true
Errors and match
int | error is the whole failure story: try propagates the parse error, error(...) creates one and an exhaustive match handles success and failure without exceptions.
int | error parse_score(string text)
int value = try int.parse(text)
if value > 100
return error("score above 100: {value}")
return value
string[] inputs = ["42", "500", "abc"]
for auto text = inputs[]
match parse_score(text)
int value
print("score {value}")
print(NL)
error problem
print("rejected: {problem}")
print(NL) score 42 rejected: score above 100: 500 rejected: cannot parse numeric input as int
04 / native by construction
Meaning preserved through native compilation
Semantic compression is a source-language goal, not a request for a lightweight implementation. Quidra makes meaning explicit and statically resolved first, then carries those decisions through a typed pipeline into machine code. Later stages never rediscover meaning from source spelling.
- The compiler is written in C++20. Native code is produced through LLVM IR and Clang, optimized at -O3 without fast-math.
- Runtime safety stays on: fixed-width integer overflow, division by zero, array and bin bounds, allocation sizes and out-of-range casts are all checked. A runtime safety failure terminates deterministically with status 101.
- The REPL lowers each submission to LLVM IR and executes it with ORC JIT; nothing is interpreted.
- Linux, macOS and Windows are supported. GPU placement is explicit through the cuda, hip and metal backends, and there is never an implicit fallback to the CPU.
- 01Quidra source
- 02AST
- 03module resolution
- 04generic specialization
- 05static checking, effect analysis, call resolution
- 06typed Quidra IR
- 07LLVM IR
- 08native machine code
05 / for machines too
A compiler you can call
LLM-friendliness is not only surface syntax. The compiler exposes its diagnostics, its structural view of a program and a revision-checked patch operation, so a tool's edit is closer to a checked transaction than to a blind text replacement.
quidra check --jsonreports diagnostics with stable codes and exact spans.quidra inspectexposes nodes with ids, spans, content hashes, inferred types and storage-effect summaries; flags trim the output to what a task needs.quidra patchapplies an edit keyed by node id and hash, rejects stale revisions and overlapping edits, and accepts the result only after it passes the compiler.quidra lspserves diagnostics and formatting over standard LSP stdio framing.
quidra check program.qui --json
quidra fmt program.qui --check
quidra inspect program.qui --no-source --kind call --depth 3
quidra patch program.qui change.json --write
quidra lsp int x
print(x)
print(NL) {"ok":false,"diagnostic_schema_version":2,"truncated":false,"diagnostics":[{"code":"UNINITIALIZED","message":"'x' is read before it is initialized on every path.","file":"uninitialized.qui","source_revision":"b4a7958a3d9dc54b5b236a70f44e72232e9c461d11e3cff75b807cadb32a78e6","node_id":"n000003","node_kind":"name","span":{"start":{"offset":12,"line":2,"column":7},"end":{"offset":13,"line":2,"column":8}}}]} 06 / measured
Quidra publishes its own benchmark, including where it loses.
Ten languages, five independent evaluations, one frozen methodology. Every ranking, score and per-requirement
result of run 2026-09-27-38b7137-gh31 is committed as data in the compiler repository. Quidra 0.3.0, measured at
snapshot 38b7137, places:
07 / ecosystem
A small, explicit library boundary
Core keeps language, tensor, autograd, device and extension mechanisms. Generic mathematics, reusable neural-network semantics, image processing, video decoding and concrete DNN model architectures live in explicit first-party packages. The cards below describe the current development architecture. The released compiler and install instructions on this site remain pinned to Quidra 0.5.0; package availability for that release is shown on Get started.
- quidra-lang/quidra Core The compiler, native runtime, REPL, language server and standard namespaces. C++20 over LLVM, MIT licensed, released from immutable tags with archives for Linux, macOS and Windows.
- quidra-lang/playground Playground The real compiler frontend runs as WebAssembly for browser-local Check, Format, IR, Inspect and Patch. Native Build/Run use a sandboxed runner only when requested, gated to the same language version and exact Core commit.
- quidra-lang/math Math import math. Generic mathematical semantics such as reductions, unary functions, dot products and matrix multiplication live outside Core with their own native and compiler optimizations.
- quidra-lang/nn NN import nn. Architecture-independent neural-network state, reusable layers, losses, optimizers, persistence and NN-owned accelerator/compiler policy live here.
- quidra-lang/vision Vision import vision. Image codecs and tensor image processing such as crop, resize, grayscale, filtering and morphology are Vision-owned package semantics.
- quidra-lang/video Video import video. Video decoding and FFmpeg integration are package-owned; decoded frames are ordinary Quidra tensors and device transfer remains explicit.
- quidra-lang/dnn DNN import dnn. Concrete model architecture families such as AlexNet, VGG and ResNet compose NN and Math rather than re-owning generic layers, optimizers or accelerator backends.
08 / try it
The real compiler frontend, in your browser
The Quidra Playground runs quidra_core compiled to WebAssembly. Check, Format, IR, Inspect and
Patch stay browser-local and do not upload source. Build and Run send the current source only when requested
to a separately sandboxed native runner that invokes the real Quidra CLI. Those operations are enabled only
when the runner reports the same language version and exact Core commit as the WebAssembly frontend.
- Check type-checks and reports the compiler's own diagnostics, with codes and exact spans.
- Format rewrites the source with the same formatter
quidra fmtuses. - IR lowers a checked program to typed Quidra IR.
- Inspect shows node ids, kinds, spans, content hashes and inferred types.
- Patch applies a structured edit and refuses any result that would not compile.
- Build invokes the real native compiler in the sandboxed runner after identity verification.
- Run executes through that same native runner; source is uploaded only for the explicit request.
09 / get started
Install and run
Download the release archive for your platform, put quidra on your PATH, and make sure
Clang 15 or newer is installed for native code generation. Then run a file directly, or build a persistent
executable.
sudo apt-get install ./quidra-linux-amd64.deb
quidra --version print("Hello from Quidra")
print(NL) Hello from Quidra