Live data from Hacker News

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

github.com

61–70 of 192 posts

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

#61
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,…

This is a good point about narrative spreading, in addition to marketing. People can become evangelized by their use of certain languages or by comments from certain language creators, then go on to attack others for using or even just wanting to try other languages. This shouldn't be what HN is about. It makes it look like HN has a language approval list.

As for both C3 and Odin, they've been around for many years, yet don't even have a Wikipedia page and have relatively low numbers on GitHub. That comes across as more time spent pushing or hyping on HN, than those languages being considered a truly viable alternative by the general public. Just weird, because you would think it should be the other way around.

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

#62
post #59
post #52

Earlier quoted context omitted.

For adapting code to different versions of libraries for one thing: #if defined(__SunOS) presult = getprotobyname_r(proto,&result,tmp,sizeof(tmp)); if (presult == NULL) return luaL_error(L,"protocol: %s",strerror(errno)); #elif defined(__linux__) if (getprotobyname_r(proto,&result,tmp,sizeof(tmp),&presult) != 0) return luaL_error(L,"protocol: %s",strerror(errno)); #else presult = getprotobyname(proto); if (presult ==…

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 :/

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

#63
post #26

Earlier quoted context omitted.

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

So which language do you use then? I've never seen a language that doesn't have bad things to say about other languages. Zig bdfl himself accused vlang of committing fraud a while back. Every language designer takes things they like about some languages and leaves things they don't like.

> Zig bdfl himself accused vlang of committing fraud a while back.

That was truly foul. On top of that, begged readers to give their money to Zig. Clearly some have no limits on what to say and do against other languages or to sell their language.

That's why whatever bad things a creator or evangelist says about another language, people shouldn't just swallow, and instead take with a grain of salt and some skepticism.

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

#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 attracted to Jai. Another aspect of this, is the more C3 promotes itself (whether intentional or not), the more likely C2 will get faded out. Many will likely think C3 is the next iteration of C2 or simply know the name more, because pushed on HN and other social media.

[1] https://github.com/c2lang/c2compiler

[2] https://github.com/c3lang/c3c

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

#65
post #57

Earlier quoted context omitted.

> `::` 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 no…

C3 has "path shortening", so for example given `open(...)` in std::io::file is usually used as `file::open(...)`. If we would to write this as `file.open(...)`. Consider now the case of mistyping `open`: `file.openn(...)`. Is this (A) mistyping the function open in module `std::io::file` or is it (B) the global/local `file` is missing from the current scope? Also, "io", "file", "random" etc are commonly used variable…

> Is this (A) mistyping the function open in module `std::io::file` or is it (B) the global/local `file` is missing from the current scope?

D uses a spell checker for undefined identifiers, and the dictionary is all the identifiers in scope. It has about a 50% success rate in guessing which identifier was meant, which is quite good.

> Also, "io", "file", "random" etc are commonly used variables, so the issue with shadowing is real.

If the same identifier is accessible through multiple lookup paths, an error is issued. If a local variable shadows a variable in an outer scope, and error is issued.

We've developed this over several years, and it works quite well.

Path shortening can be done with:

    alias open = file.open;
or:

    import io: open;

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

#66
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?

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`

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

#67
post #26

Earlier quoted context omitted.

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

So which language do you use then? I've never seen a language that doesn't have bad things to say about other languages. Zig bdfl himself accused vlang of committing fraud a while back. Every language designer takes things they like about some languages and leaves things they don't like.

The accusation is harsh, but I think Zig's BDFL had a point. V-lang seems to have been poorly led for many years.

https://news.ycombinator.com/item?id=27441848

https://news.ycombinator.com/item?id=39503446

Many links paint a picture of constant false advertising, even deception.

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

#68
post #43
post #26

Earlier quoted context omitted.

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

Off-topic (maybe should ask elsewhere), but why is C3 using "fn", it could not be avoided?

Edit: Someone already asked: https://news.ycombinator.com/item?id=43572190

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

#69
post #24

Earlier quoted context omitted.

Things like that make grepping easier. And redundancy of syntax makes reading-without-mistake faster. The more you put on the page the lower the cognitive load, the more spare it has in it, the easier it is to search for increasingly refined contexts of use.

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.

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

#70
@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 make it into the standard library.

Post reply on HN