Live data from Hacker News

Show HN: The C3 programming language (C alternative language)

github.com

161–170 of 192 posts

Re: Show HN: The C3 programming language (C alternative language)

#162
post #156
post #152

Earlier quoted context omitted.

You could still do it as a userland feature and implement add/sub/mult/div as methods on the type.

That never works as well as having it built into the compiler.

You can define your own "built-ins" types and functions(!) so that should make it indistinguishable.

You can also extend the standard Library from inside your own project, modules are open for extension

Re: Show HN: The C3 programming language (C alternative language)

#163
post #157

Earlier quoted context omitted.

Personally I think it is reasonable that a C alternative is an alternative to C, and not a C++ alternative. C3 uses a temp allocator that removes a large number of cases where C++ would need RAII to manage memory. Did you try C3?

Does it just deallocate at the end of a scope? Why go halfway? It's obviously valuable and destructors are not complicated. Destructors can also close files, sockets, deallocate buffers from the GPU, etc. I think when people want C semantics they will just use C in general, but if there is something that solves these extreme pain points in a simple way it might be enough to get someone to switch.

Yes the temp allocator will remove things at the end of it's scope. It makes it very clear when memory will be affected and gives predictable code execution.

There are other contexts for managing mutex locks so they auto close and you could dream up one for database connections and transactions too.

The nice things about a context is you can always see it's there, destructors by design are a bit hidden which can make code harder to reason about.

Re: Show HN: The C3 programming language (C alternative language)

#164
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 language)

#165

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 acc…

@lerno is a ganedev himself so should be able to answer your question there

Some links

https://c3-lang.org/getting-started/

https://c3-lang.org/getting-started/design-goals/

https://c3-lang.org/faq/compare-languages/

The blog is on the internet archive https://web.archive.org/web/20250330145704/https://c3.handma...

Re: Show HN: The C3 programming language (C alternative language)

#166

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 acc…

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 language)

#167
post #166

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 acc…

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 fe…

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 language)

#168
post #150

Earlier quoted context omitted.

And you're saying that a modules are instances of structs? Meaning functions in modules are non-static methods?

modules are struct namespaces, so they create a compile time type. modules (might not mean the same as module in any other given lang) ⊂ imports ⊂ structs ⊂ namespaces ⊂ types

Right, that's what I thought. So object member lookup and module/namespace lookup are not the same thing

Re: Show HN: The C3 programming language (C alternative language)

#169
post #166

Earlier quoted context omitted.

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 fe…

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. Doe…

> 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 language)

#170
post #168

Earlier quoted context omitted.

modules are struct namespaces, so they create a compile time type. modules (might not mean the same as module in any other given lang) ⊂ imports ⊂ structs ⊂ namespaces ⊂ types

Right, that's what I thought. So object member lookup and module/namespace lookup are not the same thing

Depends. Your module can have top level member fields or declarations. (By convention these modules would be capitalized) and in that case it would be instantiated as a struct (no objects in zig)

MyModule.zig

   somefield: u32,

   fn get(self: @This()) u32 {
      return this.somefield;
   }
main.zig

   const Module = @import("MyModule"); // note there are build parameters necessary to make this a module

   fn main() void {
     var x: Module = .{.somefield = 42 };

     _ = x.get() // => 42

     ...

A module is an import external to your project. Whether or not the import has top level fields or declarations, the mechanism is the same for structs, imports, and modules. For all imports (including modules) you should imagine an implicit `struct{...}` expression surrounding the code in your file.
Post reply on HN