Live data from Hacker News

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

github.com

71–80 of 192 posts

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

#71
post #59

Earlier quoted context omitted.

Oh, I think you missed something then: There is both `$if` and `$switch` compile time statements for this: https://c3-lang.org/generic-programming/compiletime/#if-and-... At the top level and `@if` attribute is used to achieve the same thing: https://c3-lang.org/language-common/attributes/#if

Ah. The top-level lang description claims “No preprocessor”, but my definition of that word doesn’t appear to be the same as yours :/

The difference here is that a preprocessor runs before parsing and semantic analysis. In C3 compile time if runs in the analysis step, so after parsing.

So the macros and compile time execution occurs after parsing in C3, but in C everything happens at lexing, before the code is parsed.

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

#72
post #64

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

Arguably, what you describe, is closer to what C2 was/is[1]. By the way, C2 is still alive, for those that care to look. C3 (link[2]) is a fork of/inspired by C2, which appears to have incorporated a lot of Odin and Jai "flavoring". In the case of both C3 and Odin, it can be argued that part of their popularity is that Jai isn't publicly released. Consequently, they seem to pull in a lot of the crowd, that would be a…

Isn’t it a somewhat unfair characterization that ”C3 promotes itself more” and ”is pushed on HN and other social media” and that because of this C2 for some reason experiences harm?

C2 is over 11 years now. C3’s recent breakthrough this last half year is unlikely to have had much impact on its ability to grow the last 10 years.

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

#73
post #24

Earlier quoted context omitted.

Agreed. It's tempting to make the tersest lang you can but in the end what matters is ease of reading. For ex. parens-less calls ( myfunc 42 "hello" ) are elegant but don't stand out and - for me - take more time to identify. Also `fun foo(i:int)` is easier on the parser than C-style `void foo(int i)`

I prefer lack of "fun" and "fn", to me it is easier to parse C-style. :( This is one of the things (albeit minor) that put me off of C alternatives, I like to keep things as simple as possible, but I understand it has "macro" as well, so might as well have "fn", for the reasons already mentioned. That said, I will still try C3.

Also, `fn` is used to make type inference for lambdas syntactically simple. But I would lie if I said I haven’t been considering removing `fn` many times. But there are good reasons for keeping it, despite the break with C.

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

#75
post #66

Earlier quoted context omitted.

For one thing, C3 thankfully understands that there are more mathemathical types people are interested in than just ints and reals, for example vectors: https://c3-lang.org/language-common/vectors/ Zig has SIMD vectors, but I frequently need 3D vectors, and refuse to use things like vec3_add(vec3_mul(a, 2), b) etc since I mainly develop 3D graphics software.

interesting example of swizzling ``` int[ ] a = { 11, 22, 33 }; int[ ] b = a.xxzx; ``` I assume that the `xxzx` is translated directly by the compiler. not seen that in any other language though ruby can fake it pretty easily via `method_missing`

This is not that novel. It is inspired by the similar feature in the Odin language.

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

#76
post #75
post #66

Earlier quoted context omitted.

interesting example of swizzling ``` int[ ] a = { 11, 22, 33 }; int[ ] b = a.xxzx; ``` I assume that the `xxzx` is translated directly by the compiler. not seen that in any other language though ruby can fake it pretty easily via `method_missing`

This is not that novel. It is inspired by the similar feature in the Odin language.

ah, neat if it's becoming a standard convention of sorts. i haven't used odin either.

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

#78

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

There is no spiral rule, that is a misconception. Look up how "declaration follows usage" in C. E.g. https://eigenstate.org/notes/c-decl

While this rule has become somewhat diluted when C developed and gradually took on features from C++ (like types in function parameters), it's still very helpful to understand the guiding principle. (But those inconsistencies that crept in over time are also the reason why newer languages don't do that anymore).

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

#79

@lerno, how do you feel about contributions to the standard library? For example, I might add BLAKE2 if it is not already implemented. Also I just checked the source code of hash map. What if I want to use a different hashing algorithm for "rehash"? There is no one true implementation of a hash table either, for example, so I am not sure what to do with that. I want a thread-safe hash table, I wonder if it would ever…

Blake2 and other hashes are most welcome.

As for HashMap you are completely correct: there are many different types of maps that are needed. Concurrent maps, insertion ordered maps etc. And even variations of the small things: are keys copied or not!

I talked about this on a stream recently, how the standard library is in need of a lot of additional Maps, Sets and Lists.

So if you’re interested in contributing then you’re very welcome to do so.

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

#80
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…

On ziglang.org the very first thing we advertise is:

> Focus on debugging your application rather than debugging your programming language knowledge.

Clearly, you think the language fails at this criteria (your subjective opinion). Please be honest and say that, rather than implying that it's not explicitly one of the core design principles of the language (objectively false).

Post reply on HN