Happy new year all of you, hope you’ll doing/going well
Some new generation (> 2010) languages shares concepts about preventing undefined behaviours : Zig, Rust, and obviously Crystal
Do you have some online resources to read about the topic. I’m (for personal projects) a C coder and I like the freedom it gives (and responsibilities) to me but I also understand the pitfalls. I’ve some “friction” with the Crystal compiler (note that I “more or less” undestand them), and had A LOT of friction with Zig. So, because both languages share solutions to avoid undefined behaviours, I presume there must be some general topics to read online (not related with these languages), but I did not managed to find anything very meaningful
Not being a native english speaker, if this post is unclear fell free to ask me to rephrase
Don’t quote me on this, but I’d say that an undefined behavior is rather an undocumented behavior that different compilers (or the same compiler on different architectures) decide to implement different. More of a bug than a feature (although not always a fixable one without forcing a breaking change, like in C).
I like the freedom it gives (and responsibilities) to me but I also understand the pitfalls.
I think you’re conflating the terms “undefined behavior” and “safety”. The focus in languages like Crystal is in safety, which kind of implies treating each undefined behavior as a bug. Except, of course, when you explicitly ask for it by using a (typically documented) unsafe operation.
Regarding resources to read upon this, I’m not sure what’s the purpose. I know academics books on the topic. My preferred one is Types and Programming Languages, by Benjamin Pierce, but maybe that’s too much for your case?
Thanks for the clarification ! You’re absolutely right about the fact that I’m misunderstanding these concepts. With a better search keywords I’m confident now to find articles about safety when coding (depending on how each language famillies handle it, or how one can write better C code by applying strict rules, and so on), because I’m not enough advanced on the topic to read Pierce’s book