Announcing the Hare programming language April 25, 2022 by Drew DeVault

Hare is a systems programming language designed to be simple, stable, and robust. Hare uses a static type system, manual memory management, and a minimal runtime. It is well-suited to writing operating systems, system tools, compilers, networking software, and other low-level, high performance tasks.

Here is my favorite example program, which computes its own SHA-256 hash:

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()!;
};

We have been developing Hare in private for about two and a half years, and have decided that it’s now time to offer it to you to play with. Hare is a reasonably (though not entirely) complete programming language that you can pick up today and start writing interesting and useful systems software with. If you’d like to try it out, check out the installation procedure, then the Hare tutorial.

Hare is most similar to C, and almost all programs written in C can also be written in Hare. Hare is simpler than C, however.

In the meantime, let me tell you why Hare is special.

Introducing Hare

I will be hosting a talk on Hare at Techinc in Amsterdam on Wednesday, May 4th at 19:00 local time. You’re welcome to join us in person, or watch the live stream:

Bootstrapping Hare

Anyone who has bootstrapped LLVM or GCC will be pleased to find that our process is much simpler. You can watch the whole bootstrapping process live here. This clip is not sped up.

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

Some batteries included

The Hare standard library has what we feel is the “correct” number of batteries. It has a small, fixed scope, but also offers support for many use-cases without having to reach for any dependencies. This includes:

The standard library is a fresh start for systems programming, divorced from the legacy problems of POSIX and libc. Hare programs don’t link with libc by default.

haredoc

We are also pleased to inform you that our standard library includes comprehensive reference documentation, which is conveniently available to you online, or in your terminal emulator.

Cool projects using Hare

We have already started using Hare in some of our own projects. Here’s a few of my favorites. Check them out — or contribute to them!

Himitsu: a password store & secrets manager

Himitsu is a secret manager and a password store. It stores secrets as key/value pairs, allowing you to store additional information like usernames, hosts, and protocols alongside each pair. Himitsu is also designed to accomodate a number of different “agents”; for example, it will be able to store your SSH private key and act as an SSH agent.

Helios: a microkernel for x86_64

Helios is a micro-kernel for x86_64 systems, and will ideally support other architectures in the future (we already have another working kernel for RISC-V, for example). It’s pretty basic at the moment — it can boot to long mode, has a couple of serial drivers, and sets up paging. There’s a lot of work to be done, but this is a great project for demonstrating Hare’s ability to do low-level work.

A screenshot of a page fault in Helios

OpenGL support

OpenGL bindings for Hare are underway, and have been used for a couple of little programs already:

The following projects are underway in this space:

A simple raytracer has also been written in Hare:

A raytraced scene of colored balls

More interesting projects

There are a lot of other projects being written in Hare, with varying degrees of workitude. Here’s a few more:

Maybe you’d like to help finish some of these?

Future plans for Hare

We intend to develop Hare conservatively, so that you can depend on it to be reliably useful for your projects without spending much headache on keeping up with the language itself. Once we reach version 1.0, we’re going to finalize the specification, freeze the language design, and only make backwards-compatible changes to the standard library.

In the meantime, we have some things to do. Presently, Hare only supports three architectures: x86_64, aarch64, and riscv64. We want to expand this, adding 32-bit platforms and other architectures. We also only support Linux and FreeBSD today, and want to do more ports in the future. We have no intention of supporting non-free platforms, but because the language is standardized, a third-party implementation or fork could easily develop Windows or macOS support if desired.

The largest to-do item for the standard library is the completion of our cryptography implementation. Our target is to support TLS 1.2 and TLS 1.3.

You can see more details about our future plans on the roadmap.

We need your help

We need your help! We are looking for volunteers to work specifically on the following focus areas:

We also need general assistance working on things like our new self-hosted compiler, refining the standard library, and of course, expanding the fledgling Hare ecosystem. You can also support us financially on our Open Collective:

https://opencollective.com/hare

We have a specific fundraising goal for conducting a third-party audit of our cryptography implementation:

https://opencollective.com/hare/projects/cryptography-audit

However, if we are successful at raising funds, we will apply it to other difficult problems, such as the development of our cryptographic suite and new Hare ports.

Try it out!

We hope that you’ll like Hare. Our goal is to build a supportive community of people helping each other build great programs in our language. Consider joining our community on IRC and our mailing lists on SourceHut.

Again, If you’d like to try Hare, check out the installation procedure, then the tutorial. Have fun!

Your humble hosts

I want to extend a quick note of appreciation to everyone who has helped with Hare so far.

Thanks, everyone!