Developer Drew DeVault has announced a new system programming language, Hare, which has been in development for nearly two and a half years and uses a statically typed system, manual memory management and a minimal runtime, making it ideal for writing operating systems, system tools, compilers and other low-level, high-performance tasks.

According to Drew DeVault, Hare is most similar to C, and almost any program written in C can also be written in Hare, but Hare is simpler than C.

Hare’s Hello World

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
use fmt;

export fn main() void = {
    const greetings = [
        "Hello, world!",
        "¡Hola Mundo!",
        "Γειά σου Κόσμε!",
        "Привет, мир!",
        "こんにちは世界!",
    ];
    for (let i = 0z; i < len(greetings); i += 1) {
        fmt::println(greetings[i])!;
    };
};

Hare computes its own SHA-256 hash.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
use crypto::sha256;
use encoding::hex;
use fmt;
use hash;
use io;
use os;

export fn main() void = {
    const hash = sha256::sha256();
    const file = os::open("main.ha")!;
    defer io::close(file);
    io::copy(&hash, file)!;

    let sum: [sha256::SIZE]u8 = [0...];
    hash::sum(&hash, sum);
    hex::encode(os::stdout, sum)!;
    fmt::println()!;
};

Hare is based on the qbe compiler backend, which provides good performance in a small footprint.

Hare Status

There are already many programs based on the Hare programming language, such as

  • Himitsu: a key management and password storage tool. It stores keys as key/value pairs and allows storing additional information, such as username, host and protocol.
  • Helios: Microkernel for x86_64 systems.
  • box: A simple CLI encryption tool.
  • btqd: bittorrent daemon.
  • hare-libui: libui bindings for simple GUIs.

Hare’s OpenGL bindings are a work in progress and are currently available for several small games, such as Tetris.

Hare Tetris

Simple raytracer written using Hare.

raytracer

The Hare Standard Library contains the following standard components, which provide support for many use cases without any dependencies

  • Cryptography suite
  • Network support
  • Comprehensive date/time manipulation
  • I/O and file system abstraction
  • Unix primitives such as poll, fnmatch, and glob
  • POSIX extended regular expressions
  • Hare parser and type checker

This standard library frees Hare from the legacy of POSIX and libc, and Hare programs are not linked to libc by default.

The Future of Hare

Hare is currently under conservative development, and the biggest task of the standard library is to complete the cryptographic implementation, with the primary goal of supporting TLS (Transport Layer Security) 1.2 and TLS 1.3. Once it reaches version 1.0, Hare will complete the language specification, freeze the language design, and only make backward-compatible changes to the standard library.

In addition, Hare currently supports only three architectures: x86_64, aarch64, and riscv64, with support for 32-bit platforms and other architectures to be added over time. For operating systems, Hare currently only supports Linux and FreeBSD, with plans to do more ports in the future.

We do not intend to support non-free platforms, but since the language is standardized, third-party implementations or branches can easily develop Windows or macOS support if needed.

More information about the Hare program can be found on the roadmap.