Hare

There is a port [hare-lang](https://www.freshports.org/devel/hare/), but as Drew DeVault answered my question "Just want to know - is this port official hare distribution and is it updated?": *"We do not maintain downstream packages. It's official if that's an official source for your distro."* So I found a good [manual](https://space.matthewphillips.info/posts/installing-hare-freebsd/) on how to do this from repos: There are 4 total things you need to install to get Hare working on FreeBSD, 2 pre-requisites and 2 Hare packages. It's possible that you already have the pre-requisites setup, in which case you can skip the step, but they are uncommon enough that I'm including them here. I did the installation in a fresh jail for isolation, but of course you can install where ever you like, the steps are the same. **Initial setup** First you'll need git: ``` pkg install git ``` Since we're installing from source, we need somewhere to put the source, so I created /usr/local/src ``` mkdir -p /usr/local/src cd /usr/local/src ``` Now we can start building packages. **Pre-requisites** **QBE** [QBE](https://c9x.me/compile/) is a compiler backend used by Hare. First clone the repository: ``` git clone git://c9x.me/qbe.git cd qbe ``` Then build and install: ``` make make install cd .. ``` **scdoc** scdoc is a man page generator, first clone: ``` git clone https://git.sr.ht/~sircmpwn/scdoc cd scdoc ``` scdoc uses syntax in its Makefile not supported by BSD make so you'll need gmake: ``` pkg install gmake ``` Then use gmake to build and install: ``` gmake gmake install cd .. ``` **Hare** Now with the prereqs you can install Hare itself, first the bootstrap compiler: ``` git clone https://git.sr.ht/~sircmpwn/harec cd harec ``` Copy the FreeBSD config from the configs folder: ``` cp configs/freebsd.mk config.mk ``` Then build and install: ``` make make install cd .. ``` Last up is the main package: ``` git clone https://git.sr.ht/~sircmpwn/hare cd hare ``` Like last time, copy over the FreeBSD build config: ``` cp configs/freebsd.mk config.mk ``` Before building, Hare depends on `as`, an assembler, which you can get from binutils: ``` pkg install binutils ``` And with that you should be able to build and install: ``` make make install cd .. ``` **Hello world** First, let's do a simple Hello world. ``` echo 'use fmt; export fn main() void = { fmt::println("Hello world!")!; };' > main.ha ``` Which you can now run with the `hare run` command: ``` hare run main.ha ``` It will take a second the first time, but you should then see the print out. To build to an executable use the build command instead: ``` hare build -o helloworld main.ha ./helloworld ``` And that's it, I hope this is helpful for FreeBSD users out there.

6
0

What do you think about Hare? I think it takes best from different languages, intentionally or not... It is simple like C, but safer, and at the same time allows you ~~to shoot yourself in the foot~~ to take control and make mistakes if you want. Example from [this](https://harelang.org/blog/2021-02-09-hare-advances-on-c/) blog post two years ago: ``` fn io::write(s: *stream, buf: const []u8) (size | io::error); // ... sum += match (io::write(s, buf)) { case let err: io::error => match (err) { case unsupported => abort("Expected write to be supported"); case => return err; }; case let n: size => process(buf[..n]); yield n; }; ``` Expression-based syntax and match statements remind me of Rust, but it implemented simpler without options... Maybe you already used Hare in your project. Interesting to read your feedback... Do you like it? Why?\ Dislike? Why?

5
6
youtu.be

Interview with the creator of the Hare programming language.

2
2