7 ms·
A comprehensive guide to 50 years of evolution of strict C programming
- edwcross 5y agoThis seems mostly a guide from a 42 School student towards other 42 School students. It shows one of the issues of having previous-year students teaching younger students: they don't always have enough experience to know the best way to teach things. Overall, the title is very misleading, a better one would be "42 School Cheat Sheet", ideally with "by a former 42 School student" appended.
- nyanpasu64 5y agoC/C++ is broken by design. The compiler doesn't teach people to avoid UB, but silently outputs incorrect programs when it occurs. As a result, the majority of C/C++ programs are written incorrectly and suffer from undefined behavior, which (at best) segfault consistently and (at worst) have unpredictable or exploitable crashes. Many mature programs, written by people who should know what they're doing, have ongoing UB fixes to patch over long-running mistakes as they're discovered.
- jacquesm 5y agoWater is wet. But what did you think about the guide?
- pjmlp 5y agoI expected a security programming oriented guide, given the title.
- jacquesm 5y agoThey lost me at 'float' -> used for computer graphics. Whoever wrote this spent a ton of time putting this together but failed at providing value.
- samisallinen 5y agoAt least in computer games that handle lots of 3d coordinate data, floats instead of doubles were/are used to save memory bandwidth + some exedcution time on at least old x87 fpus. Which is also why old versions of DirectX (8 or 9) on windows used set the FPU for half-precision math when initialized. But yeah.
- ac130kz 5y agoI wouldn't call it "strict C programming", the article doesn't talk about strict safety standards, for example, MISRA C. It doesn't even mention _s functions either. I think a proper title should be "common misconceptions and useful tips".
- sasaf5 5y agoWhat's with all the Korean?
- sasaf5 5y agoI see now, the author seems to be interested in Korean language and culture.
- outsomnia 5y agoThe document just seems to be an abnormally huge trolling activity from someone with too much spare time on their hands. I stopped even scanning it when the "solution" for the "common beginner mistake" of array overflow is not sizeof() but ``` { const int len = 5; int a[len] = {1,3,5,7,9}; ```
- WithinReason 5y agoIt doesn't even compile: prog.c: In function ‘somefunction3’: prog.c:8:2: error: variable-sized object may not be initialized int a[len] = {1,3,5,7,9}; ^~~
- moonchild 5y agoIt gets better: > if you want to modify a value you either have to use a pointer to the memory address: void increment_a(int *a) { *a++; } int solve(void) { int a = 5; increment_a(&a); }
- redis_mlc 5y agoAnybody got a suggestion for how to write a C program that's portable across different versions of openssl (TLS)?
- WantonQuantum 5y agoAs someone who's been writing C since the mid 90s, this is mostly rubbish and would be a terrible way to learn C.
- montblanc 5y agoHey are there any good resources you'd recommend?
- resonious 5y agoI recommend searching up "Handmade Hero" if you're interested in getting into C programming and are okay with videos instead of text (though there are text transcriptions) I think technically he uses a C++ compiler but he doesn't use C++ features. It's the mindset of thinking about the hardware that helps in my opinion. Also I'm not sponsored or anything. I just really enjoy the series.
- montblanc 5y agoIs this what you mean? https://handmadehero.org/ https://handmadehero.org/ holy crap there's an enormous amount of videos in there. Thing is it's meant for Windows from what I'm seeing and also isn't really divided into topics (let's say I just wanna learn about pointers or about macros).
- zokier 5y ago"Effective C" and "Modern C" are two books frequently recommended. I'm waiting both to arrive in mail to see them myself.
- bestcoder69 5y ago“Don’t even try to flirt with girls” is an interesting tip for a C programming guide, but I don’t have enough experience with the language to know if it’s wrong. Disclaimer: Happily married java.* programmer.
- spacechild1 5y agoHere's another gem: int allocate_memory(void) { int *matrix; if (!(matrix = malloc(sizeof(int) * 9))) // this is short for matrix = malloc(sizeof(int) \* 9; if (matrix == NULL) return NULL; // the malloc is now protected, return matrix; }