Some C habits I employ for the modern day
1–10 of 162 posts
Re: Some C habits I employ for the modern day
#2Re: Some C habits I employ for the modern day
#3Nice post, but the flashy thing on the side is pretty distracting. I liked the tuples and maybes.
Re: Some C habits I employ for the modern day
#4Nice post, but the flashy thing on the side is pretty distracting. I liked the tuples and maybes.
Not distracting at all, it feels nostalgic to me. Id rather have these flashy things than a million popups and registration forms following you around, which is basically the modern web. I hate it so much. This site is pure balsam for my soul.
Re: Some C habits I employ for the modern day
#5With enough compiler support they could be more than that. For example, I submitted a tagged union analysis feature request to gcc and clang, and someone generalized it into a guard builtin.
https://github.com/llvm/llvm-project/issues/74205
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112840
GCC proved to be too complex for me to hack this in though. To this day I'm hoping someone better than me will implement it.
Re: Some C habits I employ for the modern day
#6Instead use the stack much more and have a limit on how much data the program can handle fixed on startup. It adds the need to think what happens if your system runs out of memory.
Like OP said, it's not a solution for all types of programs. But it makes for very stable software with known and easily tested error states. Also adds a bit of fun in figuring out how to do it.
Re: Some C habits I employ for the modern day
#7#define END }
/* scream! */
Re: Some C habits I employ for the modern day
#8> In the absence of proper language support, “sum types” are just structs with discipline. With enough compiler support they could be more than that. For example, I submitted a tagged union analysis feature request to gcc and clang, and someone generalized it into a guard builtin. https://github.com/llvm/llvm-project/issues/74205 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112840 GCC proved to be too complex for me…
For instance, it appears that no amount of proper discipline, even in the best developers, allows to replace proper array support with a naked pointer to a memory area.
Re: Some C habits I employ for the modern day
#9I still have a lot of conversion to do before I can try this in my hobby project, but these are interesting ideas.
Re: Some C habits I employ for the modern day
#10Regarding memory, I recently changed to try to not use dynamic memory, or if I need to, to do it once at startup. Often static memory on startup is sufficient. Instead use the stack much more and have a limit on how much data the program can handle fixed on startup. It adds the need to think what happens if your system runs out of memory. Like OP said, it's not a solution for all types of programs. But it makes for v…