Live data from Hacker News

Learning C3

alloc.dev

41–50 of 163 posts

Re: Learning C3

#41
Most of these features have been used by countless C++ developers for the past decades -- I really don't see the point in adopting a language that's mostly C++ but without some of the warts. Either pick C++ or something like Rust.

Re: Learning C3

#42
post #27

After using Rust on a couple of projects, I understand the appeal of simpler languages like C3, Zig, and Odin. As one commenter very aptly put on the Zig subreddit ... "I used Zig for (internal tool) because I wanted to quickly write my tool and debug it, and not spend all my time debugging my knowledge of Rust."

Is Zig really that common at this point that you'd feel comfortable using it for a work project? Its not just going to piss off the next person and have them need to rewrite it? I guess Rust has the same problem to some extent but there is a lot of resources for writing Rust out there now

I suppose the nice thing about zig is that for many things, porting back to C is relatively straightforward and if you wanted to incrementally do it, there's a way to do that, too.

Re: Learning C3

#43
a nitpick:

a bit down the page there is stuff on the case syntax. The fact that "you can't have an empty break" is a good choice, but the fact that having two cases do the same thing has syntax

    case X:
    case Y:
is footgun waiting to happen. I would strongly suggest the authors of C3 make stacking cases look like this:

    case X, Y:

Re: Learning C3

#44

Most of these features have been used by countless C++ developers for the past decades -- I really don't see the point in adopting a language that's mostly C++ but without some of the warts. Either pick C++ or something like Rust.

the problem with picking C++ is that eventually you onboard someone who uses the warts in their code, and then the warts become like craft glitter.

Re: Learning C3

#45

Most of these features have been used by countless C++ developers for the past decades -- I really don't see the point in adopting a language that's mostly C++ but without some of the warts. Either pick C++ or something like Rust.

To me it didn't really feel like C++; it is much less complicated. Could you explain more what you mean by this?

Re: Learning C3

#46

a nitpick: a bit down the page there is stuff on the case syntax. The fact that "you can't have an empty break" is a good choice, but the fact that having two cases do the same thing has syntax case X: case Y: is footgun waiting to happen. I would strongly suggest the authors of C3 make stacking cases look like this: case X, Y:

seems subtle to distinguish between case 3,4: for values 3 or 4, and case (3,4): for an array with the value [3,4]

Re: Learning C3

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

This is a completely valid and reasonable argument; I don't understand why people are downvoting it.

Re: Learning C3

#48

a nitpick: a bit down the page there is stuff on the case syntax. The fact that "you can't have an empty break" is a good choice, but the fact that having two cases do the same thing has syntax case X: case Y: is footgun waiting to happen. I would strongly suggest the authors of C3 make stacking cases look like this: case X, Y:

seems subtle to distinguish between case 3,4: for values 3 or 4, and case (3,4): for an array with the value [3,4]

oof. To me switch/case mentally implies constant time matching and routing, I wonder if that is the case (it could be if arrays have compile-time known length).

Re: Learning C3

#50
post #23
post #22

Earlier quoted context omitted.

There's also Zig in the C-alternatives space. https://ziglang.org/

There is also Odin: https://odin-lang.org/ Would be nice to have a list of these and comparisons

There is also C23 and at some point C2Y.

C23 got typeof, constexpr constants, enums with underlying type, embed, auto, _BitInt, checked integers, new struct compatibility rules, bit constants, nullptr, initialization with {}, and various other improvements and cleanups. Modern C code - while still being simple - can look quite different than what people might be used to.

C2Y already already got named loops, countof, if with declarations, case range expressions, _Generic with type arguments, and quite a lot of UB removed from the core language. (our aim is also to have a memory safe subset)

Post reply on HN