Heresy: Hare programming language an alternative to C

Hare-brained. Bad Hare day. Hare no evil, say no evil ... At least it'll be a pun goldmine

On Monday, software developer Drew DeVault announced a systems programming language called Hare, describing it as "simple, stable, and robust." We've all heard that before – but there may be something in this.

More than 400 programming languages have existed at one time or another. Hare aims to serve as an alternative to C – arguably the most significant programming language of the past 50 years.

DeVault and about 30 project contributors have been working on Hare for about two and a half years. They've now let their rabbit loose so developers can run with it.

"Hare uses a static type system, manual memory management, and a minimal runtime," explained DeVault in a blog post. "It is well-suited to writing operating systems, system tools, compilers, networking software, and other low-level, high performance tasks."

In an email to The Register, DeVault wrote that Hare draws its main inspirations from C.

"I am not as dissatisfied with C as many other language designers appear to be," observed DeVault. "Hare is a conservative set of improvements over C's basic design ideas, and aims to be what C might have been if it were built with the benefit of hindsight."

DeVault revealed that Hare's standard library incorporates ideas from Google's Go programming language, specifically having enough capabilities built into the standard library – batteries included, in coding jargon – to avoid the need to import dependencies.

"The idea is to have enough batteries to facilitate many use-cases without causing programmers to reach for dependencies, while still having a manageable scope," he argued. "I think Go does this reasonably well; in fact, some Hare modules were more-or-less straight ports from Go (especially crypto)."

Hare's batteries include: a cryptography suite; networking support; date/time operations; I/O and filesystem abstractions; Unix primitives such as poll, fnmatch, and glob; POSIX extended regular expressions; a parser and type checker; and reference documentation.

Hare does not link to libc, the C standard library, by default. It's based on the qbe compiler backend. Here's what a Hare "Hello, world!" program looks like:

use fmt;
export fn main() void = {
        fmt::println("Hello world!")!;

Hare has been characterized as a stripped-down spin on Zig, which is also a low-level systems language with manual memory management. It's certainly less involved than Rust – another C alternative that has won a significant following over the past few years.

DeVault, however, describes Hare as a way to avoid C's pitfalls.

"I think that many of the languages which aim to compete with C are too far removed from it," he opined. "Hare is a conservative language that aims to distill the lessons learned from the past 30 years into a small, simple, and robust language which can be relied upon for the next 30 years. We're not concerned so much with bold innovations as we are with careful engineering."

Hare currently supports three CPU instruction set architectures – x86_64, Arm's aarch64, and riscv64 – and two operating systems – Linux and FreeBSD. According to DeVault, while there's currently no plan to support non-free platforms like macOS or Windows, a third-party implementation or fork could try to make that work.

The language remains a work in progress, as detailed in the roadmap, which is currently focused on stability for a 1.0 release and standard library enhancements like TLS and raw IP sockets support.

"I expect that in the early days much of the development will continue to be focused on the language itself," DeVault noted, "but it is already useful for … system tools like command line utilities, daemons like cron, init systems and supervisors, etc."

DeVault explained he is using Hare to write a password manager and a kernel – projects for which the language is well suited. "I think a lot of additional use-cases will open up once we have TLS support as well," he added.

Hare currently relies on the BDFL (benevolent dictator for life) governance model. "The language is designed to stabilize and remain largely unchanging, so much governance is not necessarily called for," DeVault explained, noting that there is a current fundraising effort focused on paying for a cryptography audit.

"Hare is the sum of the efforts of about 30 individuals over the course of two and a half years," said DeVault. "We've worked very hard on it, we are very proud of it, and we hope that you will like it." ®

Other stories you might like

Biting the hand that feeds IT © 1998–2022