Learning C3
alloc.dev
Learning C3
1–10 of 163 posts
Re: Learning C3
#2Re: Learning C3
#3C3 looks promising, but any language that supports nulls needs null-restricted types, not whatever those contract comments are. If I wanted to have to null-check everything, or YOLO it, I would just write Java... and even Java is seeking to fix this: https://openjdk.org/jeps/8303099
But having them be inside comments is just weird.
Re: Learning C3
#4Because 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 iterate? Is it moving pointers or indexing them or what? Not only is it hiding logic but it also prevents me from modifying the logic. I could easily change a C for loop to use i += 2 instead of i++ if I wanted, that's the beauty of it. With this, I have to read some docs first to see how their abstraction works, and then hope it allows me to modify how it's used to how I need.
Re: Learning C3
#5> 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…
Re: Learning C3
#6C3 looks promising, but any language that supports nulls needs null-restricted types, not whatever those contract comments are. If I wanted to have to null-check everything, or YOLO it, I would just write Java... and even Java is seeking to fix this: https://openjdk.org/jeps/8303099
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.
Re: Learning C3
#7> 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…
Re: Learning C3
#8> 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…
It uses operator overloading of [] &[] and "len" to create a straight for loop. Normal C for loops are there of course.
[1] https://c3-lang.org/implementation-details/specification/#fo...
Re: Learning C3
#9Interviews:
- 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:
Re: Learning C3
#10Earlier quoted context omitted.
It uses operator overloading of [] &[] and "len" to create a straight for loop. Normal C for loops are there of course.
I just skimmed the C3 spec[1] on foreach and foreach_r, and I'm still confused as to how to move elements by anything other than 1, if it's even possible. [1] https://c3-lang.org/implementation-details/specification/#fo...