Named parameters are already in the language.
Regarding concurrency, I don't want to pick a single concurrency model over another. I will see what hooks I can make for userland additions, but the language will not be opinionated about concurrency.
1,425 karma · joined April 1, 2014
Named parameters are already in the language.
Regarding concurrency, I don't want to pick a single concurrency model over another. I will see what hooks I can make for userland additions, but the language will not be opinionated about concurrency.
I think Rust and similar languages fill that niche already, so there is no real need to try to offer that type of alternative.
So they should be the same, otherwise it's a bug.
switch (x) {
case 0:
...
case 1 + 1:
...
}
This will behave in the normal way. But you can also have: switch {
case foo() > 0:
...
case bar() + baz() == s:
...
}
In which case it lowers to the corresponding if-else. case SOME_BAD_THING, SOME_OTHER_CONDITION, HERE_IS_NUMBER_THREE:
foo();
int y = baz();
Placing them on the next row is fairly hard to read case SOME_BAD_THING, SOME_OTHER_CONDITION,
HERE_IS_NUMBER_THREE, AND_NUMBER_FOUR, AND_NUMBER_FIVE,
AND_THE_LAST_ONE:
foo();
int y = baz();
In C I regularly end up with lists that have 10+ fallthroughs like this, because I prefer complete switches over default for enums at least. case SOME_BAD_THING:
case SOME_OTHER_CONDITION:
case HERE_IS_NUMBER_THREE:
case AND_NUMBER_FOUR:
case AND_NUMBER_FIVE:
case AND_THE_LAST_ONE:
foo();
int y = baz();
I understand the desire to use "case X, Y:" instead, and I did consider it at length, but I found the lack of readability made it impossible. One trade off would have been: case SOME_BAD_THING,
case SOME_OTHER_CONDITION,
case HERE_IS_NUMBER_THREE,
case AND_NUMBER_FOUR,
case AND_NUMBER_FIVE,
case AND_THE_LAST_ONE:
foo();
int y = baz();
But it felt clearer to stick to C syntax, despite the inconsistency.1. It is so big.
2. It still largely depends on GC (less important actually)
It keeps adding features, but adding features isn't what makes a language worth using. In fact, that's one of the least attractive things about C++ as well.
So my guess:
1. It betted wrong on GC trying to compete with C++.
2. After failing to get traction, kept adding features to it – which felt a bit like there was some feature that would finally be the killer feature of the language.
3. Not understanding that the added features actually made it less attractive.
4. C++ then left the GC track completely and became a more low level alternative to, at which point D ended up in a weird position: neither high level enough to feel like a high level alternative, nor low level enough to compete with C++.
5. Finally: the fact that it's been around for so long and never taking off makes it even harder for it to take off because it's seen as a has-been.
Maybe Walter Bright should create a curated version of D with only the best features. But given how long it takes to create a language and a mature stdlib, that's WAY easier said than done.
The try-catch has nice composability:
try {
int x = foo_may_fail();
int y = bar_may_fail(x);
} catch (... ) {
...
}
Regular Result types need to use flatmap for this, and of course error codes or multiple returns also struggle with this. With C3: int? x = foo_may_fail();
int? y = bar_may_fail(x);
if (catch err = y) {
...
return;
}
// y is implicitly unwrapped to "int" here
This is not to say it would satisfy you. But just to illustrate that it's a novel approach that goes beyond Optional and Either and has a lot in common with try-catch.Overloading is also generally missing from today's breed of C alternatives.
There has certainly been many attempts at C alternatives: eC, Cyclone etc etc
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.
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.
Plus the "frontend -> QBE -> assembler -> binary" process is slower than "frontend -> LLVM -> binary". And LLVM is known for being a fairly slow compiler.
Otherwise it's quite straightforward that they have an uninitialized state (zero) and are then wired up when used. Trying to prevent null pointers here is something that the program to do. However, making the compiler guarantee without requiring constructors it is a challenge I don't know how to tackle.
Interviews:
- https://www.youtube.com/watch?v=UC8VDRJqXfc
- https://www.youtube.com/watch?v=9rS8MVZH-vA
Here is a series doing various tasks in C3:
- https://ebn.codeberg.page/programming/c3/c3-file-io/
Some projects:
- Gameboy emulator https://github.com/OdnetninI/Gameboy-Emulator/
- RISCV Bare metal Hello World: https://www.youtube.com/watch?v=0iAJxx6Ok4E
- "Depths of Daemonheim" roguelike https://github.com/TechnicalFowl/7DRL-2025
Tsoding's "first impression" of C3 stream:
1. You want almost all pointer parameters non null.
2. Non-null variables is very hard to fit in a language without constructors.
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.
It's certainly possible to create generic "type safe" non-null types in C3, but they are not baked into the language.
But I'm trying to update the docs for types now. It's reasonable to just have all the compile time type properties in one place so people can find them.
This is a good example of the sharp edges I hope to smoothen out in 0.7-0.9.
Clearly the lack of zeroing in C was a trade-off at the time. Just like UB on signed overflow. And now people seem to consider them "obvious correct designs".
Odin and C3 has things like swizzling, assigning a scalar to all elements etc out of the box, whereas Zig is similar to C and just provides compiler builtins. Compare `vec * @splat(foo())` (Zig) to `vec * foo()` (Odin/C3).