Live data from Hacker News

Learning C3

alloc.dev

11–20 of 163 posts

Re: Learning C3

#11
This looks promising, but I wonder what advantages it has over Rust. Community support is very important for a programming language, and given that this is the first time I am hearing about this project, it still has some way to go.

Edit: ABI compatibility & two way interop with C seems to be a pretty big selling point!

Re: Learning C3

#13
post #4

> Don't misunderstand me - I love using foreach in other languages; the added syntax better expresses your intent, reducing logic errors. It did jump out at me as "this isn't C" though. Because it's not. The whole point of C is that you know exactly what's going on and it's relatively clear in the code itself. C++ hides logic in abstractions for the sake of convenience. This is a C++ thing. How does it know how to it…

Just curious - in what situations would you want to use `foreach` (with the intent to iterate over a sequence), but use `i += 2` instead of `i++`? I can only think of a situation where I want to group elements by pairs, but then I'm explicitly not doing a "for each", and would prefer to explicitly use a regular `for`.

Re: Learning C3

#14
post #10
post #8

Earlier quoted context omitted.

I just skimmed the C3 spec[1] on foreach and foreach_r, and I'm still confused as to how to move elements by anything other than 1, if it's even possible. [1] https://c3-lang.org/implementation-details/specification/#fo...

It isn't possible. Use `for` instead. `foreach` isn't trying to be a one-stop-shop, but rather help the common case of looping over an array or list. Because it handles caching the length and such it's more efficient than a casually written `for` loop. This is the 90% solution to iteration.

Ah that makes sense, as long as the length doesn't change during iteration, which like you said is the 90% case. As long as I also can use for(), then that's fine.

Re: Learning C3

#15
post #4

> Don't misunderstand me - I love using foreach in other languages; the added syntax better expresses your intent, reducing logic errors. It did jump out at me as "this isn't C" though. Because it's not. The whole point of C is that you know exactly what's going on and it's relatively clear in the code itself. C++ hides logic in abstractions for the sake of convenience. This is a C++ thing. How does it know how to it…

> I could easily change a C for loop to use i += 2 instead of i++ if I wanted, that's the beauty of it.

If you're not doing something for each element of a collection, you should not be using a `foreach` loop. In exchange for not exposing the implementation, you immediately know the behavior. You also don't have to worry about checking the rest of the loop body for later mutations.

Re: Learning C3

#16

Has anyone tried both C3 and Hare[1]. How do they fare? There seems to be quite the overlap between the two. [1] https://harelang.org/

Problem with Hare is that it is (or at least was last time I checked) Linux/Unix only and so by design. That kinda makes it DOA for many.

Re: Learning C3

#17

This looks promising, but I wonder what advantages it has over Rust. Community support is very important for a programming language, and given that this is the first time I am hearing about this project, it still has some way to go. Edit: ABI compatibility & two way interop with C seems to be a pretty big selling point!

Rust is way more complex to say the least, in fact it's the sole reason why it still has the same market share as COBOL(https://www.tiobe.com/tiobe-index/). Rust 1.0 was released 10 years ago by the way.

Re: Learning C3

#18

This looks promising, but I wonder what advantages it has over Rust. Community support is very important for a programming language, and given that this is the first time I am hearing about this project, it still has some way to go. Edit: ABI compatibility & two way interop with C seems to be a pretty big selling point!

I want to second this comment.

The comparison shouldn't be with C, it should be with C++, Rust, or Zig.

The place to go is actually the C3 comparison page:

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

There you can see that there are very few items "in C3 but not Rust", for example. Mainly "it's a familiar C-like language".

I am also suspicious of the macro system. I'd like more of an explanation of how it works. Especially how it relates to Zig comptime, and whether it has "hygiene" problems. Hygiene to me means: can a variable name in a macro expansion refer to a variable outside of the macro? (The concern is that this could be accidental.)

https://c3-lang.org/generic-programming/macros/

Re: Learning C3

#19
post #4

> Don't misunderstand me - I love using foreach in other languages; the added syntax better expresses your intent, reducing logic errors. It did jump out at me as "this isn't C" though. Because it's not. The whole point of C is that you know exactly what's going on and it's relatively clear in the code itself. C++ hides logic in abstractions for the sake of convenience. This is a C++ thing. How does it know how to it…

Just curious - in what situations would you want to use `foreach` (with the intent to iterate over a sequence), but use `i += 2` instead of `i++`? I can only think of a situation where I want to group elements by pairs, but then I'm explicitly not doing a "for each", and would prefer to explicitly use a regular `for`.

Vectorization unrolling?

Re: Learning C3

#20

This looks promising, but I wonder what advantages it has over Rust. Community support is very important for a programming language, and given that this is the first time I am hearing about this project, it still has some way to go. Edit: ABI compatibility & two way interop with C seems to be a pretty big selling point!

Rust is way more complex to say the least, in fact it's the sole reason why it still has the same market share as COBOL( https://www.tiobe.com/tiobe-index/ ). Rust 1.0 was released 10 years ago by the way.

Tiobe really?
Post reply on HN