Getting Started
From download to your first program
Prerequisites
A computer running Windows 10 or newer, or Linux, with about 50 MB free. You don't need a graphics card. On Linux, have gcc and bash installed, because the kit builds a small piece of itself there.
Installation
Grab whichever one suits you from the Sanguis 4.0 downloads page. They all hold the same kit.
- On Windows, run sanguis-4.0-setup.exe. It installs into your user folder, and afterwards you can type sanguis anywhere.
- Or unzip sanguis-4.0-windows-x86_64.zip wherever you like. The Windows and Linux tools are both inside.
- On Linux, run sh sanguis-4.0-linux-x86_64.run. Add --prefix=DIR if you want it somewhere else.
Before you run anything, compare it with SHA256SUMS.txt. If the numbers match, the file is exactly what we put up.
Check the kit
sanguis verify
Give it about two minutes. It runs real programs and checks their answers. Then the compiler builds a new copy of itself and compares the two, byte for byte. When you see VERIFIED and VERIFIED, everything on your machine works.
The Sanguis compiler is written in Sanguis. That last step means the compiler on your computer can rebuild itself and get the exact same file back. Nothing went missing on the way to you.
Hello World
Make a file called hello.sanguis and put this in it:
circuit hello;
cell main() -> float {
print("hello from the 4.0 toolchain kit");
output 0.0;
}Then compile it and run it:
sanguis bleed hello.sanguis sanguis drip hello.bc
You'll see:
hello from the 4.0 toolchain kit 0
bleed turns your program into BloodCode. That's a plain text file, so you can open it and read it. drip runs it, starting at the cell called main. The 0 at the end is what main gave back with output. In a hurry? sanguis drip hello.sanguis does both at once.
Arithmetic
circuit add_test;
cell main() -> float {
let a = 1.0;
let b = 2.0;
print(a + b);
output 0.0;
}You'll see:
3 0
You get +, -, * and /. Dividing by zero gives 0.0 instead of crashing. Math is worked out from left to right.
Machine cells
Some cells run straight on your processor, with no interpreter in between. The kit has a demo with ten of them, each with an answer we already know:
sanguis bleed examples\cellsdemo.sanguis cellsdemo.bc sanguis blob cellsdemo.bc cellsdemo.mod blobrun cellsdemo.mod
blobrun: 10 tests, 0 failures