Strict Programming Language

Strict Programming Language

  • Games
  • Performance
  • VS Code
  • Docs
  • Blog
  • GitHub

›Source

Documentation

  • Overview
  • The VS Code Experience
  • Getting Started
  • Platforms
  • Built with Strict
  • Cheat Sheet

Language

  • Types
  • Members and Variables
  • Decimals and Exact Values
  • Methods
  • Tests
  • Statements and Expressions
  • If
  • For
  • Lists and Dictionaries
  • Errors
  • Keywords
  • Grammar

Rules

  • Coding Style
  • Code Validations
  • Naming

Source

  • Base Types
  • Architecture
  • Examples
  • Machine Learning
  • Benchmarks

More

  • Using APIs
  • Concurrency
  • Microservices

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.

How Strict code becomes a program

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.

Strict layers: VS Code and strict on top of the Strict packages

PackageResponsibility
root typesNumber, Text, List, Dictionary, Error, File, ... define the language and are its documentation, Strict is the strict command
ExpressionsTokenizer, syntax tree, statements, header tokens, type shapes, known types, and type inference over all packages
ValidatorsUnused and never-changed variables, names, constant folding, limits (ValidateCheck behind strict check)
BytecodeCompiles a type into register-based instructions (FileCompiler), inlines constants, removes tests, links used types, writes .strictbinary
RuntimeThe Strict VM that runs those instructions (Execute behind strict <file> and strict test)
CompilerNativeBuild behind strict build: instructions to MLIR, the native runtime (texts, lists, files, processes, collector), then mlir-opt, mlir-translate and clang
VS Code extensionEdit, test, check and run .strict files, all through strict

How a program is compiled

  1. SourceFiles collects the .strict files of the current folder and its sub folders, then the base types and packages next to strict.exe, see how strict finds types.
  2. Expressions reads type shapes and method headers, parses each method body into a syntax tree, and infers the type of every expression across all packages.
  3. Bytecode compiles the entry type into register-based instructions. Constants are inlined and folded, inline tests are removed (or collected into a $Tests method for strict test), and the Linker adds only the methods of other types that are actually called.
  4. Then either Runtime runs the instructions on the Strict VM (strict <file> and strict test), or Compiler translates 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.

NativeBuild.strict in VS Code: the compiler pipeline written in Strict

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. Error values carry a tag in the top bits, so x is Error works for a value of any type.
  • A type with one member is that member: Name is its text, Degrees its number. Members declaring value.Bits is 32 round to 32-bit precision on construction, on the VM and natively. Native Vector2 and Size pack two 32-bit floats into one 64-bit slot, and types of 3 to 16 32-bit numbers like Vector3, Vector4 and Quaternion use 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 returns Mutable.
  • TypeShape: analyzes a type's lines: members, methods, parameters, constants, enum values, traits and generics.
  • MethodBodies: flattens method bodies into scoped statements, tracking declarations and value, index and outer.
  • 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 and then … else, and finds to and from conversions.
  • 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 or value member 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: the check entry 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 computed has members that should be constant, plus UsageRules for every method.
  • UsageRules: per-method rules for unused variables and parameters, names that hide members, mutable values that never change and mutable parameters.
  • Limits: line length, nesting, tab indentation, method length, and method and member counts.
  • Names: rejects keywords as names, names starting with List, and constants named like a type or a method.
  • ConstantCollapser: folds constant subexpressions (arithmetic, text concatenation, and/or, to conversions).
  • ValidationIssue: one issue (rule, target, message), printed as RuleName: 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 .strictbinary bytes.
  • SourceFiles: collects the .strict files of the source folder and the packages it references.
  • TypeCodegen: compiles a type's lines into a TypeEntry: 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 … else and operator methods of custom types.
  • LoopCodegen: for loops over ranges, counts, iterators and nested loops, plus the implicit sum, product, list and any results.
  • SelectorCodegen: selector if x is blocks with value then result cases.
  • IndexCodegen: indexing like numbers(1), two-dimensional Colors(x, y) flattened by Size.Width, and error(value), which attaches a value to an Error.
  • ListCodegen: list literals, Add/Remove, list operators, and copies for shared lists.
  • ConversionCodegen: inserts implicit from/to conversions 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 $Tests method 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 .bytecode bytes.
  • 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, named R0 to R63.

Packaging

  • BinaryFile: packs compiled types into a .strictbinary zip with one <Type>.bytecode entry 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 a Run method, 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 the index and value state 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: from constructors, to conversions, Length, logic, in, text methods, processes and default member values.
  • Hosted: file, directory, process and Math calls that the Strict VM hands to the running strict executable.
  • 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): the strict command. Runs a file, or the test, check, build, format, update and version commands, and finds the base types next to strict.exe.
  • NativeBuild: strict build. Runs the tests, compiles the program (or its tests for a type without Run) 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 its ProcessResult.
  • 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: emits main: 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: maps Text, List, File, Directory and Process methods to runtime functions.
  • MlirMemory: pointer and bits conversion, allocation and slot access.
  • MlirAutomatic: generates automatic to Text for types and lists of them.
  • MlirEquality: generates member-by-member equality for types and lists, used by is.

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:

PurposeCommand
Inline tests of a file (SCrunch, on open and on save)strict test <file> .
Validator diagnostics for the folder of a tested filestrict check <folder> .
Executed-line values and hit countsstrict test <file> values
Suggested implementation candidatesstrict 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.

Last updated on 10/22/2026 by Benjamin Nitschke
← Base TypesExamples →
Docs
The VS Code ExperienceGetting StartedPlatformsBuilt with StrictLanguage GuideCheat SheetCoding Style
Source
Base TypesArchitectureExamplesQwen3 and Machine LearningC and C# Interop
More
BlogGitHubIssuesVS Code ExtensionWebsite SourceStar
Copyright © 2000-2026 Benjamin Nitschke