Architecture
Strict is written in Strict. The compiler, the validators, the virtual machine and the native code generator are plain .strict packages in the Strict repository, next to the base types. They compile into one native executable, strict (strict.exe on Windows), and that executable then compiles its own sources again, byte for byte identical.
This is a substantial real-world Strict application: open it in VS Code, follow definitions with F12 and use the inline tests and line values to understand each stage. Every source file is short and self-explanatory, and it starts with tests that show how to use it. This page gives a one-line summary of each type and links to its source. Folder names link to the package on GitHub.
| Package | Responsibility |
|---|---|
| root types | Number, Text, List, Dictionary, Error, File, ... define the language and are its documentation, Strict is the strict command |
Expressions | Tokenizer, syntax tree, statements, header tokens, type shapes, known types, and type inference over all packages |
Validators | Unused and never-changed variables, names, constant folding, limits (ValidateCheck behind strict check) |
Bytecode | Compiles a type into register-based instructions (FileCompiler), inlines constants, removes tests, links used types, writes .strictbinary |
Runtime | The Strict VM that runs those instructions (Execute behind strict <file> and strict test) |
Compiler | NativeBuild behind strict build: instructions to MLIR, the native runtime (texts, lists, files, processes, collector), then mlir-opt, mlir-translate and clang |
| VS Code extension | Edit, test, check and run .strict files, all through strict |
How a program is compiled
SourceFilescollects the.strictfiles of the current folder and its sub folders, then the base types and packages next tostrict.exe, see how strict finds types.Expressionsreads type shapes and method headers, parses each method body into a syntax tree, and infers the type of every expression across all packages.Bytecodecompiles the entry type into register-based instructions. Constants are inlined and folded, inline tests are removed (or collected into a$Testsmethod forstrict test), and theLinkeradds only the methods of other types that are actually called.- Then either
Runtimeruns the instructions on the Strict VM (strict <file>andstrict test), orCompilertranslates them into one MLIR module, appends the handwritten native runtime and lowers everything to an executable (strict build).
Only code that is actually called is parsed, validated, tested and executed. This is what makes it possible to generate huge amounts of code and discard what isn't needed or doesn't work almost immediately.
The native build pipeline, written in the same language it compiles.
Native model
- Every value is one 64-bit slot. Numbers are doubles, and texts, lists and instances are pointer bits.
Errorvalues carry a tag in the top bits, sox is Errorworks for a value of any type. - A type with one member is that member:
Nameis its text,Degreesits number. Members declaringvalue.Bits is 32round to 32-bit precision on construction, on the VM and natively. NativeVector2andSizepack two 32-bit floats into one 64-bit slot, and types of 3 to 16 32-bit numbers likeVector3,Vector4andQuaternionuse flat packed blocks of floats. Lists of Colors store 4 bytes per element in packed format. - Lists append in place as long as they are the newest version.
- Memory combines a generational conservative mark-sweep collector with deferred reference counting. Young collections scan roots and changed cards; larger dead objects and small objects holding them can be reclaimed without tracing the surviving heap. Freed blocks, including large allocations, are reused.
The reference-count checks were exercised across 349 test programs and strict.exe, with no counts reported too low. Reusing allocations reduced the recorded 784-64-6 MNIST training run from 834 to 520 ms. GPU memory pressure triggers full collection before the driver starts paging heavily. See the README memory model for thresholds and diagnostic switches.
Memory management is tuned for high throughput across the compiler, games and neural networks. Uniquely owned values are rewritten in place, dead objects are reclaimed without tracing the surviving heap, and flat layouts minimize overhead for numeric types.
The current VM benchmark reports 1 million loop iterations in 40 ms natively and 105 ms on the Strict VM. These development measurements depend on the workload and hardware. strict builds itself in about 14.5 seconds, most of it in mlir-opt and clang. Executables are reproducible: single-threaded MLIR passes and -Brepro make every build byte-identical.
Expressions
Expressions is the compiler front end. It tokenizes and parses Strict lines into SyntaxNode trees, reads type and method headers, and infers the type of every statement. FileCompiler calls ResolveCheck to build the type inference for all files.
Parsing
Tokenizer: splits a source line into words, numbers, quoted texts and operators.PhraseTokenizer: splits a phrase on spaces into tokens.NumberChars: checks whether a text starts with a digit or a minus sign.SyntaxNode: a syntax tree node (kind, text, children) with precedence-aware printing.SyntaxParser: precedence-based expression parser for binary operators,not, negation, calls, members, lists and literals.StatementParser: parses one line into a statement: declaration,return,if,for,else, reassignment or expression.BodyParser: parses indented method body lines into nested blocks by tab depth.ShuntingYard: converts infix expressions to postfix by operator precedence.HeaderTokens: reads member and method headers: declared or implicit types, parameters, return type and whether it returnsMutable.TypeShape: analyzes a type's lines: members, methods, parameters, constants, enum values, traits and generics.MethodBodies: flattens method bodies into scoped statements, tracking declarations andvalue,indexandouter.Scope: ordered names and types, later entries shadow earlier ones.ScopedStatement: a parsed statement with its visible scope and source line.
Types
KnownTypes: all types with their member, method and parameter scopes. Resolves member, element and plural types.TypeInference: infers result types of literals, calls, members, operators andthen … else, and findstoandfromconversions.TypePattern: a constant type pattern with a concrete name and a display name.ResolveCheck: builds the type inference for all files and reports unresolved names in a folder.FileCheck: reports identifiers that no known type, scope name orvaluemember resolves.
Tools
TypeReport: logs the inferred type of every statement line in a folder.RoundTrip: checks that parsed method bodies print back exactly as their source lines.
Validators
Validators holds the static code-quality rules behind strict check, see Code Validations.
ValidateCheck: thecheckentry point. Collects mutating methods across files, validates each file, logs the issues and returns their count.TypeValidator: per-type checks for unused private members and computedhasmembers that should beconstant, plusUsageRulesfor every method.UsageRules: per-method rules for unused variables and parameters, names that hide members,mutablevalues that never change andmutableparameters.Limits: line length, nesting, tab indentation, method length, and method and member counts.Names: rejects keywords as names, names starting withList, and constants named like a type or a method.ConstantCollapser: folds constant subexpressions (arithmetic, text concatenation,and/or,toconversions).ValidationIssue: one issue (rule, target, message), printed asRuleName: target.
Bytecode
Bytecode turns a type, plus the packages it references, into register-based instructions. Along the way it folds constants and strips inline tests, or collects them into a $Tests method. It links in only the methods of other types that are actually used, and packs everything into a .strictbinary zip. The entry point is FileCompiler.
Compiling and linking
FileCompiler: compiles a file with its packages and optional tests, links the used types and writes the.strictbinarybytes.SourceFiles: collects the.strictfiles of the source folder and the packages it references.TypeCodegen: compiles a type's lines into aTypeEntry: members, constants, and all or only the selected methods.Linker: repeatedly adds the used types, with only their called methods, to the compiled entry type.
Caches and packages
Successful tests write a .strictbinary cache. Source and test-read file timestamps determine freshness, so unchanged code can run, test and build without recompilation. Matching package caches can be referenced instead of embedding the same dependencies repeatedly. strict update . refreshes packages tracked by .origin; resolution can use sibling projects, local clones or GitHub. See Getting Started and Tests.
Code generation
MethodCodegen: generates a method body: statements, assignments,if/else, logging and returns.ValueCodegen: the core expression generator for literals, variables, calls, member access, indexing and type lookups.OperatorCodegen: arithmetic, comparisons,and/or,is in,then … elseand operator methods of custom types.LoopCodegen:forloops over ranges, counts, iterators and nested loops, plus the implicit sum, product, list and any results.SelectorCodegen: selectorif x isblocks withvalue then resultcases.IndexCodegen: indexing likenumbers(1), two-dimensionalColors(x, y)flattened bySize.Width, anderror(value), which attaches a value to anError.ListCodegen: list literals,Add/Remove, list operators, and copies for shared lists.ConversionCodegen: inserts implicitfrom/toconversions for assignments, operands and list elements.BranchValues: turns branch values into returns or loop accumulations (sum, product, list, any).CallTarget: resolves method signatures, full type names, parameter types and implicit owners of calls.CodeBlock: an immutable instruction block under construction: next register, jump ids, scope and list ownership.TestLines: separates the inline test lines of a method from its code lines.TestCodegen: builds the$Testsmethod from inline tests. It prints failures and returns the failed count.
Optimizations
ConstantFolding: inlines constants, including those of other types, and folds arithmetic on number literals.LoadReuse: drops repeated loads of an unchanged variable by reusing the earlier register.
Instruction format
InstructionEntry: one instruction (kind, names, numeric payload) with constructors and its byte encoding.InstructionType: the opcodes: loads, stores, arithmetic, comparisons, invoke, loops, jumps, list writes, print and field loads.MethodEntry: a compiled method (name, parameters, return type, instructions).MemberEntry: a compiled member (name, type, initial value instructions, constant flag).TypeEntry: a compiled type with members and methods, encoded as.bytecodebytes.BinaryNames: the per-type name table (predefined built-in names plus the type's own names) and its encoding.ByteEncoder: encodes integers, 7-bit variable-length numbers, UTF-8 texts and IEEE doubles as bytes.Register: the 64 registers of the Strict VM, namedR0toR63.
Packaging
BinaryFile: packs compiled types into a.strictbinaryzip with one<Type>.bytecodeentry per type.ZipWriter: writes uncompressed zip archives.ZipEntry: named bytes with their CRC-32 checksum.Crc: CRC-32 computed with plain arithmetic.
Runtime
Runtime is the Strict VM. It runs the instructions that FileCompiler produces, using slot-based frames and values. strict <file> and strict test call Execute.
Execute: compiles a file, checks that it has aRunmethod, converts the command-line numbers, and launches the machine or runs the tests.Machine: the VM core. Finds methods, binds members and parameters, and steps through the instructions, handling calls, indexing, printing and field loads.Frame: executes a method using an owned list of slots for registers and locals, avoiding a new frame per instruction.Resolver: resolves names to slots before execution.VmValue: the universal runtime value (kind, number, text, items) with factories and text formatting.Invocation: decodes an invoke instruction into type, method, return type, parameters, arguments and instance.ErrorCheck: detects unhandled Error values and propagates them with source stack frames.Looping: loop begin and end, keeping theindexandvaluestate for numbers, ranges, lists and texts.Operations: arithmetic and comparisons, including text and list concatenation and removing list elements.Storage: loads and stores between registers and locals, plus list appends.Natives: built-in behavior for methods without bytecode:fromconstructors,toconversions,Length, logic,in, text methods, processes and default member values.Hosted: file, directory, process andMathcalls that the Strict VM hands to the runningstrictexecutable.PayloadDecoder: decodes instruction payloads into numbers, doubles, texts, booleans, lists and ids.
Compiler
Compiler translates the linked types from FileCompiler into one MLIR module, appends the handwritten MLIR runtime, and lowers everything with mlir-opt, mlir-translate and clang into a standalone executable. The entry point is NativeBuild behind strict build, see Getting Started for all commands.
Command line and toolchain
Strict(in the repository root): thestrictcommand. Runs a file, or thetest,check,build,format,updateandversioncommands, and finds the base types next tostrict.exe.NativeBuild:strict build. Runs the tests, compiles the program (or its tests for a type withoutRun) to MLIR, builds the executables and removes the intermediate tool files.Toolchain: finds and installs the tools, lowers MLIR, links executables, and cross-builds the Linux executable through WSL.ToolRunner: finds and runs an external tool and returns itsProcessResult.Platform: the Windows, Linux and MacOS constants and detection of the current OS.
MLIR generation
MlirModule: builds the whole module from the reachable functions, globals and helpers.MlirEntry: emitsmain: starts the collector, creates the instance, parses the arguments, calls the entry method and returns the exit code.MlirFunction: translates one method into an MLIR function.MlirStatements: arithmetic, comparisons, stores, returns and jumps.MlirCalls: method calls, constructor calls, default arguments, native helper calls and printing.MlirConstants: constant values and escaped text globals.MlirInstances: creating instances, loading fields, default member values and referenced constants.MlirLayout: decides the memory layout: base type, single-member wrapper or heap struct.MlirKinds: infers which kind of value (number, text, boolean, list, type) each register holds.MlirLists: list literals, appending, indexing, element writes, copies and list operators.MlirListOperators:+,-,*and/between lists, or between a list and a number.MlirLoops: loop begin and end for ranges, counts and collections.MlirTexts: text concatenation and conversions from and to text.MlirNatives: mapsText,List,File,DirectoryandProcessmethods to runtime functions.MlirMemory: pointer and bits conversion, allocation and slot access.MlirAutomatic: generates automaticto Textfor types and lists of them.MlirEquality: generates member-by-member equality for types and lists, used byis.
Native optimizations and packages
The default fast build uses -O2; strict build <file> small uses -Os for both the program and C natives. The compiler and generated Release builds are smaller, and small can shrink them further at the cost of up to 20% slower execution on demanding paths. Getting Started explains the commands and release files. GPU code is emitted as companion .ptx files rather than embedded in the executable.
SIMD, packed numeric rows, CPU worker pools and NVIDIA PTX kernels accelerate eligible numeric loops. Neural-network and machine-learning programs are working workloads for these paths. Ordinary Number values remain doubles; stepped decimals use exact integer step counts. GPU-resident intermediate values and graph replay support larger inference workloads.
Package-local native/ C implementations link into native builds and load as shared libraries on the VM. Native builds reuse compiled C objects until sources, headers or flags change. On Windows an App.ico next to App.strict becomes the executable icon via llvm-rc; a changed icon is compiled again each build.
Native runtime, written by hand in MLIR:
NativeRuntime.mlir: the garbage collector, texts, lists, number formatting, math, files, arguments and processes.NativeRuntimeWindows.mlir: Windows memory, directories, temporary files and processes.NativeRuntimeLinux.mlir: Linux memory, directories, temporary files and processes.
Bootstrapping. Compiler/Bootstrap.mlir is Strict.strict compiled by itself. Compiler/Bootstrap.cmd (Windows) and Compiler/bootstrap.sh (Linux) combine it with the native runtime and build strict.exe (Linux: strict) in the repository root with just the LLVM tools, see Getting Started.
Shared libraries
strict build <file> library tests the exported type, emits a native shared library and generates a C# binding. The boundary carries numbers, texts, Booleans, number lists, records and lists of records; stepped parameters and results carry their decimal scale. Using APIs explains the application workflow; the compiler packages handle generation and linking.
Tools
The Strict extension for Visual Studio Code is written in TypeScript and is the main way to work on Strict code. It has no compiler of its own. Every action is a strict call with the Strict folder as root:
| Purpose | Command |
|---|---|
| Inline tests of a file (SCrunch, on open and on save) | strict test <file> . |
| Validator diagnostics for the folder of a tested file | strict check <folder> . |
| Executed-line values and hit counts | strict test <file> values |
| Suggested implementation candidates | strict suggest <file> <method> |
| Strict: Run File (Ctrl+Shift+R) | strict <file> . [arguments] |
Each call looks up the newest strict.exe again, so a rebuilt strict is used on the next save. Agents can run the same commands to verify .strict changes without VS Code. See Getting Started for the features and how to install it.
Development direction
Real projects drive the next optimizations: DeltaEngine and SoulCraft, website and application logic, neural-network training and Qwen3 inference. The compiler, runtime and editor evolve together so larger programs retain the short feedback loop you get from a small Strict method. Package READMEs record measurements; the improvements list tracks development priorities.

