What's Different From Traditional Programming
For programmers coming from C, Python, and everything else.
What 4.0 changes
Here's what's new in 4.0:
- The compiler is written in Sanguis, and it compiles itself. Every smoke test checks that the result matches, byte for byte.
- There's a second kind of cell, the system cell. It works with 64-bit integers, compiles to machine code, and can be loaded from any language that can call C.
- The same toolchain runs inside web pages and gets the same answers.
- The compiler's source comes in the kit, so you can read it yourself.
The circuit grids are back in 4.0, running the same 3.9 engine: wire, truth, trace, vana, grid, press, insert, play, pulse. Fleets also run on every core now, with the same output as on one.
If you've written code in C, Python, or most anything else, Sanguis works differently. Here's how.
What changes coming from C or Python
Control flow
Sanguis has the control flow you know: if/else, while, and cells are functions. Loops are written with while and for item in list. Branches use if/else and when. There's no switch (chain if/else instead) and no goto. strain gives you tagged data, break exits a loop, resume continues it, and close ends a spawned task.
Data types
| Traditional | Sanguis |
|---|---|
| int, float, double | float (floating-point numbers) |
| string | string |
| bool | true and false, and 0.0 and 1.0 read the same way |
| struct with methods | organ with fields and cells |
| int[], arrays | list, written [1.0, 2.0, 3.0] |
Organs are Sanguis's structs. They have fields and cells, and the compiled file carries a description of them.
Assignment
Inside cells, you assign directly: let x = 5; and x = x + 1;. On the graphics card, an organ's field is a wire. Writing to it drives the wire, and reading it senses the wire.
Parallel by default
Most languages run one line after another. In Sanguis, fleets run on every core at once: each cell ticks in parallel, and messages arrive on the next tick in the order they were sent.
| Traditional | Sanguis |
|---|---|
| Sequential execution | Fleets split across every core, same bytes as one core |
| Shared mutable state + locks | Snapshot semantics, no races |
| Threads, async, goroutines | Not needed: a fleet is the parallel unit |
| Manual synchronization | The engine handles it via sweep snapshots |
At the start of a tick, every cell sees the same picture. A message one cell sends doesn't arrive for the others until the next tick, so cells can never race each other.
One kernel, programs as data
A compiled program is text you can open and read. The same file runs the same on Windows and Linux, and the compiler rebuilds itself to the same bytes, which sanguis verify checks on your machine.