News for hackers. Stuff that matters.
Re:Learning C3 by plainOldText on Thursday May 29, 2025 @10:49AM (#44126650)
Has anyone tried both C3 and Hare[1]. How do they fare? There seems to be quite the overlap between the two.

[1] https://harelang.org/

Re:Learning C3 by mustermannBB on Thursday May 29, 2025 @11:01AM (#44126779)
Problem with Hare is that it is (or at least was last time I checked) Linux/Unix only and so by design. That kinda makes it DOA for many.
Re:Learning C3 by plainOldText on Thursday May 29, 2025 @11:58AM (#44127341)
Indeed. There’s a port for macOS though.

And yet out all these newer C-like languages, it looks like Hare probably takes the crown for simplicity. Among other things, Hare uses QBE[1] as a backend compiler, which is about 10% the complexity of LLVM.

[1] https://c9x.me/compile/

Re:Learning C3 by sitkack on Thursday May 29, 2025 @12:06PM (#44127416)
QBE is an art project. Read the source.
Re:Learning C3 by orthoxerox on Thursday May 29, 2025 @01:17PM (#44128106)
I tried. It's not at Arthur Whitney's levels of terseness, but compared to the source of, say, Redis it's a pain to read.
Re:Learning C3 by lerno on Thursday May 29, 2025 @01:48PM (#44128403)
The downside of QBE is that it then requires an assembler and a linker. And QBE's only input and output is still text.

Plus the "frontend -> QBE -> assembler -> binary" process is slower than "frontend -> LLVM -> binary". And LLVM is known for being a fairly slow compiler.

Re:Learning C3 by stevefolta on Thursday May 29, 2025 @04:50PM (#44130277)
The downside of QBE is that it doesn't have a way to generate debug symbols. But I still love and use it.
Re:Learning C3 by YorickPeterse on Thursday May 29, 2025 @09:23PM (#44131918)
The most recent release has the ability to generate basic debugging information (see "new experimental dbgfile and dbgloc directives. " from the release notes) as Hare needed that (and IIRC a Hare contributor added it). Unfortunately, there's no documentation on it, and last I checked to see how to use it I had to go spelunking in the Hare source code.
Re:Learning C3 by atiedebee on Saturday May 31, 2025 @11:05AM (#44144744)
It's funny how they say they are at 10% of the code of LLVM in their marketing, when it is actually closer to 0.1%. Throwing LLVM version 20.1 through wc (just the subdirectory llvm/lib) results in 2.3 million lines for all .c and .cpp files. QBE was around 14k last time I checked.
Re:Learning C3 by alpaca128 on Friday May 30, 2025 @03:47PM (#44139361)
That and no multithreading.
Re:Learning C3 by amelius on Thursday May 29, 2025 @11:09AM (#44126849)
There's also Zig.

https://ziglang.org/

Re:Learning C3 by mapcars on Thursday May 29, 2025 @11:19AM (#44126932)
There is also Odin: https://odin-lang.org/

Would be nice to have a list of these and comparisons

Re:Learning C3 by uecker on Thursday May 29, 2025 @12:43PM (#44127772)
There is also C23 and at some point C2Y.

C23 got typeof, constexpr constants, enums with underlying type, embed, auto, _BitInt, checked integers, new struct compatibility rules, bit constants, nullptr, initialization with {}, and various other improvements and cleanups. Modern C code - while still being simple - can look quite different than what people might be used to.

C2Y already already got named loops, countof, if with declarations, case range expressions, _Generic with type arguments, and quite a lot of UB removed from the core language. (our aim is also to have a memory safe subset)

Re:Learning C3 by eacnamn on Thursday May 29, 2025 @01:03PM (#44127979)
What's the state of things regarding statement expressions? Are there any intentions of adding them? I think I've read Meneide make an offhand comment about that.
Re:Learning C3 by uecker on Thursday May 29, 2025 @01:10PM (#44128051)
This is being discussed. It has some weird corner cases and limitations though. But since it is widely used and supported, I think there is a good chance that some harmonized version of it will be standardized.
Re:Learning C3 by ksec on Friday May 30, 2025 @08:09PM (#44140897)
Interesting C2Y. I am wondering how long would it take for GCC and LLVM to implement it once it is out.

At this point may be C2Y will get to be the BetterC, given adoption or any other alternative will take far longer than expected.