Hare programming language

Just noticed that their website says support for Haiku is planned!

https://harelang.org/platforms/

5 Likes

I think it’s worth mentioning some progress is being made there.
https://harelang.org/documentation/install/#supported-platforms

Latest release:

New to Hare’s list of supported platforms is NetBSD, thanks to the hard work of Mallory Adams – who is now counted among the upstream maintainers of Hare to ensure this target remains in good working order for the foreseeable future. This expands Hare’s platform support to include all three major BSD derivatives – NetBSD, OpenBSD, and FreeBSD – and Linux.

Can anyone find the license terms to any of either Hare or the QBE backend it uses? It doesn’t seem to be posted anywhere on the c9x.me webpage.

EDIT:

The Mac version on GitHub lists the license terms.

From a casual “Frequently Asked Questions” browse -

Can I use multithreading in Hare?

Probably not.

We prefer to encourage the use of event loops (see unix::poll or hare-ev) for multiplexing I/O operations, or multiprocessing with shared memory if you need to use CPU resources in parallel.

It is, strictly speaking, possible to create threads in a Hare program. You can link to libc and use pthreads, or you can use the clone(2) syscall directly. Operating systems implemented in Hare, such as Helios, often implement multi-threading.

However, the upstream standard library does not make reentrancy guarantees, so you are solely responsible for not shooting your foot off.

Doesn’t say what the issues would be. C doesn’t have a lot of intrinsic support for threads, but I don’t think a C authority would say “probably not” to that question. I would expect problems if there’s a runtime that handles memory allocation etc., but it sounds like it doesn’t have that. I don’t know. Anyway, that’s the main reason I’m drifting away from Ocaml lately, because while it can run the Haiku interface window threads, it can’t really run them fully concurrently because they need exclusive access to the runtime while running Ocaml code. So it can get stuck in one thread, and then windows don’t get redrawn etc.

There sure are a lot of languages in the works these days.

I think most C standard libraries are re-entrant, though it may require some OS specific support. Newlibc (used for embedded C) requires a bit of work to get re-entrancy supported for things like the print functions and memory allocation, but it’s pretty easy to do. For newlibc you have a few different options, their docs suggest you carry some state around in each thread and add some code to your scheduler, but you can also just override all the memory allocation functions with re-entrant ones from your RTOS and replace the printf family with one that doesn’t do heap allocation for float printing.

Personally I would hesitate to learn a new language that doesn’t support multi threading… but it’s always good to see new development on haiku!

The QBE (MIT licensed) backend that Hare uses may be worth more than the Hare language itself. It implements static single-assign architecture (SSA) like LLVM but doesn’t have “kitchen sink disorder” feature lists like LLVM has. There are some patches in QBE that will allow it to use 32-bit processors as well as 64-bit soon whenever they clear the backlog of 30+ proposed patches in the patch list.

2 Likes