|
|
Log in / Subscribe / Register

DeVault: Announcing the Hare programming language

DeVault: Announcing the Hare programming language

Posted May 2, 2022 16:16 UTC (Mon) by wtarreau (subscriber, #51152)
In reply to: DeVault: Announcing the Hare programming language by ddevault
Parent article: DeVault: Announcing the Hare programming language

> Here's some string-heavy code for your consideration:
>
> https://git.sr.ht/~sircmpwn/hare-irc
> String manipulation and manual memory management goes together like oil and water. I think we've done a pretty good job nevertheless,
> and you can do most string operations relatively comfortably.
>
> https://docs.harelang.org/strings
> https://docs.harelang.org/regex
> https://docs.harelang.org/fmt

Thanks Drew for sharing. However I had already looked at these ones. For example what's not obvious to me is how strings and memory mix together. I.e. if I want to write a variant of base64 output whose max output size I already know based on the input, am I supposed to use concat() between strings for every character or may I just create a string of suitable size and fill the chars a-la "*(p++) = c" since I know what I'm doing ? Don't get me wrong, I love the approach of "trust the programmer", especially since nowadays a non-negligible number of bugs are induced from trying to work around absurd warnings or non-sensical UB, resulting in unnatural code that easily breaks. I'm just curious to know how that mixes as I do imagine it's not a trivial thing.

> >I don't know if it also forces to change every single line of code when using an alternate implementation of a lib
> It does not; vendoring is very straightforward and does not require any rewriting of the code. You can also trivially vendor modules
> from the standard library.

OK, fine!

> >That said it's strange that cross compiling is still in the roadmap, given that by now it should be well known that cross-compiling
> > should be the default approach and native compiling just a special case of it.
> This is in fact how it works in Hare, we just have to glue a few pieces together to make it useful. You can compile Hare code to any
> supported arch like so:
>
> $ harec -X^ -T+riscv64 example.ha | qbe -t rv64 > example.s
> $ as -o example example.s

That's fine then!

> But generally Hare programs are not built like this - they're built by invoking the build driver, hare(1), which is just currently
> lacking the convenience flags to glue all of the bits together. Also missing is the non-trivial considerations for handling sysroots
> when linking to native C libraries, though thankfully most Hare programs don't link to C.

OK so in practice it does support cross-compiling, it's just that it's not trivial to use right now. That's much less of a problem, because usually when cross-compiling is not supported, it stems from reasons having their roots very deeply burried. Here's it's mostly a UI issue in fact.

Thanks for the clarifications.


to post comments

DeVault: Announcing the Hare programming language

Posted May 2, 2022 16:22 UTC (Mon) by ddevault (subscriber, #99589) [Link] (3 responses)

>I.e. if I want to write a variant of base64 output whose max output size I already know based on the input, am I supposed to use concat() between strings for every character or may I just create a string of suitable size and fill the chars a-la "*(p++) = c" since I know what I'm doing?

Here's some sample code that might answer your question:

https://paste.sr.ht/~sircmpwn/ba2f1f110c6d3e0a6e16c496af0...

Try changing the buffer size to 16 and run it again - the runtime will detect the overflow and abort.

DeVault: Announcing the Hare programming language

Posted May 2, 2022 16:26 UTC (Mon) by wtarreau (subscriber, #51152) [Link] (2 responses)

But this one seems to be using a pre-existing base64() function, my question was rather from the function's implementer point of view. In fact, do I still have the ability to fill a buffer one byte at a time and cast it in return saying "this is my string" (possibly with a required size prefix or any such thing to accommodate for internal needs) ?

DeVault: Announcing the Hare programming language

Posted May 2, 2022 16:31 UTC (Mon) by ddevault (subscriber, #99589) [Link] (1 responses)

I'm still not sure how to answer your question generally, but:

>In fact, do I still have the ability to fill a buffer one byte at a time and cast it in return saying "this is my string"

https://paste.sr.ht/~sircmpwn/7ce10cda33c51304974b324e3b6...

Does that tell you what you want to know?

DeVault: Announcing the Hare programming language

Posted May 2, 2022 16:33 UTC (Mon) by wtarreau (subscriber, #51152) [Link]

> https://paste.sr.ht/~sircmpwn/7ce10cda33c51304974b324e3b6...
>
> Does that tell you what you want to know?

Looks so, thank you :-)


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds