Package request: Zig programming language
Zig is a general-purpose programming language designed for robustness, optimality, and maintainability. It is a natively compiled (using LLVM backend) language which plays nicely with musl (so building for Alpine should be not that hard) and integrates easily with existing C code and libraries, allowing to export the C interface of the Zig library as well.
Some distributions already packaged Zig: https://repology.org/project/zig/versions
Just yesterday Zig 0.5.0 version was released (the requirement is LLVM/Clang-9.0 and above) with many various improvements. See also the comparison with C, C++, D, and Rust languages.
This is how Zig example program looks like:
const std = @import("std");
test "switch on error" {
const result = parseInt("hi", 10) catch |err| switch (err) {};
}
fn parseInt(buf: []const u8, radix: u8) !u64 {
var x: u64 = 0;
for (buf) |c| {
const digit = try charToDigit(c);
if (digit >= radix) {
return error.DigitExceedsRadix;
}
x = try std.math.mul(u64, x, radix);
x = try std.math.add(u64, x, digit);
}
return x;
}
fn charToDigit(c: u8) !u8 {
const value = switch (c) {
'0'...'9' => c - '0',
'A'...'Z' => c - 'A' + 10,
'a'...'z' => c - 'a' + 10,
else => return error.InvalidCharacter,
};
return value;
}
P.S. GitLab seems do not support Zig language syntax highlight, while GitHub does: https://github.com/ziglang/zig/blob/master/lib/std/base64.zig