some comparisons, confusions, & praisals #1102
-
hi there! i have known about c3, c2 before but ignored lest can't track innumerably numbered proliferations; so, with respect to comparisons (site | permalink), i had some questions:
also:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
@goyalyashpal The Zig build system is not integrated. Maybe it's unclear what I mean. Zig has one (or more) external build scripts, written in Zig. The advantage of the Zig scheme, is that it offers great flexibility at compile time. The downside is that for an IDE to execute the same things that the build script does, it needs to understand the code. So the way the C3 compiler works is that it takes some declarations and from those it builds the library or executable. There is no declaration in the project settings that isn't available at the command line, so that you can either choose to have it integrate with a system that also does dependency management, such as CMake, or – for simpler projects – just use "project.json" which is a configuration file. This is why I write "Toolchain uses build files written in native Zig" for Zig and "Integrated build system" for C3.
Zig doesn't have C ABI compatibility for its features. Only a limited subset can be used to interface with C. Normal zig structs, tagged unions, errors etc may not be used in the C interface. In contrast, all structs, unions, enums, optionals etc in C3 are directly available from C. It is more proper to say that Zig has a FFI to C. Zig also offers a way to import C headers and have those implicitly translated, but that is not related to the ABI.
Auto-arguments are fairly new I think, and is a result of needing some macro definitions not available in the new C2 compiler in development. Template functions and structs are not implemented yet, nor is there a description of how they would look, so it's kind of early to compare with it. The last time when C3 got updated with C2 features was in 2019.
It is something of a remix. As you already noted, it has a similar behaviour as namespaces, but there are things such as path shortening that doesn't have anything corresponding to it in any other language, but in practice invoking functions from other modules may appear similar to invoking static methods on Java classes, (e.g. you would invoke |
Beta Was this translation helpful? Give feedback.
-
hey, also i noticed that the feature of c3 containing @test and umh, is it so trivial thing? also, is c3 taking some inspirations from zig? like edit for contracts: contracts like the pre/post condition, purity, in/out for ptrs (ada has this too) |
Beta Was this translation helpful? Give feedback.
-
Yes, benchmark and tests all feel like a fairly small feature.
As inspiration from Zig, I do indeed look at Zig to see what's added. However, the few things I tried out early on that I "borrowed" from Zig early on (no unsigned wrap, wrapping operators, untyped numerical constants) turned out so badly that I removed them - and in fact went in the opposite direction. It's been useful to see how the direction Zig chose turned out though, that Zig explored the design space has been useful. Design philosophy wise C3 and Zig are in different places. |
Beta Was this translation helpful? Give feedback.
-
With all respect to c3,I like many of its features,may I ask how c3 is very like/dislike the v language(vlang.io)? I get familar to v for a couple of month before knowing c3 thus have an impression they are alike each other,for example,the generics,the operator overloading,the error handling,the Optional/Result ( c3c provided more options which I don't know whether it should be or it is a bit more complicated) ,the way to interop with C etc.... As a programming beginner,if the impression is totally wrong,kindly ignore. |
Beta Was this translation helpful? Give feedback.
@goyalyashpal The Zig build system is not integrated. Maybe it's unclear what I mean. Zig has one (or more) external build scripts, written in Zig. The advantage of the Zig scheme, is that it offers great flexibility at compile time. The downside is that for an IDE to execute the same things that the build script does, it needs to understand the code.
So the way the C3 compiler works is that it takes some declarations and from those it builds the library or executable. There is no declaration in the project settings that isn't available at the command line, so that you can either choose to have it integrate with a system that also does dependency management, such as CMake, or – for simple…