Vlad-Ștefan Harbuz

The Hare Programming Language

Hare is a systems programming language, which means it’s useful for building video games, operating systems, real-time audio applications and other high-performance software. It’s designed to be a replacement for C, by keeping that language’s simplicity and power, but bringing significant innovations that allow users to write better, more correct programs while also having more fun programming.

Hare was designed by Drew DeVault, and I’ve had a lot of fun being part of the core development team. I’ve written parts of the standard library such as math::, regex::, the arithmetic and textual parts of datetime::, graphics support libraries such as hare-gl, linear algebra library hare-glm, as well as other contributions to the language and documentation.

Let’s look at an example that shows some of Hare’s most important features.

Firstly, you’ll notice the match statement, which is a good example of tagged unions. Tagged unions allow Hare variables to have one of multiple possible types. In this case, regex::find returns (void | []matchgroup | error), which means that either no match was found (void), or we have a set of matches ([]matchgroup), or there was an error (error).

By using the match statement, we can have our program handle all of these cases differently. You might notice we’re not handling error explicitly, though. This is because it’s being handled by the exclamation mark at the end of the function call: regex::find(...)!. Since this is a simple example, we want to abort if regex::find returned an error. The ! operator calls abort() if the value of the preceding expression is an error, which is exactly what we want.

Hare has many more wonderful features — I invite you to read the announcement blog post, then have a look at the tutorial. If you have any questions, find me and other members of the Hare community in IRC!

OpenGL support from scratch in Hare.