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

https://news.ycombinator.com/rss Hits: 16
Summary

C3 Language C3 is a programming language that builds on the syntax and semantics of the C language, with the goal of evolving it while still retaining familiarity for C programmers. It's an evolution, not a revolution: the C-like for programmers who like C. Precompiled binaries for the following operating systems are available: The manual for C3 can be found at www.c3-lang.org. Thanks to full ABI compatibility with C, it's possible to mix C and C3 in the same project with no effort. As a demonstration, vkQuake was compiled with a small portion of the code converted to C3 and compiled with the c3c compiler. (The fork can be found at https://github.com/c3lang/vkQuake) Design Principles Procedural "get things done"-type of language. Try to stay close to C - only change what's really necessary. C ABI compatibility and excellent C integration. Learning C3 should be easy for a C programmer. Data is inert. Avoid "big ideas" & the "more is better" fallacy. Introduce some higher level conveniences where the value is great. C3 owes its inspiration to the C2 language: to iterate on top of C without trying to be a whole new language. Example code The following code shows generic modules (more examples can be found at https://c3-lang.org/references/docs/examples/). module stack {Type}; // Above: the parameterized type is applied to the entire module. struct Stack { usz capacity; usz size; Type* elems; } // The type methods offers dot syntax calls, // so this function can either be called // Stack.push(&my_stack, ...) or // my_stack.push(...) fn void Stack.push(Stack* this , Type element) { if ( this . capacity == this . size ) { this . capacity *= 2 ; if ( this . capacity < 16 ) this . capacity = 16 ; this . elems = realloc ( this . elems , Type. sizeof * this . capacity ); } this . elems [ this . size ++] = element; } fn Type Stack.pop(Stack* this ) { assert ( this . size > 0 ); return this . elems [-- this . size ]; } fn bool Stack.empty(Stack* this ) { return ! this . size ; ...

First seen: 2025-04-03 17:57

Last seen: 2025-04-04 18:02