Live data from Hacker News

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

github.com

41–50 of 192 posts

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

#41
So many of the so-called "C alternatives" end up doing way too much. I don't need algebraic data types or classes or an integrated build system or a package manager.

What I would like to see is a language that is essentially just C with the major design flaws fixed. Remove the implicit casting and obscure integer promotions. Make spiral rule hold everywhere instead of being able to put const at the beginning of the declaration. Make `sizeof()` return a signed type. Don't allow mixed signed/unsigned arithmetic. Make variables/functions private by default i.e. add `public` to make public instead of `static` to make private.

Keep the preprocessor and for the love of god make it easy to invoke the compiler/linker directly so I can write my own Makefile.

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

#42
Recently gave this language a spin with raylib and libtmx for loading tiled maps. Out of C3, Zig, and Odin, I've had the least trouble integrating C libraries with C3 (rolled my own bindings for libtmx). Overall a big fan of the language and am hoping it gets recognition on the level of the other languages mentioned here.

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

#43
post #26
post #22

Earlier quoted context omitted.

As the author, let me add something beyond the comparison. Zig and Odin are very different languages, Odin is – as its slogan goes - "for the Joy of Programming". Zig on the other hand doesn't feel that this is a goal. From what I can tell Zig fans like to wrestle with the features of Zig to figure out how to fit their solutions within the constraints of the language. A mental challenge, similar to that of fighting t…

> People who "figured out" Zig tend to be fiercely loyal to the language in a similar way as Rust evangelists to Rust. This is very much not productive and you’re now part of spreding this narrative. There’s plenty of people out there who has «figured out» and appreciate both Zig and Rust without becoming attached to it. I’m interested in communities which looks towards other languages for inspiration and admiration,…

For what it's worth, I found the Zig community on the biggest Zig discord very nice and welcoming. But that said, there is a lot of "you have to understand Zig" sentiment. Also, there is a lot of "I discovered Zig and it's finally showing me how to program" echoed as well.

I don't find this an unfair judgment but rather an observation.

I think this naturally arises from the language claiming to be "a programming language designed for robustness, optimality, and clarity" (See for instance https://www.recurse.com/events/localhost-andrew-kelley)

If you feel that this is an optimal programming language that gives more robustness and clarity than other languages, then it's natural to be preachy about it.

This is similar to Rust being sold as safe language, where similarly the proponents of Rust feel that the advantages of Rust need to be spread.

As a contrast, Odin focuses on "joy of programming" as its main goal, and the author does not make any claims of the language having killer features to choose it over something else.

However, it seems to be successful in that new users tend to remark how pleasant and fun it is to program in the language.

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

#44
post #28

Hello, your doc about const says "The const qualifier is only retained for actual constant variables". Then how do you express read-only pointers ? Like C `const int* ptr`

If you pass them as parameters, then there are in/out/inout annotations to limit usage. But other than that, there isn't anything.

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

#45
post #18

One thing I just can't understand is proactively using the :: syntax. It's sooo ugly with so much unnecessary line noise. Just use a single period! I think one of the best decisions D made was to get of -> and :: and just use . for everything.

`::` simplifies the module vs identifier resolution. In C3 there is something called "path shortening", allowing you to use `foo::bar()` in place of something like `std::baz::foo::bar()`. To do something similar with `.` is problematic, because you don't know where the path ends. Is `foo.baz.bar()` referring to `foo::baz::bar()` or `foo::baz.bar()` or `foo.baz.bar()`?

> `::` simplifies the module vs identifier resolution

The identifier on the right is looked up in the scope of the identifier on the left. If it resolves to a module, then it's a module. If it resolves to a function, then it's a function. If the left side is a pointer (not a symbol with a scope) then the right side resolves to a member.

It also makes refactoring much easier - changing a pointer to a reference does not require a global search/replace of -> with .

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

#46
post #22
post #5

How does this compare to Zig or Odin, which have the same goals of improving upon C and have gotten occasional publicity here on HN?

As the author, let me add something beyond the comparison. Zig and Odin are very different languages, Odin is – as its slogan goes - "for the Joy of Programming". Zig on the other hand doesn't feel that this is a goal. From what I can tell Zig fans like to wrestle with the features of Zig to figure out how to fit their solutions within the constraints of the language. A mental challenge, similar to that of fighting t…

Just to be clear, I don't mean the description of Zig to put down the language or the community. It's the best I can do to describe the difference between Zig on one hand and Odin/C3 on the other.

A more concrete example that might explain it better is looking at Advent of Code solutions.

One thing that struck me was that doing typical tasks for parsing would be 2-3 functions stringed together in a smart way in the Zig solutions, whereas in Odin and C3 it was achieved by having a single standard library function that did these steps.

From what I understand, there is a pushback against creating convenience functions in the Zig standard library, if the same thing can be achieved by stacking together a few functions.

My understanding is that doing these smart things with the Zig library with the existing functionality of considered a cool way to leverage existing code.

In C3, and I feel Odin as well, the lack of such a convenience function would be considered an omission to patch, and that having to stack things together should be reserved for specialized solutions, rather than having to stack things together for everyday tasks.

Thus in C3 and Odin, it is okay to trade detailed explicitness for convenience, whereas this is a no-no in Zig.

But what this means is that Zig users tend to celebrate and focus on smart and clever code, whereas this is a complete non-goal in C3 and Odin.

I could probably have formulated this better before.

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

#48
post #5

How does this compare to Zig or Odin, which have the same goals of improving upon C and have gotten occasional publicity here on HN?

Zig and Odin compiler may implicitly pass variables by references[1][2], creating hidden aliasing, that's one thing unacceptable for me coming from C, I haven't read about C3 doing this, hopefully it doesn't and not planned in the future.

[1] https://www.1a-insec.net/blog/25-zig-reference-semantics/ [2] https://github.com/odin-lang/Odin/issues/2971

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

#49

Any other C alternative or C-like languages that people here are using more than experimentally? Asking because my above question and this current post about C3 are related to this recent post by me, which had a good number of comments: Ask HN: What less-popular systems programming language are you using? https://news.ycombinator.com/item?id=43223162

Other than C3, there is Jai, Odin, Zig and Hare which are the ones that have any traction right now that I know of. Many interesting projects have been started but ultimately later abandoned.

Going to C++ competitors there is obviously Rust, but also Nim, Crystal, Beef and a lot of others. (And Jai is a C++ competitor too)

Post reply on HN