6 ms·
The author linked to this site: https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard https://www.securecoding.cert.org/confluence/d
by AndyKelley 11y ago
The author linked to this site: https://www.securecoding.cert.org/confluence/display/c/SEI+CERT+C+Coding+Standard https://www.securecoding.cert.org/confluence/display/c/SEI+C...
These are wonderful. Concise nuggets of knowledge that you can keep in your head, little warnings of what not to do.
Side note, it's really fun reading this article about modern C given that I'm working on an experimental programming language meant to replace C [1]. Just today I got the Guess Number Game example working, without a dependency on libc [2] (caveat: Linux x86_64 only so far). So, I'm having fun trying to think about how C could be better, reading implementations of various libc functions, and writing my own "standard library".
For example, in my language, there are no `int`, `unsigned char`, `short` types, there are only `i32`, `u8`, `i16`, etc (I shamelessly stole this idea from Rust). This mirrors the article's suggestion to only use int32_t, uint8_t, int16_t, etc. But, since it's a new programming language, we don't have the other types sitting there as a red herring.
[1]: https://github.com/andrewrk/zig https://github.com/andrewrk/zig
[2]: https://gist.github.com/andrewrk/131e6f48a15c42fc5ca8 https://gist.github.com/andrewrk/131e6f48a15c42fc5ca8
- WalterBright 11y ago> there are only `i32`, `u8`, `i16`, etc (I shamelessly stole this idea from Rust). Those are very old ideas.
- kibwen 11y agoAnd Rust stole them from very old languages, but you haven't at all refuted the author's statement. :P
- ilek 11y ago>only `i32`, `u8`, `i16` While these are not new ideas - Why not use s32 rather than i32 and so on. Makes more sense if you use something like u32 too. I think it's important when making another language to really question everything you do in it. Why use this operator, or why use this mnemonic for built in types?
- masklinn 11y ago> While these are not new ideas - Why not use s32 rather than i32 and so on. Makes more sense if you use something like u32 too. i denotes an integral, as opposed to the also-signed float types?
- deleted 11y ago[deleted]