Salivo for Visual Studio Code
Write safe native code without the ceremony. Salivo is a compiled language with no garbage collector, no manual free, and no lifetime annotations, and a standard library that already includes a web server, SQL databases and a UI framework. Install, press Ctrl+F5, ship a 12 KB executable.
pub func main() -> int {
outln("Hello, Salivo!");
return 0;
}
|
|
| ~0.3 s |
cold build of a program |
| ~40 ms |
full type check (sf check) |
| 12 KB |
the hello world executable above |
| 0 |
packages to download for a web server, a database or a game |
Why developers pick Salivo
Memory safety without the fight. Values free what they own when they leave scope. There is no garbage collector pausing your program, no borrow checker to argue with, and no manual cleanup. Reading past the end of a list stops with a clear message instead of corrupting memory:
panic: Vec::get index 5 out of bounds (length 1)
Safety checks that never get in your way.
- Live errors as you type, from the language server, with no setup.
sf check type-checks a file in about 40 ms, so you can run it on every save.
salivolint --deny turns every warning into a build failure, one flag for CI.
- Errors are values:
Result and Option, with postfix ? to pass an error up in one character, and match that must cover every case.
SALIVO_OVERFLOW_CHECKS=1 makes unchecked integer overflow panic, and checked and saturating arithmetic is built in.
spm check-layout keeps a project's structure honest.
Cleanup you cannot forget. Implement Drop once and files, sockets, database connections and locks are released at a known point, every time.
Instant feedback. Builds take about a quarter of a second. Run an unchanged program again and it starts in milliseconds from the run cache.
Tiny native executables. No runtime to install and nothing to bundle. The code goes through LLVM, so it runs at native speed.
Everything in the box. HTTP/1.1 and HTTP/2 server, PostgreSQL, MySQL and SQLite, JSON, regex, compression, cryptography, async tasks and channels, a reactive WebAssembly UI framework, and a 2D and 3D game engine. No package manager dance to get started.
One language for the whole stack. spm new site --template fullstack gives you a native server and a browser UI, both written in Salivo, served from one origin.
A compiler written in Salivo. It builds itself and the result is verified bit for bit, so what you install is what was tested.
Kiln: our own backend (in development)
Salivo hands final code generation to LLVM today. We are building Kiln, a code generator and linker written in Salivo, to become the default backend: faster builds (the compiler builds itself in about 6 s on Kiln versus about 30 s on LLVM), smaller executables, and checks only a compiler that owns the whole path can make. You can already try it:
SALIVO_BACKEND=kiln sf run hello.sal
sf build app.sal --deny net,process # fails the build if the program can reach the network or spawn processes
When a program breaks the rule, the compiler names the call chain that does it. Kiln is opt-in and not finished. LLVM stays the default for now and will remain available as an option afterwards, so use it for anything you ship today. Details in the SDK README.
What it looks like
module main;
><salivo.std.core::{Result, ok, err};
><salivo.std.collections::{Vec, vecNew, push, veclen, get};
pub struct Item { name: string, price: int }
func parsePrice(text: string) -> Result<int, string> {
if (len(text) == 0) { return err<int, string>("empty price"); }
return ok<int, string>(text:int);
}
func total(items: Vec<Item>) -> int {
let mut sum = 0;
for (let mut i = 0; i < veclen<Item>(items); i = i + 1) {
sum = sum + get<Item>(items, i).price;
}
return sum;
}
func run() -> Result<int, string> {
let mut cart = vecNew<Item>();
cart = push<Item>(cart, Item { name: "tea", price: parsePrice("12")? });
cart = push<Item>(cart, Item { name: "cake", price: parsePrice("30")? });
return ok<int, string>(total(cart));
}
pub func main() -> int {
let r = run();
if (r.is_ok) { outln($"Total: {r.value}"); } else { outln("error: " + r.error); }
return 0;
}
No imports of a web framework, no build file, no free. One file, one command: sf run cart.sal.
What the extension gives you
- Live diagnostics, hover and go to definition from the Salivo language server.
- Run in one key.
Ctrl+F5 saves and runs the file.
- Build, check, format, lint and test from the editor: native executable, type check without code generation,
salivofmt, salivolint and spm test.
- Highlighting for the whole language, including stream imports (
><), string interpolation ($"...") and postfix modifiers like {name:trim:upper}.
- Snippets for functions, structs, enums, traits,
Drop, loops, match, error propagation, collections and web routes.
| Command |
Shortcut |
| Run file |
Ctrl + F5 |
| Build native executable |
Ctrl + Shift + B |
| Check syntax and types |
Ctrl + Shift + K |
| Format document |
Shift + Alt + F |
| Lint |
Ctrl + Shift + L |
Get started in a minute
Install the Salivo toolchain.
Windows (PowerShell):
irm https://raw.githubusercontent.com/Serion89/salivo-sdk-public/main/get.ps1 | iex
Linux:
curl -fsSL https://raw.githubusercontent.com/Serion89/salivo-sdk-public/main/get.sh | sh
Open a .sal file and press Ctrl+F5.
Start a project: spm new app, or spm new api --template web, spm new site --template fullstack, spm new game --template game.
Both installers check the SHA-256 of the download before installing.
Settings
| Setting |
Default |
Description |
salivo.lsp.enabled |
true |
Enable the language server. |
salivo.lspPath |
(from ~/.salivo/bin) |
Custom path to salivo-lsp. |
salivo.executablePath |
(from ~/.salivo/bin) |
Custom path to sf. |
salivo.formatterPath |
(from ~/.salivo/bin) |
Custom path to salivofmt. |
salivo.linterPath |
(from ~/.salivo/bin) |
Custom path to salivolint. |
salivo.packageManagerPath |
(from ~/.salivo/bin) |
Custom path to spm. |
salivo.enableExecCache |
true |
Reuse compiled binaries so unchanged programs start instantly. |
Links