Show HN: The C3 programming language (C alternative language)
101–110 of 192 posts
Re: Show HN: The C3 programming language (C alternative language)
#102Earlier quoted context omitted.
That strategy will backfire when the grammar changes in a later release. A pre-parse step is necessary for code that targets different compiler releases.
Now I'm confused, what do you mean? What grammar changes?
$if $defined(C3_V2_PLUS):
// new feature
fn f = \ -> foo(); // this won't parse in v1.0
$else
Callback f = ...;
$endif
This is also an issue if a future version of C3 introduces language level support, allowing newer compilers to compile code as if it were written for an earlier version. While this approach works well when teams standardize on a specific version’s feature set, they may still want to take advantage of performance improvements in the latest compiler.That said, this is a niche case and not something I’d consider a dealbreaker.
Re: Show HN: The C3 programming language (C alternative language)
#103Earlier 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…
> Also, there is a lot of "I discovered Zig and it's finally showing me how to program" echoed as well.
So, did you try Zig? How did you find it? Did it show you a new way to program? Or were you already aware of this way? Or do you think it's not a good way? What did you find interesting? What features did you steal because they were good? What do you think is overrated? These are the questions I'm interested in from other programming language designers!
> 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.
And that's a fair thing to say! You can say that C3 is just a slightly better C and doesn't have any other killer feature. I'm just not sure why you need to talk negatively about other languages.
Re: Show HN: The C3 programming language (C alternative language)
#104Earlier quoted context omitted.
Do you think it is ever going to be removed, or do the pros of having it outweigh the cons?
I don't like to say "never", because other things make change that invalidates previous conclusions. For example, let's say that for some reason macros were removed (this is very unlikely to happen, but as a thought experiment), then the symmetry between macro/fn definitions wouldn't be an argument anymore, and the question could be revisited. Similar things have happened before: the optional type syntax changed from…
There is a C (single header-only) library[1] that determines CPU features at runtime (similar to that of what libsodium does), so I might try to use that with C3 and implement BLAKE2. That might be a good starting point, or perhaps even TOTP, my friend told me implementing TOTP might give me some insight into the language, but for that I will need base32 (I checked, it exists[2]) and SHA{1,256,512}-HMAC, which may not be available in C3, although there may be an OpenSSL binding already, or perhaps I could directly use OpenSSL from C3? The latter would be pretty cool if so.
Regarding the mentioned C library, it might not work, because it is header-only, and it generates the C functions using macros (see line 219). What do you think? Would this work from C3?
[1] https://zolk3ri.name/cgit/cpudetect/tree/cpudetect.h
[2] https://github.com/c3lang/c3c/blob/master/lib/std/encoding/b...
---
I checked base32.c3. I am comparing it to Odin's, which can be found at https://github.com/odin-lang/Odin/blob/master/core/encoding/.... Apparently they added a way to gracefully handle error cases. Is it possible to do so with the current C3 implementation?
Edit: I noticed "@require padding some errors or invalid input gracefully. Although I prefer Odin's current implementation because you can handle specific errors, e.g. not just "invalid character", but invalid length (and others, see base32.odin for more). Any thoughts on this?
Additionally, what are the differences between
@require padding
and @return? encoding::INVALID_PADDING, encoding::INVALID_CHARACTER
exactly? If I want to handle invalid padding character, I would have to get rid of "@require"?Additionally, what if there are many more error cases? It would be a "long line" of available error cases? Could I use an enum of errors or something instead or something similar to https://github.com/odin-lang/Odin/blob/master/core/encoding/...?
BTW I like programming by contract, but I am not sure that all error cases that Odin has could have a "@require", and I am not sure if I would like to mix them either, because what if I have a program where I want to handle even "padding ---
Thank you for your time and help in advance!
Re: Show HN: The C3 programming language (C alternative language)
#105Earlier quoted context omitted.
I like to quickly at a glance be able to distinguish between "this is a member access on an object" and "this is referencing something in a module". I like that the compiler can distinguish those two things too, so that I can refer to things within modules even if I happen to also have a local variable with the same name. Go sometimes annoys me because I need to rename a module or a variable just because the syntax d…
> distinguish between "this is a member access on an object" and "this is referencing something in a module". zig: what's the difference?
In C3 it goes the other way despite having methods, and says "let's not allow static variables or methods".
This also goes hand in hand in the language approaches between open/close. Zig is very strongly "closed" and C3 is very much "open" (adding methods to types anywhere, appending to modules anywhere etc)
It's an interesting contrast that leads to very different code layouts.
Re: Show HN: The C3 programming language (C alternative language)
#106Earlier quoted context omitted.
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…
You're kinda proving my point here by using such loaded terms. You've chosen the term "preachy" (a negative word) to describe people who are excited about advancements in programming languages (e.g. borrow checker, powerful type system, comptime, alignment as a part of type system). You've chosen to not mention that Rust keeps being the "Most loved programming language" (according to Stack Overflow); isn't this is a…
However, my impression was obviously coloured by being around 45 at the time and I was used to program in many different programming languages. Plus I grew up with BASIC, Pascal and C.
There's going to be quite a different experience for someone coming from Go/JS/Java and venturing into low level programming for the first time!
That is not to say that all of the people being enthusiastic about Zig is coming from those particular languages, but I think that C is considered a scary language for many people, so C alternatives tend to attract people from higher level languages to a higher degree than C itself.
When I eventually started on C3, I incorporated some features from Zig. I ended up removing all of them as I found them to be problematic: untyped literals combined with implicit widening, unsigned error on overflow, special arithmetic operators for wrap, saturation.
However, I am very grateful that Zig explored these designs.
From Odin I ended up including its array programming, but for vectors only. I also adopted Odin's use of distinct types.
But most of the C3 features are GCC C extensions plus ASTEC inspired macros.
Re: Show HN: The C3 programming language (C alternative language)
#107I have used this language for a few things (csv parsing and some simple personal cli tools). Other than the normal pre-1.0 issues it's great. I wish it had a tagged union type, but it looks like that's planned based on the github issue tracker. It is a pretty big improvement on C without changing the ABI. Maybe not the improvements I would make if I was smart enough to make a compiler, but better than doing C which I…
Making compilers are not that hard. Sure, it grows in complexity as you make it more feature-complete. But writing compilers is actually a lot of fun. If you're interested in compilers you should definitely try making a simple one. This book is free and a great starting point: https://craftinginterpreters.com/ . I'm not associates with the book author in any way, I just found incredible value in it.
Re: Show HN: The C3 programming language (C alternative language)
#108Earlier quoted context omitted.
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)
Notably all of these you mentioned aren't finished. C3 is 0.7, Jai is an "internal beta", Odin is working through a series of "dev" builds, Zig is 0.14, and Hare 0.24.2 This is maybe more striking when comparing against C which was already very old and battle tested in 1989 when it was standardized. If you pick any of these languages you're accepting an unknowable amount of churn. It better be worth it.
Re: Show HN: The C3 programming language (C alternative language)
#109Earlier quoted context omitted.
You're kinda proving my point here by using such loaded terms. You've chosen the term "preachy" (a negative word) to describe people who are excited about advancements in programming languages (e.g. borrow checker, powerful type system, comptime, alignment as a part of type system). You've chosen to not mention that Rust keeps being the "Most loved programming language" (according to Stack Overflow); isn't this is a…
I tried Zig in 2017-2018 span (and as part of research I've read quite a bit of Zig over the years). To me the language had some details not previously tried out: special operators for wrapping ops, error value based error returns and pervasive NPOT types. But overall it felt unnecessarily verbose with what I feel were unnecessary changes to established syntax in standard constructs such as "for" and "while". For thi…
Re: Show HN: The C3 programming language (C alternative language)
#110Earlier quoted context omitted.
I like to quickly at a glance be able to distinguish between "this is a member access on an object" and "this is referencing something in a module". I like that the compiler can distinguish those two things too, so that I can refer to things within modules even if I happen to also have a local variable with the same name. Go sometimes annoys me because I need to rename a module or a variable just because the syntax d…
> distinguish between "this is a member access on an object" and "this is referencing something in a module". zig: what's the difference?