Earlier quoted context omitted.
Just to be clear, I don't mean the description of Zig to put down the language or the community. It's the best I can do to describe the difference between Zig on one hand and Odin/C3 on the other. A more concrete example that might explain it better is looking at Advent of Code solutions. One thing that struck me was that doing typical tasks for parsing would be 2-3 functions stringed together in a smart way in the Z…
In other words, Zig is closer to the original C and maybe Scheme, while C3 and Odin tend towards maybe Ruby (while of course remaining capable of doing low-level stuff). Correct?
Show HN: The C3 programming language (C alternative language)
121–130 of 192 posts
Re: Show HN: The C3 programming language (C alternative language)
#122Earlier 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…
Indeed, Zig has interesting features that make you think in ways you won't make when using C, like an ability to offload large amount of computation to comptime code, or using different allocators at different times (super simple arena allocation per a game frame, for instance).
"A language that's not changing the way you think about programming is not worth knowing."
Re: Show HN: The C3 programming language (C alternative language)
#123Earlier quoted context omitted.
> 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 sha…
If I would have liked, I could have done something like `import std::io::file as file;` but I noticed that we keep getting this issue that we’re renaming things all of the time, and usually in the same way. This is why path shortening is there. To directly get something like the informal `file_open` namespacing in C programs.
Re: Show HN: The C3 programming language (C alternative language)
#124How 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.
const meta = @import("std").meta;
test "vector add" {
const x: @Vector(4, f32) = .{ 1, -10, 20, -1 };
const y: @Vector(4, f32) = .{ 2, 10, 0, 1 };
const z = x + y;
try expect(meta.eql(z, @Vector(4, f32){ 3, 0, 20, 0 }));
}
Everything is element-wise, which matches what the shading languages do (mostly).But, yes, you won't get overloading allowing things like dot, cross, or scalar products. And I do miss the swizzle notation, but I don't think the language actually prevents that so it might appear at some point.
Re: Show HN: The C3 programming language (C alternative language)
#125Earlier quoted context omitted.
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.
If your programming language had a different name, then I would agree, but it doesn't. Many will assume that C3 is the next iteration of C2 and that it's outdated, despite the fact that C2 is still in development.
Re: Show HN: The C3 programming language (C alternative language)
#126Earlier quoted context omitted.
Just to be clear, I don't mean the description of Zig to put down the language or the community. It's the best I can do to describe the difference between Zig on one hand and Odin/C3 on the other. A more concrete example that might explain it better is looking at Advent of Code solutions. One thing that struck me was that doing typical tasks for parsing would be 2-3 functions stringed together in a smart way in the Z…
In other words, Zig is closer to the original C and maybe Scheme, while C3 and Odin tend towards maybe Ruby (while of course remaining capable of doing low-level stuff). Correct?
But at the time there was little need for high level abstractions, and it was fine to just allocate an array with N number of entries and that was the maximum the program allowed.
Today we're dynamically allocating memory with intricate relationships, especially in object oriented programming.
This makes C look really hard to use – but it can actually be much improved with just an improved string library and a good dynamic array.
But there are also cross platform concerns for things like networking and here C offers little to help.
Regardless whether you're using Zig, C3 or Odin you're going to have a much easier time than C with straight up libc.
So I think a better comparison is that Zig is a bit like using the C++ containers. If you've ever struggled to mutate a std::vector while iterating over it, you know it's a bit complicated to figure out exactly what functions fit where.
The final solution might be performant, but it's a lot more to remember than say `iterator.remove_element()` that you might encounter in some other language. However, it does offer more ways to tweak it, and it's very explicit in what happens.
Re: Show HN: The C3 programming language (C alternative language)
#127Earlier 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.
In Zig, basic operations on vectors with standard operators work fine. "+", for example. const meta = @import("std").meta; test "vector add" { const x: @Vector(4, f32) = .{ 1, -10, 20, -1 }; const y: @Vector(4, f32) = .{ 2, 10, 0, 1 }; const z = x + y; try expect(meta.eql(z, @Vector(4, f32){ 3, 0, 20, 0 })); } Everything is element-wise, which matches what the shading languages do (mostly). But, yes, you won't get ov…
Given Zig's preference for closed modules, I don't expect this to be on the roadmap, but rather would need to be implemented as functions.
Re: Show HN: The C3 programming language (C alternative language)
#128Earlier quoted context omitted.
For grabbing the CPU features, there is some rudimentary implementation for x86 here: https://github.com/c3lang/c3c/blob/master/lib/std/core/priva... but not properly tested (which is to say, I would not count on it to work properly). The `@require` here is creating a contract. You can't give a padding that is 0xFF, that's a programming error. However, you might have data which is invalid – in that case the typical e…
Oh thank you, that cpu_detect.c3 is exactly what I need, the posted single-header library is almost the same in terms of functionality. BTW my last question still stands, however, that if there is a C library that is only a single header file that implements functions through macros, can it be used from C3? In C, for what I posted, you would need to first do "#define CPUDETECT_IMPL" and then include the header file.…
For that reason it's not an option for the standard library, but can certainly be useful for programs and libraries.
For faults, they are usually defined with `faultdef` which allows you to define one or more faults:
faultdef SOMETHING_WENT_SIDEWAYS, BIG_OOPS;
Then you use them as if they were constants: if (x > 0) return BIG_OOPS?;
If they are defined in another module, say "foo::bar::baz", then: if (x > 0) return baz::BIG_OOPS?;
Using path shortening "foo::bar::baz::BIG_OOPS" would also be valid, but is not necessary nor recommended.Re: Show HN: The C3 programming language (C alternative language)
#129Earlier quoted context omitted.
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.
This thread literally meets the definition of self-promotion. So no, don't think the characterization is unfair. If your programming language had a different name, then I would agree, but it doesn't. Many will assume that C3 is the next iteration of C2 and that it's outdated, despite the fact that C2 is still in development.
[1] Bas van den Berg, the author of C2.
Re: Show HN: The C3 programming language (C alternative language)
#130I think any system language going forward really needs three things: 1. Generics / templates 2. Destructors 3. Ownership It is unfortunate that this only has the first one. There was a language called clay that had all three and kept easy integration with the C ABI, but it seems like that design has been lost.
Any RAII language will be considered a C++ competitor, not a C alternative. None of Zig, Odin, C3 or Hare has RAII.