Blorp by Example
A concise path through the language, from small runnable programs to systems features.
How To Read This Guide
Each page sticks to a short set of subheads and one focused example. The early pages favor code you can run with blorp run or blorp test.
hello.brp
func main(args: List[String]) -> Void:
print("Hello, world!")
Foundations
- Hello, Blorp
main, printing, running a file, and exit codes. - Values and NamesInferred bindings, annotations, immutable names, and
varrebinding. - Expressions EverywhereLast-expression returns,
ifvalues, statement conditionals, and loops. - FunctionsParameters, return types, helpers, recursion, and
@tailrec. - Pure Functions
pure func, local mutation, effect boundaries, and pure callbacks. - Strings and TextInterpolation, chars, raw strings, triple strings, and common methods.
- Method SyntaxMethod-style calls, chains, imports, and field access precedence.
Core Data
- ListsLiterals,
append,get,length, iteration, and COW-friendly rebinding. - Option
Some,None, no null,match,get_or,map, andand_then. - Result and Try:
Ok,Err, predictable failure,?=, and Option-to-Result. - Records and StructsNamed fields, record update, and struct value types.
- Unions and EnumsVariants, payloads, enums, and explicit states.
- Pattern MatchingVariants, literals, tuples, list patterns, wildcard, and exhaustiveness.
- Dictionaries and Sets
Dict,Set, lookup asOption, counting, grouping, and insertion order.
Program Structure
- Imports and ModulesPrelude, selective imports, qualified imports, modules, and visibility.
- GenericsType parameters, inferred type params, containers, and reusable helpers.
- TraitsStandard traits, bounds, operator traits, and implementing traits.
- Testing
TestSuite, assertions, running tests, and organizing examples. - DoctestsDocstrings, named doctests, and examples as API contracts.
Working Programs
- Input and CLI Arguments
args,input, EOF asNone, stderr, and exit codes. - Files and Paths
read_file,write_file,path.join, andResulthandling. - Processes and EnvironmentEnvironment variables, process helpers, and shell safety.
- JSON, CSV, and Codec ValuesParse, inspect, validate, and encode.
- Building a Small CLI App
argparse, pure core, impure shell, and tests.
Safety and Runtime Model
- Memory by ExampleValue semantics,
ARC/COW, aliases, and closure capture. - Debugging and Diagnostics
check, formatting,debug:, and compiler errors. - Concurrency
concurrent:, task results, timeouts, and cancellation points. - Channels and Pipelines
Channel[T],send/recv,close, and channel iteration. - Parallel Collection WorkPure callbacks,
List.parallel(), and collecting results.
Numerics and Systems
- Numbers and Safe Arithmetic
Int,Float, sized numbers, wrapping defaults, and checked helpers. - Vectors, Matrices, and Tensors
Float[#3], compile-time bounds, dot product, and matrix basics. - Dimension Safety
#N, dimension-preserving functions,where, andassert_shape. - Performance Tools
--profile, benchmark hygiene, instrumentation, and generated C. - FFI Preview
foreign func, C ABI, purity/safety modes, and package boundaries. - Where to Go NextStd tour, examples, tests, architecture docs, and contribution paths.