September 30, 2022

COSFONE

Networking, PBX, IT, DIY Solution

Hare: A new systems programming language and competitor of C language

3 min read

Hare: A new systems programming language and competitor of C language



 

Hare: A new systems programming language and competitor of C language.

Developer Drew DeVault has announced Hare , a new systems programming language . 

Hare, which has been in development for nearly two and a half years, uses a static type 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 all programs written in C can also be written in Hare, but Hare is simpler than C.

Hare’s Hello World 

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:

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 and provides good performance in a small footprint.

Hare Status

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

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

 

Hare’s OpenGL bindings are in the works and are currently available for several small games, such as Tetris:

Hare: A new systems programming language and competitor of C language

 

Simple ray tracer written in Hare :

Hare: A new systems programming language and competitor of C language

 

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 like poll, fnmatch, and glob
  • POSIX extended regular expressions
  • Hare parser and type checker

 

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

 

Hare future

Hare is currently under conservative development. The biggest task of the standard library is to complete the implementation of cryptography.

The primary goal is to support TLS ( Transport Layer Security ) 1.2 and TLS 1.3. Once at version 1.0, Hare will finalize the language specification, freeze the language design, and make only backwards-compatible changes to the standard library.

 

In addition, Hare currently only supports three architectures : x86_64, aarch64 and riscv64, and support for 32-bit platforms and other architectures will be gradually added in the future. In terms of operating system, Hare currently  only supports Linux and FreeBSD , and plans to do more porting in the future.

We have no intention of supporting non-free platforms, but since the language is standardized, third-party implementations or forks can easily develop Windows or macOS support if needed.

 

 

More information on Hare’s plans can be found on the roadmap .

 



You may have missed