Algebraic types, native binaries,
and no garbage collector.
An ML-family language whose compiler is written in itself. Errors are values, every match is checked for exhaustiveness, and memory is reference counted with reuse rather than collected.
use Http;
use Json;
struct Repo { name: String, stars: Int }
// A decoder is a value. Composing decoders composes their error paths,
// so a failure five levels down still names all five.
let repo (): Json.Decoder[Repo] =
Json.map2(
Json.field("name", Json.string()),
Json.field("stargazers_count", Json.int()),
|n, s| Repo { name: n, stars: s })
let main (): Unit =
match Http.get("http://api.github.com/repos/bradcypert/plum") {
Err(e) => println("request failed: ${e}"),
Ok(res) => match Json.decode_string(repo(), res.body) {
Err(e) => println("bad payload: ${e}"),
Ok(r) => println("${r.name} has ${r.stars} stars"),
},
}What it is
- It is self-hosted
- The compiler is written in Plum, and builds itself. Nothing in the toolchain needs another language;
clangassembles and links what it emits, and that is the only requirement. - No garbage collector, no manual frees
- Memory is reference counted with reuse analysis, in the Perceus tradition. A dying cell is written into rather than freed and allocated again.
- Errors are values
- No exceptions, and no early
return. A function that can fail says so in its type, and the compiler will not let you forget a case. - It talks to the operating system
- Sockets, HTTP, processes, files, time, terminals. The standard library is ordinary Plum over a small set of C shims, and its reference is generated by
plum doc.