News for hackers. Stuff that matters.
Re:Show HN: The C3 programming language (C alternative langu... by SleepyMyroslav on Saturday April 05, 2025 @11:12PM (#43598675)
A low effort question on what's C3 take on pointer provenance. Does C3 have any own take on it? Are you with C or with your implementation detail (LLVM) ?

Also if you have 'tourist guide' for gamedev people please share links or short tips. I have no idea about C replacements myself because gamedev that I know is not using C.

ps somehow in my part of the internet your blog is not accessible with cloudflare saying access denied. Do you have any copy/backup of it elsewhere?

Re:Show HN: The C3 programming language (C alternative langu... by Joshringuk on Sunday April 06, 2025 @04:34AM (#43599873)
Re:Show HN: The C3 programming language (C alternative langu... by lerno on Sunday April 06, 2025 @06:09AM (#43600307)
I don't have any particularly strong stance on provenance. But I've yet to see a strong argument for it in C.

There is not much of a guide I'm afraid. I translated some of the raylib examples to C3: https://github.com/c3lang/c3c/tree/master/resources/examples...

But those are straight up conversions of the original C code.

I think any C tutorial on gamedev would work fine to follow in C3, and then one can leverage features of C3 as desired.

Re:Show HN: The C3 programming language (C alternative langu... by SleepyMyroslav on Sunday April 06, 2025 @07:50AM (#43600745)
Judging from 'comparing pointers of different provenance' can produce 'any result' ( here https://c3-lang.org/language-rules/undefined-behaviour/#list... ) everyone has to deal with it.

More low effort questions. Question about optional debug traps: are they available in optimized builds? Are any LLVM sanitizers available? It usually means language needs to have APIs to mark up your own allocators/containers/etc.

Does language help parallel/concurrent programs to be more readable?

Re:Show HN: The C3 programming language (C alternative langu... by joshring2 on Sunday April 06, 2025 @09:43AM (#43601374)
> Question about optional debug traps

Contracts are available in safe mode, which can optionally be enabled for optimised builds as-well, yes.

> Does language help parallel/concurrent programs to be more readable?

There's active interest in working in this area, if you're interested to help you're welcome to suggest or contribute.

Re:Show HN: The C3 programming language (C alternative langu... by lerno on Sunday April 06, 2025 @07:01PM (#43605705)
I think that one is a bit wrong, I must have written it many years ago. There are machines where pointers do have different address spaces, like the Arduino obviously, but that support isn't in the language yet, and maybe there might be issues there but comparing something like `int` and `float` pointers, that shouldn't be UB. I'll look at that text.

Debug traps can be kept in optimized builds, you can always do something like "-O3 --safe=yes". Right now it's not possible to set it per function or module, but that might be added if there is demand for it.

Because C3 also has contracts, the plan is to step by step increase static analysis to catch more of the contract violations at compile time.

For example:

    <*
     @require a > 10
     @require b < a
    *>
    fn void test(int a, int b) {}
Will error at compile time for `test(5, 2)` (first @require), or `test(5, 10)` (second @require). These will also be checked at runtime, but catching low hanging fruits a compile time will be very helpful I think.

LLVM address and thread sanitizers work. The memory sanitizer still has some issues but will be fixed.

Currently there are just cross platform threads available and some rudimentary thread pools. This needs to be expanded and we'll see if there are things the language could help with but there will not be any async built in.

Re:Show HN: The C3 programming language (C alternative langu... by SleepyMyroslav on Monday April 07, 2025 @06:56AM (#43609901)
if you plan to look at pointer provenance please check recent HN discussions like this one ( https://news.ycombinator.com/item?id=42878450 ) and transitively links to source papers for C.

TLDR (imho) C has failed to define pointer provenance but had to acknowledge its existence. LLVM and GCC have their own ideas on it which means their open issues on it are different. For practical languages aiming to be useful in embedded ie Rust there are complex workarounds: https://doc.rust-lang.org/std/ptr/index.html#exposed-provena.... What is relevant for C3 is that it is likely to be exposed to open issues from LLVM and people will need practical ways to solve them.

ps Don't take my word for it. My tldr might be wrong because of my gamedev experience (like we dont ship products with GCC).

Re:Show HN: The C3 programming language (C alternative langu... by lerno on Tuesday April 08, 2025 @06:17PM (#43627029)
In C casting a pointer to an int and back again used to be fine. Except later people want to track the pointer to do optimizations and things went... poorly.

I feel that this is a mess better addressed once there are actual implementations that you have to use, rather than the current state where people are still working out the details.