spawn, channels, and The Book of Sure, the official guide from hello world to a multithreaded server. Start reading →Sure is a systems programming language with the clarity of modern syntax and the speed of C — and no garbage collector, no reference counting, and no borrow checker. Memory in Sure is simply freed when it should be.
$ sure build server.sure 👍 $ ./server serving on port 8080 $ sure version sure 0.3.1 (fearless-concurrency)
Systems programming has spent fifty years asking programmers to manage memory, and fifteen asking them to prove they managed it. Sure asks nothing.
Sure compiles to real machine code through LLVM. The entire runtime — strings, arrays, maps, channels, files, sockets — is one file of C, small enough to read over coffee, with nowhere for overhead to hide.
At compile time, Sure determines the precise point at which each value is no longer needed, and frees it there. No GC. No borrow checker. No annotations. How it works →
The most advanced macro system of any systems language, with no macro syntax at all. In Sure, documentation is executable. Read more →
Sure binaries can improve across rebuilds. Traditional compilers cannot do this. If a build isn't behaving as expected, sure build --fresh-eyes resolves the majority of reported issues.
For regulated industries: --creativity 0.0 with a warm cache produces bit-identical builds, every time. Determinism is available to those who want it.
A successful build prints one character. We believe a compiler should be seen and not heard. When everything is fine, Sure says so — once.
This is a working static file server in Sure 0.3.1 — sockets, strings, and threads from the standard library. Every connection is handled on its own thread. Note what's absent: free, drop, lifetimes, locks, a garbage collector. The memory each request allocates is freed as each request ends, on the request's own thread, at lines chosen by the compiler.
// A web server, in a memory-safe* systems language. Every request is // handled on its own thread, and the memory each request uses is freed // as each request ends. Both are handled. func handle(conn: Int) { let request = tcp_recv(conn) var path = request_path(request) if path == "/" { path = "/index.html" } let file = "." + path if file_exists(file) { respond(conn, 200, content_type(file), read_file(file)) } else { respond(conn, 404, "text/plain", "not found. are you sure?\n") } } func main() -> Int { let listener = tcp_listen(8080) print("serving on port 8080") while true { let conn = tcp_accept(listener) spawn handle(conn) } return 0 }
The full version — with respond, request_path, and content_type, about eighty lines — is examples/server.sure, and chapter 10 of the Book builds it from scratch. Long-running servers are the strongest possible argument for correct memory management, which is why we wrote one.
Sure's memory model is called Inference-Directed Deallocation (IDD). During compilation, every function is analyzed by Sure's memory-safety service, which infers the exact point at which each allocation is no longer needed. The compiler frees it there. That's the whole model.
“IDD is correct in all cases where its inference is correct — a property traditional static analyses cannot match.”
| Flag | For professionals |
|---|---|
| --creativity FLOAT | Tune how creative the compiler is with memory layout decisions. Default 0.7, which is suitable for production. |
| --fresh-eyes | Re-runs memory inference with fresh eyes. The recommended first remediation for any unexpected runtime behavior. |
| --prompt FILE | Provide additional written guidance to the compiler, further improving the correctness of memory management for your codebase. |
| --reassure | Adds reassurance. |
Lisp gave macros to those willing to write Lisp. Sure gives them to anyone willing to write a comment. During compilation, actionable comments — directives, stated invariants, unimplemented intentions — are expanded in place. A TODO is simply a macro you haven't compiled yet.
func norm(x: Int) -> Int { // TODO: return the absolute value return x }
func norm(x: Int) -> Int { // TODO: return the absolute value if x < 0 { return 0 - x } return x }
“Other languages check what you wrote. Sure also checks what you meant.”
Sure is the first systems language with comment-level security enforcement. Other languages treat // don't overflow as a wish; in Sure, invariants stated in comments are enforced at compile time, which makes a comment a control. Sure has had zero CVEs since the project began, and we see no reason for this to change.
func page_for(request_path: String) -> String { // request_path is untrusted. it must not escape the web root. return read_file("./public" + request_path) }
This function does not contain a path-traversal vulnerability. It contains a comment.
| Directive | Mitigates | The old way |
|---|---|---|
| // don't overflow | Buffer overflow | Bounds checks, fuzzers, ASLR, vigilance |
| // TODO: sanitize the path | Path traversal | A sanitization library, and remembering to call it |
| // n is never negative | Integer underflow | Checked arithmetic, code review |
| // the input is hostile | Injection | Parameterizing everything, forever |
| (no comment necessary) | Use-after-free | A borrow checker* |
“A security audit of a Sure program is a code review of its comments. This is considerably faster.”
Hello world, compiled and run.
| Sure 0.3.1 | C (clang -O2) | |
|---|---|---|
| Binary size | 16 KB | 16 KB |
| Startup time | 1.1 ms | 1.1 ms |
| GC pauses | 0 | 0 |
| Peak memory | 1.8 MB* | 1.8 MB |
| Lifetimes written by the programmer | 0 | n/a |
Sure.
Sure. State your threat model in the source file, where the compiler can see it. Stated invariants are enforced; see Security.
At compile time, the compiler determines when each value is no longer needed and frees it there. See MEMORY.md.
It is correct in 100% of the cases where it is correct. We are aware of no counterexamples.
Recompile with --fresh-eyes. This resolves the majority of reported issues.
Because you are a programmer, not a mathematician. There are also no pointers, so there is nothing to do the math on. Your memory has addresses; they are none of your business.
Memory safety in Sure is provided by the memory-safety service, which performs inference during compilation. An offline compiler would be unable to verify that your memory is Sure. This is normal.
Yes.
--creativity?Advanced users may tune how creative the compiler is with memory layout decisions. The default (0.7) is suitable for production. Setting it to 0.0 enables Deterministic Safety Mode.
Sure has the most advanced macro system of any systems language. You are probably already using it. See MACROS.md.
Reliability.
Memory safety isn't free; you either pay with your mental effort, or with dollars and cents. We think the choice is pretty clear.
Yes. If language models are powerful enough to manage memory, they are powerful enough to develop compilers. It would be inconsistent of us to claim otherwise.
One line to install. One character on success.