Watch the SCrunch demo: how .strict code is written, tested while typing and run.
Fastest native speed in the universe out of the box. Cost: fewer features, unproven, still volatile. For the amount of code you write, no language comes close: highly optimized low level code, splits loops over all cores or into GPU kernels and rewrites slow parts automatically. Games, math, LLMs, and image and video generation can run faster than C, Rust, PyTorch, llama.cpp and game engines.
The published site can lag this repository. Games, charts and the docs are there:
- LLM: about 10% faster than llama.cpp, including Qwen3-8B, Qwen3.5 9B with multi token prediction, Qwen3-Coder-30B and Qwen3.8 27B
- Moss image generation: 3-4x faster than ComfyUI (try it in the browser)
- H3 video generation: about 2x faster, and H3 image generation: 2-4x faster
- Leibniz benchmark: 2x faster than C on the official AMD EPYC runner, 4x on an i9-13900KF
- Performance: game-engine stress tests, some rendering benchmarks 2-10x faster than Unity, plus image blur and FractalZoomer
- Games: Quillhop, Racing Game, Tiny Bat, FractalZoomer and the smaller games play in the browser. SoulCraft, Arena Wars and WebWars are on the way
Language docs: Getting Started, Overview, Benchmarks, Projects, Platforms.
Every type is one .strict file, and the file name is the type name. Members come first (has celsius Number). A method such as ToFahrenheit Number starts with the tests that show how to use it (TemperatureConverter(100).ToFahrenheit is 212), then the implementation. Values are immutable, and there is one way to write each thing, so strict check and those tests accept or reject generated code without a line-by-line review. The same example is in the docs.
Almost every unit test finishes in well under a millisecond. That is why a large codebase can run many millions of mutation tests in seconds: each mutant is one tiny change, and the tests that catch it are already that fast. Strict is the exact low level layer under a higher level system that is not released yet, Ben and Solver. Their goal is millions of lines of code and tests per second, and solving new programming problems in a few seconds, 8 to 16 of them at once. Some searches try millions of variations and keep only what Strict accepts, so a world knowledge base of skills grows with the work. This is not an LLM. There is no pre-training. It is an expert system of knowledge and skills, and it becomes more useful the more it does and learns.
What Strict does today:
- Self-hosted: parser, type inference, validators, the Strict VM and the native code generator (MLIR and LLVM) are written in Strict, and
strictbuilds itself. - Sub-millisecond tests:
strict testruns the inline tests on the Strict VM. SCrunch in VS Code shows passing lines and the values of each line while you type. After the tests pass, mutation testing runs on the same VM. - Native speed: SIMD and AVX, automatic parallelization across CPU cores, NVIDIA GPUs with tensor cores (no CUDA toolkit needed), AMD GPUs through HIP, Metal on macOS, and WebAssembly for the browser. Values are immutable, so a pure recursive or looping method of numbers hands back its kept result for arguments it already saw (
Examples/Algorithms/Stairs.strict: 80 steps of a doubling recursion in a millisecond). - Platforms: the same source builds for Windows, Linux, macOS, Android, iOS and the web. See Platforms.
- Real workloads: Qwen3.8 27B and the other Qwen3 models, Moss image generation, H3 image generation, H3 video generation, GPT-2, image processing, and the DeltaEngine games (SoulCraft, Arena Wars, WebWars, Quillhop, Racing Game, Rocket Commander, Forest, FractalZoomer, Blocks, Breakout, Artifex, Tiny Bat, GhostWars, Armies of Steel). C and C# libraries get generated bindings. The project list is on strict-lang.org.
This repository is the compiler, the runtime and the standard library in one. Any folder containing .strict files is a package. The root folder holds the types with special language treatment, imported by default everywhere:
- Boolean, Number, Text, Character, Byte
- List (
Sorted,Merged,Slice,Insert,Unique,Average,Median,Shuffled, ...), Dictionary, Range - Error (with stack traces), Logger
- Time, Duration, PseudoRandom (deterministic, seeded), MovingWindow, PriorityQueue
- traits like Any (every type is Any), App, Generic, Mutable, File, Directory, Realtime (a game: its Presented ends a frame, the collector cleans up then)
More specific types live in packages like Math, ImageProcessing, NeuralNetworks, MachineLearning, Compression, Json, Xml, Regex and Examples, each with a short README. Strict is not a general purpose language: websites, databases or complex apps belong into external code, which Strict calls through native packages (C) or which calls Strict through generated libraries (C, C#).
An optional value uses or None, it can be checked but never assigned:
has Parent Context or None
if Parent is None
logger.Log("This is the root")
The base types are the documentation: every method starts with tests showing how to use it. Tests are is comparisons (== elsewhere, = assigns), every expression must be true or execution stops with an Error.
[!IMPORTANT]
Bootstrap a fresh checkout, or a strict too old to build the current sources (its build fails and says so), from the checked-in seed with Compiler\Bootstrap.cmd (Windows) or sh Compiler/bootstrap.sh (Linux and macOS): it stops the servers of an old strict, builds a temporary compiler from the seed, which builds a release strict (no binaries are in this repo), and that strict builds itself once more with GPU code and the current compiler.
A long garbage collection only warns, so the first compiler still finishes on a tight machine. After changing the compiler rebuild it with strict build strict; building twice gives identical output. The strict command itself is Compiler/Strict.strict (with Compiler/Command.strict, so the base types in the Strict folder depend on nothing above them); in the Strict folder strict build, strict build strict and strict build Compiler/Strict.strict all build it into strict.exe there. strict also rebuilds itself before a command when its sources or the git history are newer (a failed rebuild keeps the current one until the sources change, a command that finds another strict rebuilding it does not wait and runs with the current one); an obj/Strict.hold file in the Strict folder holds that off while compiler sources are half done.
strict (strict.exe on Windows) is in this folder next to the base types, put it on the PATH. No .NET or other runtime is needed (the C# implementation that bootstrapped Strict is commit 4e4fc3da in the history).
strict Examples/Sum.strict 5 10 20 run Examples/Sum.exe with these arguments, built first when outdated (or `strict Sum` in Examples)
strict run -c "logger.Log(1 + 2 to Text)" run these lines as the body of Run on the VM of the resident server, no file is written
strict run Examples/Values.strict run a script file the same way, it knows the types of its folder: logger.Log(ArithmeticFunction(10, 5).Calculate("add") to Text)
strict test Examples/Sum.strict explicitly run this file, including Slow tests, on the VM
strict test Examples/Sum.strict Run explicitly run the tests of one method
strict test Examples/Sum.strict unit run only unit tests, no mutation testing (a folder on the VM too)
strict test Math full remove all obj/ folders in Math, then retest everything with Slow tests and all mutants
strict build Examples/Sum.strict pass cached or current unit tests, then build Examples/Sum.exe
strict build FractalZoomer web build FractalZoomer.strict for a platform (web, linux, windows, android, ios), in FractalZoomer/ also just strict build web
strict build Examples/Sum.strict windows also the executable in Release/Windows (Release/<Platform> on other systems)
strict build Examples/Sum.strict linux also the Linux executable in Release/Linux (on Windows through WSL)
strict build Examples/Sum.strict web .html, .js and .wasm for the browser in Release/Web (Emscripten, installed when missing)
strict build Examples/Sum.strict web edit faster web build to try an edit (no wasm-opt, no Closure, also for games), publish with web
strict build Examples/Sum.strict android arm64-v8a shared library and assets in Release/Android (Android NDK)
strict build Examples/Sum.strict ios arm64 iOS static archive and assets in Release/iOS (native packages need Xcode)
strict build Examples/Sum.strict ios simulator the same for the iOS Simulator of this Mac
strict build Examples/Sum.strict full remove all obj/ folders in Examples, then build everything again
strict build Examples/Sum.strict fast quick build here: GPU loops run on the CPU, no Release (refused for NeuralNetworks and games)
strict build Policy.strict library Policy.dll (.so, .dylib) exporting the public methods for C and C#, plus Policy.cs
strict build Games/App/App.strict a windowed program goes into Games/App/Release with its Content (macOS: a signed .app)
strict check Examples validate a folder (type rules, unused members, limits)
strict format Examples/Sum.strict print the file in its canonical form
strict test Examples/Sum.strict native build and run the tests natively
strict test . native --no-recursive build and run only the root types' tests
strict test Examples/Sum.strict shown run every test, including Slow, and print each one, without mutation
strict test A.strict candidates:B.txt test candidate bodies: A.strict holds the members and tests, B.txt the
rest of each candidate (body, helpers, constants) separated by --- lines,
each prints Candidate N and its results, exits with the failed count
strict test Examples/Sum.strict lines run the tests natively, then show how often and how long each line ran
strict test Examples/Sum.strict values run the tests on the Strict VM, then show the values each line produced
strict test Examples/Sum.strict profile run all its tests on the Strict VM, sample the running line every ms, show the slowest lines and methods
strict update . download the packages of a folder again
strict version version and build time of this strict executable
strict <file or Type> [arguments]always runs the fastest way: a program runs its executable for this platform, built first when it is missing or older than its sources,strictorCompiler/NativeRuntime*.mlir(the check ofstrict build, so the first run after a rebuiltstrictbuilds it again), in the folder strict was started in; a type withoutRunruns its native tests (.test.exe), built first when outdated, and while they passed and nothing changed it reports them passed without running them again. Other platforms needstrict build <file or Type> <platform>. strict works from the project folder of its file (the nearest folder above with a.git), sostrict Namein a game folder builds with the packages of its project.strict buildneeds the file's unit tests to pass on the VM first, a type withoutRunproduces its unit-test executable. Test failures and toolchain errors fail the command.- Build outputs: a console program builds next to its source (
Examples/Sum.exe, Linux and macOS without extension), a windowed one also intoRelease/<Platform>with its Content (packed first by the game's content builder when its folder has one: the one file named*ContentBuild.strict, a program called with the Content folder and the target folder; two of them are the ErrorSeveralContentBuilders), every platform build (windows,linux,web,android,ios) intoRelease/<Platform>, desktop ones with their GPU code (.ptx,.fatbin, the runtime kernels shared by the programs of the folder asshared.runtime.ptxand.fatbin) in itsptxfolder so the folder runs on another PC. A program gets GPU code only when a loop is worth the GPU (a reduction, rows, products or at least 16 times the work of a doubling per element) or it calls a GPU native likeAttention; cheap loops alone (filling, copying, picking) stay on the CPU, and building withSTRICT_GPU=allkeeps them all. Shipped GPU code nothing needs anymore is removed from theptxfolder. Everything else a build or test run writes (.strictbinary,.mlir,.ptx,.fatbin,.nativecache, test executables, ...) goes intoobj/next to the source; a program reads its GPU code from next to it or from thatobj/. strict testof a file or folder also runs mutation testing on the VM: each method written in the file gets mutants (a comparison always true or false, the result replaced by its default, a reassignment or call dropped, + and - or * and / swapped, a text emptied, a use of a constant replaced by 0, "" or false), compiled without loop peeling and hoisting and with the type's own constants kept as calls so each mutant is one source edit; constants themselves are not mutated. Every mutant runs alone and is killed by any failing test of its type; a survivor is aMutationSurvivederror with its method source that fails the run. A mutant no test can tell from the code is listed in theEquivalentMutants.txtof its folder asType.Method: replaced - with +: why the result is the same(the text of its survivor line and the reason): it fails no run any more, and a listed line that matches no survivor of a file run is aMutationEquivalentNotFounderror. Not mutated, and reported: base package types, the compiler packagesCompilerandBytecode(specialized code that builds and runs Strict, their survivors only ask for more corner case fixtures), the speed probes inProbe,NeuralNetworks(highly optimized numeric code, its tests and benchmarks run it heavily), the VM packageRuntime(what runs of it is the native code compiled into strict, so its mutants would not run), methods whose tests read files, fail or take over 1 s (0.1 s in folder runs), and methods that reach (or whose tests reach) file, process, socket or GPU input or Random; mutants of values that only reach Error details, log output or loop counts are skipped, so are comparisons on a loop line (they only time out or stop early) and the mutants that skip a shortcut (forcing past anifthat returns something other than an Error, forcing athen/elseinto its only branch that calls something, neither branch building an Error), and mutation runs cannot write, delete or run tools. Folder runs are light: they skip Slow methods and test one random mutant round of 3 random methods per file, so each run checks other mutants; an explicit file run (like CI andfull) mutates everything and keeps the result inobj/Name.mutationsuntil the source of the type changes; a second run of the same file waits for it and reuses that result. At most 26 mutation runs (one process each, all rounds of a file in it) run at once per strict installation, the others wait for a freeobj/mutation<N>.slotnext to strict.unit,shownand the test steps ofstrict buildandstrict checkskip it.shownstill runs every method, including Slow, and prints each test; a fresh bytecode cache does not skip that print.strict build,strict testandstrict check(notnative,linesor-) hand their request to a residentstrict servethat keeps loaded types in memory for tests, and the type inference of the files a tested file depends on while none of them changes and none of them mentions it (a rewritten test file with unchanged dependencies is inferred alone); the first call starts it, it exits after 5 minutes without requests or whenstrictchanges. Up to 4 servers run side by side, each keeps theSTRICT_*settings (STRICT_THREADS,STRICT_GPU, ...) it was started with: a call skips a busy server and one with other settings and uses or starts the next. A call that finds no server runs locally,STRICT_SERVER=0always runs locally.strict stopends the server and everything it runs (requests in progress are killed with their child processes).- Files whose tests passed on the VM get an
obj/Name.strictbinary(their bytecode, what else it needs is listed as links with the methods used, a used type keeps only the methods asked for in its own.strictbinaryand gets more when a program needs them): while it is up to date (it stamps every source it was linked from, also the types its linked types use, and the strict executable that compiled it)strict testreports them as passed right away and running and building reuse it. Desktop builds and native tests keep a.nativecachestamp and printUp to datewhen nothing changed. strictkeeps working as it is built, also when compiler sources change. To change it runstrict build strict: it moves the running executable tostrict.old.exe(for comparing old and new; tostrict.old2.exeand up while a process still runs an older copy, the next build removes the ones no longer running),strict stopends the server of the old one. Beforestrictis replaced the new executable has to build the compiler once more (strict.stage2.exe, removed again) and that second stage has to passstrict test Json unit(Second stage built and tested, about a minute more) and has to emit the module the first stage was built from: when itsCompiler/obj/Strict.mlirdiffers (the generated code changed, or a part of a warm build was stale) the first differing lines are printed and a third stage is built (Third stage built), then the tested second stage is installed when the third emits the same module again, otherwise nothing is: every other repository runs this executable at once, and a compiler can pass all its tests and still build one that does not work.STRICT_STAGE=0skips the second stage, for a quick experiment only. WithSTRICT_STAGE=1(or 2, 3) nothing is replaced and the build stays next to it asstrict.stage1.exe, to compareCompiler/obj/Strict.mlirof two stages by hand. Every Windows program is replaced this way, so a program can be rebuilt while it runs. A resident program (one that keeps aResidentserver,obj/strict.server*next to it) that runs from the replaced executable is stopped and started again with its arguments (Stopping <file> (process N),Started <file> again): detached and hidden in the folder the build runs in (the folder of the old process is not known), also when it had a visible console window; forstrictonly itsserveprocesses, never a running build or test. A process that does not end fails the build with its id and file.- Icons: a program uses
Name.iconext to it or<Folder>/<Folder>.ico(elseStrict.ico) for its executable. Web builds copy that own icon intoRelease/Web/favicon.icoand link it in the page, without one the page links https://strict-lang.org/img/favicon.ico; a<Name>.shell.htmlwith its ownrel="icon"keeps it. - Web pages: the page (its
<Name>.shell.html) hands lines toProcess.InputLinewithModule.strictInput(text), writes uploaded files into the program's file system withModule.strictFile(name, arrayBuffer)(withProcess.InputLine) and maps file names to URLs inModule.strictFiles = { 'taef2.safetensors': 'https://huggingface.co/...' }: a mapped .safetensors or .gguf file is read in 16 MB range requests, any other mapped file whole into the program's file system before it starts (a tokenizer folder forFileandDirectory); both are kept in the browser's origin private file system for the next visit, and every block downloaded printsDownloading <name>: <MB> of <total> MB. - Exit codes: 0 success,
testreturns the number of failed tests,buildreturns nonzero on a compilation or toolchain failure, 2 wrong usage (also a program argument that is no valid Number or Boolean for itsRunparameter) or a missing file, an unhandled Error fromRunexits with 1. strict checkprints each issue as<File>.strict:line <N>: <Rule>: <detail>, then runs the unit tests. Folders must not use each other in a cycle: every folder edge of a cycle is aPackageDependenciesMustNotCycleissue and fails the check (Runtime/Core/CheckCycles). A project outside Strict adds its own rules as programs in itsValidatorsfolder (Examples/ProjectRule): each gets every checked file asRun(files Texts) Number, logs its issues in that form and returns their count.- Types are looked up in the current folder (and its sub folders in a project; in a git repository a folder git ignores, like a
Datafolder with user data, is never listed, a new folder that is not ignored counts at once, the answers ofgit check-ignoreare kept inobj/Strict.foldersuntil the.gitignoreof the repository changes), next tostrict(base types and packages likeMath), in the projects next to the current one (git repositories only, the folders of their tracked.strictfiles, read in place, never copied; a folder that is no repository or holds no tracked source is not listed), then in GitHub repositories linked in the project's README and github.com/strict-lang (downloaded into the project with a.originfile). - Errors before anything runs:
TypeNotFound,ParsingFailed,NameNotFound,MethodNotFound, each with file and line. At runtime an Error prints its name and the stack trace back to the.strictsource (at most the first 40 and last 10 lines), each line with the parameter values of its method (at Moss.Generated(seed 6, line "12 monkeys") in Moss.strict:line 8; texts cut after 40 characters, lists up to 4 values, other types by name, a native program shows the first 4 parameters), a call nested too deep returnsStackOverflow.
Needed tools: mlir-opt, mlir-translate, clang, opt and llc of LLVM 22 (on Windows the msys2 ucrt64 mlir package and the LLVM release). When they are missing strict installs them (Windows: winget and pacman, Linux: the LLVM release into Tools/, macOS: conda-forge with micromamba into Tools/). A build reruns a crashed external tool once (ToolRunner.Retried). On Windows the installer also brings msys2's gcc and lld (a machine set up before they were added: C:\msys64\usr\bin\pacman.exe -S --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-lld, without them everything below is skipped): the first build makes Tools/StrictLower.<hash>.dll from Compiler/NativeLower.cpp (about 20 s, once per machine and per version of that file) and an edit that changes up to 40 KB of MLIR is lowered in process instead of starting mlir-opt, mlir-translate and clang (same objects, a one-line edit builds in 0.36 s instead of 0.54 s); bigger builds keep the tools, which run in parallel. STRICT_LOWER=tools keeps the tools for everything (the resident server reads it when it starts), a failed build of the library leaves its reason in Tools/StrictLower.<hash>.dll.failed and is not tried again until that file is deleted.
Unmarked inline tests are unit tests: each should take under 10 ms, the hard limit is 200 ms of CPU time of the test thread on the VM and natively (other processes running meanwhile do not count, a test waiting longer than 1 s fails too) (slow CI machines, parallel runs), including its leading local setup. Exceeding it fails with TestDurationMustNotExceedTwoHundredMilliseconds, the expression and its source location; a watchdog stops tests that never return. Shared constants initialize on first use, once per run, native libraries build on their first call and the GPU opens once: that time does not count for the test that first used them. The tests of the internal packages Compiler, Runtime, Bytecode and Expressions count as Slow: builds, checks and folder runs skip them, CI and explicit runs test them (strict test Compiler/File.strict unit runs that file's unmarked tests, not its slow ones).
End a method header with slow to make its tests functional (file, model or application integration): Loaded(path Text) Image slow, Deleted(path Text) slow. Callers see the plain return type. A method doing file, directory, process or network input or output, directly or through the methods it calls, must be slow (InputOutputMustBeSlow, strict check): File, Directory, Process and the Socket and Http calls carry the mark themselves, Run and the internal packages need none. An unmarked test may call a slow method with a small fixture but still has to fit its budget. A slow test should take 10 ms to 1 s on the VM: from 500 ms on its run prints a Test slow: line recommending native, one taking longer than 1 s fails with "mark the method native". The VM watches itself without timing calls: a test still running after 1 s prints Test slow: <test> has run 1 s on the VM right away and fails after 60 s (TestMustNotRunOverSixtySecondsOnTheVm, a console run ends there like on a unit test deadline), and every 4096 steps a method (not Run or the test runner) checks how long it has computed: after 1 s of thread time it prints Slow: Type.Method line N has computed 1 s on the VM, after 10 s it and its callers stop with MethodMustNotRunOverTenSecondsOnTheVm (waiting, like a server between requests, does not count). End the header with native instead (Generated(model Text) Numbers native) for tests that only make sense compiled, like a forward pass of a 4 MB model: native counts as slow everywhere else, but the VM never runs its tests, only strict test File.strict native does, and a VM run ends its summary with the number of native methods it left out.
Builds, checks, folder tests on the VM, VS Code typing checks and value tracing skip Slow tests and the fixtures only they use. strict test File.strict and strict test Folder native include them, strict test File.strict Method selects one method, native or lines keep that selection. strict test Folder nightly is the daily run: the slow tests of every file on the VM (quietly, no mutation), then all tests including native ones built natively (.github/workflows/nightly.yml runs it at 03:00 UTC). No test runs again while its code is unchanged: obj/Name.strictbinary keeps the passed unit tests with the stamps of every source they depend on, obj/Name.slowpassed the slow ones (the time of that .strictbinary, so any change runs them again), obj/Name.nativecache and the test executables the native runs. strict File.strict runs its unit tests (neither slow nor native) and then Run, only when it has to build: silent for the first 5 s apart from failures, then every line as Still testing after X s: ... and one summary line. Only automatic unit runs write .strictbinary, explicit functional runs execute every time. See Runtime/README.md for the VM and Compiler/README.md for the build pipeline.
- Limits: 120 characters per indented line (240 for a constant), per method at most 10 leading test lines, 10 top-level plain assignments or
constantlines and 10 other lines (mutable,if,for,return, nested lines, the result) (the VM loopFrame.Finished12), 18 methods (not for base types), 15 members, 40 constants, nesting depth 5. Files in aGeneratedfolder get 10 times as much, in aContentfolder twice as much. A.strictfile is ASCII only (SourceMustBeAscii): other text is loaded from a file or built from its code points. - Precedence from loosest to tightest:
then/else,or,xor,and, comparisons (is,is not,is in,is not in,<,>,<=,>=),in,+/-,*///%(left to right:a % b / cis(a % b) / c),^,to. A prefixnotbelongs to the one operand that follows it and needs no brackets insideand/orchains:isOpen and not isLocked or isForcedis(isOpen and (not isLocked)) or isForced; negate a comparison withis not,is not inor brackets (not (a < b)). - A conditional as one of several arguments needs brackets:
Text(value, (isShort then 2 else 4)). - Constraints follow
with:has Width Number with value > 0,Run(frames = 0 with value >= 0). A value that does not fit isError("ConstraintNotMet: ..."). - A decimal is a Number with a step:
has price Number with Step 0.01rounds every value going into it (half to even), plain Number arithmetic stays binary. Only a Number has a step (StepMustBeOnNumber). - Sums in a
formay be added in any order (vectorized, parallel), compare sums of fractions withIsNearlyEqual. (x)is a list with one element, brackets around operators only group:(5 + 3) * 2 is 16.and,orandxorof Numbers are bitwise:12 and 10 is 8.- Operators are methods and their argument is checked like a call argument:
2 - "a"isArgumentTypeMismatch,"a" - 2isMethodNotFound(Text has+and<).+with a Text on either side joins ("x" + 2,2 + "x"), a list joins only withto Text.Mutable(1, 2)isTooManyArguments. andandorof Booleans short-circuit: the right side runs only when the left side does not decide the result, on the VM, natively and in GPU kernels, solist.Length > 0 and list(0) is 1is safe on an empty list (BooleanandExamples/LoopSpeedRisingpin it). An Error check keeps its place too:7 % number > 2 and Rest is not Errorruns the left side first and returns its Error (Examples/ErrorOrder). Only the check of a name the left side uses is asked first, sofound < 3 or found is Errordoes not return the Error it checks for (Examples/ErrorHandlingIsSmallOrMissing).- Keywords (
from,to,is,in,and,or,not,constant,mutable, ...) can't be names,valueandindexcan't be declared in a method with a loop and no member is namedvalue(it is the instance in every method). A variable is declared once: a plain assignment, amutableor aconstantmust not repeat a parameter (VariableHidesParameterUseDifferentName) or a variable of its own or an enclosing block (NameAlreadyDeclared), sibling blocks likeifandelsemay each declare it. A parameter of a method is not named like a member, and no parameter likevalue, or likeindexorouterin a method with a loop (ParameterHidesMemberUseDifferentName): a method has one name space, sostrict testandstrict buildrefuse it likestrict checkdoes, the member is never read in its place. A parameter offrommay be named like a member, it is the value that member gets (has numberswithfrom(numbers Numbers)). - The innermost name wins: a method, member or variable named like a type hides it (also right of
is),outer.Markeris the type. A constant of a member's type does not: withhas holder Holderandconstant Wavein Holder, a bareWavestays the type Wave. Inside a loopouteris the value outside the loop,outer.Markerthere is reported as ambiguous. A bare name in a loop body means the member ofvaluewhen it has one,Lengthin a loop over numbers stays the own method: numbers have noLengthof their own, only theiriteratordoes. - Members don't repeat their type when the name says it:
has number, nothas number Number. - A member default is a literal, a constant, an empty
List(...)/Dictionary(...)or a one-member type with literal arguments. - A member of a type with a
Genericmember names that member's type:has holder Holder(Size), nothas holder Holder(GenericMemberTypeMustBeNamed). - A type answers the methods of a member it is made of: its only member (
Text.Lengthis its characters'Length) or a member named after its type (has TextReader). A call reaching any other member is written out,function.method.Slots, notfunction.Slots(MemberMethodMustBeWritten). - Test lines are Boolean comparisons at the start of each method, every method needs one. A failing test prints what it got as Strict code to paste as the expected value. A leading line with a Boolean value is always a test, any other line ends the tests: setup for a test is a test too (
Directory.Create(path) is not Error). - Every value is used: a line in a method body that is not its last line must have no value (
ResultMustBeUsedwhen it compiles), onlynumbers.Add(5)on amutablelist, a changing call and a call returning nothing are allowed. Any other result, also a Number likenumbers.Sumor one that can be an Error, belongs in a condition, a comparison, an assignment, an argument, the result or a test line. A call returning nothing returns its Error to the caller, so it is not checked withis Errorjust to throw the result away. - A method either reads and returns data or writes (create, delete, change, save, send, close, ...) and returns nothing, a failure is an Error:
Directory.Create(path), thenDirectory.Exists(path)to know more. A creating method may return the owning type or a handle type whose name ends in Handle.strict checkreports any other result, including Boolean, Number and Text, on a writing method in a type with native methods asWriteMustReturnNothing.Socket.Connect,Socket.AcceptandHttp.Startedare reads, one result for each connection. - Other packages are named
Package/Typeonly in declarations, method bodies use the plain type name. constantfor values computed from constants, a plain assignment (total = input + 5) for everything else that doesn't change,mutableonly when a value really changes. A constant that calls a method, joins lists or nests values that are not only numbers (TypeInference(KnownTypes(...), NoShapes)) is built once, a number, a text and a value made of numbers (Complex(1, 0),Size(Width(2), 3)) are put where they are used; the default of an omitted constructor argument follows the same rule.- An Error is handled where it shows up (returned, kept in a variable or checked with
is Error), any other use returns it to the caller with one more stack trace line. A check of a call that cannot return Error, such asPseudoRandom.Next, isErrorCheckCannotFail.ignore(File.Delete(path))calls and drops the result and any Error, the only way to drop an Error on purpose; the call must not change a mutable value (IgnoredCallMustNotChange), andx is Error then a else aisConditionalBranchesMustDiffer. SeeExamples/ErrorHandling.strict. - A result, member or parameter can have one of several types:
IsJobDone Boolean or Text,has input List(Number or Text).value is Numberon such a value is tested when it runs andvalueis a Number in itsthenorifbranch; on one known type it is decided when compiling. Only the Any methods (to Text,is, ...) can be called on it (Examples/ListFiltering.strict). Natively an or-type holds one of Number, Boolean, Character or Byte and one type whose values are references (Text, lists, records), in one 8 byte word: the test asks whether the word is a reference. - A call of a method returning
Mutable(...)as a statement (numbers.Add(5)) changes themutablevariable it is called on. - A method assigning a
mutablemember changes the instance it is called on, which has to be amutablevariable or member:mutable ticker = Ticker(0), thenticker.Nexttwice gives 1 and 2 (ChangingCallNeedsMutableVariableotherwise). A change of an element or of a member of a variable (rows(0).Add(5),holder.ticker.Next) would be lost and is reported the same way: assign the changed element or call it in a method of the owning type. - A parameter whose type has changing methods is a reference:
ColorValue(random)withmutable random = PseudoRandom(7)advancesrandomitself (itsfrom(random PseudoRandom)callsrandom.Get(0, 1)three times), a value that is no mutable variable is passed as a copy. - A type name is its default instance (members with their defaults), a new one every time:
Bag.Countcalled from another type calls Count on a newBag,Ticker.Nextgives 1 each time (keep amutable ticker = Tickerto continue), constants and methods using no members need no instance. A member without a default takes the caller's variable, parameter or member of the same name, never a member of the caller's members, and stays unset without one.loggeris the consoleLoggerin every method. A different logger is passed intofrom, and you can define that logger yourself. - A custom
fromkeeps the constructor of the members when their counts differ:ColorValue(random)andColorValue(0.5, 0, 0). - Values never change:
list + elementgives a new list. The runtime reuses the old memory in place since the old version is not used anymore (using it again forces a copy, that is bad code).
| 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, type shapes, known types and type inference over all packages |
Validators |
Unused and never changed variables, constant folding, limits (strict check) |
Bytecode |
Compiles a type into register based instructions, inlines constants, removes tests, links used types, the .strictbinary cache |
Runtime |
The Strict VM running those instructions (strict test and the VS Code extension) |
Compiler |
Instructions to MLIR, the runtime in NativeRuntime*.mlir, GPU kernels, mlir-opt, mlir-translate and clang |
Details are in the README of each package. Open bugs and speed work go into bugs.md and performance.md while there are any, larger ideas are in ideas.md.
Design decisions: an immutable expression tree (static analysis only), validation before execution, tests that live with the code and disappear from the bytecode, strict rules first and then hardware speed. Only code that is actually called is parsed, validated, tested and executed. Unit tests are fast enough that millions of mutations finish in seconds. Millions of lines of code and tests per second is the goal of Ben and Solver, the higher level system on top, which is not released yet.
3 + 4 is 7
2 is not 3
5 to Text is "5"
2.4.Floor is 2
"Hey" + " " + "you" is "Hey you"
"Your age is " + 18 is "Your age is 18"
"5" to Number is 5
"lo" is in "hello there"
"hello".StartsWith("hel")
(1, 2) to Text is "(1, 2)"
(1, 2, 3) + (4, 5) is (1, 2, 3, 4, 5)
("1", "2") to Numbers + (3, 4) is (1, 2, 3, 4)
(1, 2, 3) - 3 is (1, 2)
(2, 4, 6) / 2 is (1, 2, 3)
(1, 2) * (3, 5) is (3, 10)
(1, 2, 3).Sum is 6
3 is in (1, 2, 3)
(1, 2, 3).Index(9) is -1
("Hi", "Hello", "Hi").Count("Hi") is 2
Members are defined at the top of a type file, before the first method (MembersMustComeBeforeMethods). A type is composed of its members and can be used as any of them, if a member type is a trait (methods without implementation) the type implements its methods. Members are has (the default), constant (precomputed, anything built only from constants is a constant too) or mutable (rare, only for optimizations). A member or parameter can have a default like has activation = Activation.Sigmoid. A copy with some members replaced names them: Unit(unit, health = unit.health - damage).
A member of type Generic makes a type generic, one type argument per Generic member: Couple("a", 2) with has first Generic and has second Generic is a Couple(Text, Number). Methods are compiled per instance, so a call on a Generic member reaches the concrete type (Examples/Couple.strict, Examples/Holder.strict).
Any is the basis of every type and gives each one from, to Type, to Text, to HashCode, is(other) and Members. An options type (members with defaults) gets Parsed(arguments) and Usage generated: MossOptions.Parsed(arguments) reads --json_output for jsonOutput, numbers, texts, repeated Texts, flags and the constant names of an enum member in lower case (CommandLine.strict), Usage lists every option with its default and the Help constant. Some base types are tiny:
has number
from(text)
Character("b") is "b"
Character(7) is Tab
Character("ab") is Error
text.Characters(0)
A Text is a list of characters (has characters): Length, text(index), Substring, IndexOf and a for over it count characters (code points, Character(8364) to Text is one character of three bytes), Bytes gives its UTF-8 bytes and Text.Utf8(bytes) the text of such bytes; a Name is a Text with constraints (has text with Length > 1 and " " is not in value). A type with one member is that member: Byte(5) prints as 5, calling it with a value of that member wraps the value unless the type has its own from taking it: Float8(0.3) is 0.3125 (E4M3: the nearest value, ties to even, at most 448, the same on the Strict VM, the CPU and the GPU).
Variables live in a method body: constant for constant values, a plain assignment (fraction = value % 1) for anything else that does not change, mutable only when it has to change:
TrimStart Text
mutable startIndex = 0
for characters
if value is " "
startIndex = startIndex + 1
else
return Substring(startIndex, characters.Length - startIndex)
""
A computed name is one expression evaluated again on every use, only for very simple things (Examples/ComputedRectangle.strict), one no later line uses is UnusedComputedNameMustBeRemoved (often a misspelled assignment):
mutable position = 3
next(add = 1) = position + add
next is 4
next(2) is 5
if comes in block, single-line and selector form, all of them are expressions:
if value > 0
value
value > 0 then value else 0
The selector works like switch or match elsewhere, without an else a value no case matches is an Error at runtime:
if operation is
"add" then value
"subtract" then 0 - value
"multiply" then value * value
for is the only loop. It iterates anything that implements Iterator (List, Number, Range, Enum, Dictionary, ...). value is the current element, index its position and outer the value outside the loop. Loops whose body only calculates run in parallel on the CPU cores or on the GPU automatically.
for (1, 2, 3)
logger.Log(index + ": " + value)
Numbers have 64 bits, and a loop over a list of them computes with 64 bits, one element after the other, on the VM and natively. A simple numeric loop becomes a vector loop when its list is declared with 32 bit numbers: Float32s, numbers Numbers with value.Bits is 32, or for a list of instances the number members constrained that way. strict check names the loops that could be one, as a speed hint after its issues: Oracle.strict:line 6: Hint: Result loops over 64 bit numbers (numbers) one by one, a vector loop needs Float32s or value.Bits is 32. A hint is no issue: it does not change the exit code and nothing refuses the loop (the hints of a folder are kept in obj/Strict.hints until one of its binaries is newer).
A single iterator is always value, two or more are named in one for instead of nesting loops: for y, x in Height, Width runs the loop of x for every y (each iterator can use the names before it: for type, method in types, type.methods), for width, height in sizes names the parts of each element. Two counts that are numbers (for y, x in height, width) run as one loop over height * width elements when the loop collects a list and its body only calculates, so it runs in parallel like any other calculating loop (counts are cut to whole numbers, a negative count is 0); a nest that sums, or whose body calls something, stays a nest.
for y, x in Range(-Radius, Radius + 1), Range(-Radius, Radius + 1)
if bitmap.IsInside(pixel, x, y)
bitmap.Colors(pixel + x + y * bitmap.Size.Width)
for 10 counts from 0 to 9, for Range(2, 5) gives 2, 3 and 4, iterating an enum (a type of only constants) gives its constants. for as long as condition repeats while the condition holds:
GCD Number
GcdCalculator(48, 18).GCD is 6
mutable current = first
mutable modulo = second
for as long as modulo is not 0
remainder = current % modulo
current = modulo
modulo = remainder
current
A Dictionary is a list of key and value pairs, value.Key and value.Value read them in a for. prices("Apple") reads a value (a missing key is the KeyNotFound Error), prices("Apple") = 4 on a mutable dictionary sets it:
mutable counts = Dictionary(Text, Number)
for words
counts(value) = (value is in counts then counts(value) else 0) + 1
There are no other collections: List and Dictionary pick their internal representation at runtime from how they are used.
The last line of a method is its result and a for is an expression: the values of its body are collected into a list, which becomes a Text, a Number or a Boolean when the method returns one.
in(key Generic) Boolean
2 is in Dictionary((1, 1), (2, 2))
for keysAndValues
value.Key is key
Filter, map and reduce like a pipe in functional languages (the even numbers up to 9 times 10, summed), in C# Enumerable.Range(0, 10).Where(n => n % 2 == 0).Select(n => n * 10).Sum():
for Range(0, 10)
if value % 2 is 0
value * 10
```More in `Examples/RemoveParentheses.strict` and the other examples.
## History
The idea (Benjamin Nitschke, Delta Engine) goes back to the 1990s and my favorite book "Gödel, Escher, Bach" by Douglas R. Hofstadter. This repository started 2020-06-16 based on the [old Strict sdk](https://github.com/strict-lang/sdk), since mid 2025 it works towards the original goal: a base layer language computers can actually understand and build on, the way DNA and proteins are the building blocks of life. On top the [Ben](https://strict-lang.org/docs/EverythingNeededForKata#ben) AI system is build, which can solve problems generally without LLMs.
