Interestingly there is also C2: http://c2lang.org
Learning C3
71–80 of 163 posts
Re: Learning C3
#72Re: Learning C3
#73Earlier quoted context omitted.
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.
Indeed. There’s a port for macOS though. And yet out all these newer C-like languages, it looks like Hare probably takes the crown for simplicity. Among other things, Hare uses QBE[1] as a backend compiler, which is about 10% the complexity of LLVM. [1] https://c9x.me/compile/
Plus the "frontend -> QBE -> assembler -> binary" process is slower than "frontend -> LLVM -> binary". And LLVM is known for being a fairly slow compiler.
Re: Learning C3
#74This 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!
C3 is more complex than C (because of a net increase of features), but it's miles from C++ and Rust in complexity and it compiles as fast or faster than C.
Re: Learning C3
#75Earlier quoted context omitted.
> Approaches to avoid constructors/destructors such as ZII play very poorly with ref values as well. What you end up with is some period of time where a value is quasi valid - since non-null types need to be assigned and it's in a broken state before it's initially assigned. I don't see that as a problem; don't separate declaration from assignment and it will never be unassigned. Then a ZII non-null pointer is always…
I don't quite see what you mean. As an example, let's say you use ZII and allocate 100 objects in a single allocation. These are now zero initialized and so either invalid (which should not happen) or do not hold non-null types. Can you explain how you intend this scenario to be resolved in your case? Otherwise it's quite straightforward that they have an uninitialized state (zero) and are then wired up when used. Tr…
If you want to do that you can always use a nullable type. You can always assign it to a non-nullable type after initialization if you plan on using the aggregate a lot.
Usually you provide a vector type though, which has an underlying nullable array, but maintains a fill-index such that for all i < fill-index it the value is initialized, and then you have two indexing operations; one which returns a nullable type and the other which bounds-checks and returns a non-nullable type.
Re: Learning C3
#76This 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. Espec…
The macro cannot insert variables into the caller scope, nor cause the function to return. Mostly it's similar to a static inline function with optionally polymorphic arguments. But it can do some more things as well, but nothing violating hygiene.
Re: Learning C3
#77Re: Learning C3
#78> 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…
> The whole point of C is that you know exactly what's going on and it's relatively clear in the code itself. Given the widespread undefined behavior and the ways that compilers aggressively rely on that to reorganize and optimize your code, that hasn't been the case for many many years. Sure, if you're using dmr's compiler on a PDP-11, then C is a pretty transparent layer over assembly, which is itself a fairly thin…
Re: Learning C3
#79This 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. Espec…
Re: Learning C3
#80Earlier quoted context omitted.
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.