5 ms·
>Maybe in another 60 it will get proper strings and arrays. If you think this is missing, there's a big chance you don't "get" C. Also, if you don't know how
by moralestapia 5y ago
>Maybe in another 60 it will get proper strings and arrays.
If you think this is missing, there's a big chance you don't "get" C.
Also, if you don't know how to properly emulate strings in a safe way in C nowadays (for which plenty of code sample and librariesexist), your skills with the language are quite poor.
- pjmlp 5y agoI surely get C, having to deal with its casualties in DevSecOps. I have been "getting" C since 1992, across Xenix, DG/UX, HP-UX, Solaris, AIX, FreeBSD, Linux, Amiga, Windows 3.x,.....
- moralestapia 5y agoWell, then, you must know it's not really a big deal to write code with proper memory checks.
- coldtea 5y agoIf you think that, then you really don't get C - not as in "it's intents", but as in its actual history and repurcursions...
- pjmlp 5y agoI have found yet another C expert. https://www.cvedetails.com/vulnerability-list/opmemc-1/memory-corruption.html https://www.cvedetails.com/vulnerability-list/opmemc-1/memor...
- dnautics 5y agoIt's a big deal, you need about 1/3 of sel4 proofs
- nec4b 5y agoYou once claimed C requires UNIX like OS to run.
- coldtea 5y agoAnd he was right. He didn't mean it as a statement of fact (which would be wrong, and he already knew it).
- nec4b 5y agoNo he was definitely wrong. Ask any C developer. His comment: https://news.ycombinator.com/item?id=20828974 https://news.ycombinator.com/item?id=20828974
- pornel 5y agoWhen I complain C's portability sucks, because it can't do anything useful without a ton of ifdefs, people tell me it's not a problem, I should just use POSIX. https://twitter.com/rygorous/status/1224413742667988992 https://twitter.com/rygorous/status/1224413742667988992
- pjmlp 5y agoI claim it yet again on this very comment. Without UNIX spreading with its free beer into universities, C would have been a footnote on the history of system programming languages.
- nec4b 5y agoNope in the above comment you claim something else. Here is where you claim C requires UNIX like OS: https://news.ycombinator.com/item?id=20828974 https://news.ycombinator.com/item?id=20828974 Let me tell you, in embedded development we run C on bare metal or under RTOS. There is no UNIX in sight. And the code is portable to many CPU architectures.
- pjmlp 5y agoA snowflake RTOS without POSIX, call me amazed.
- mhh__ 5y agoAdding so-called fat pointers to C that could be bounds checked would probably instantly eliminate a large fraction of all security issues. Of course, you can emulate these yourself, it's just a struct but not everyone does.
- flohofwoe 5y agoAdding opaque builtin struct types to C would be kind of a big deal though and would probably creep into other parts of the language and interact with them in unexpected ways. Features like fat pointers, slices, builtin dynamic arrays/strings or tagged unions would all require builtin opaque structs. This would be a whole different language (closer to Zig).
- mhh__ 5y agoIt really wouldn't be that hard to do. The syntax would be trivial, and the whole point is that you want it to creep so people actually use them. There's no overhead to doing it, but you save a bunch of bugs earlier, all for stopping conflating arrays with pointers, which is something not much code does these days anyway
- Findecanor 5y agoC99 introduced variable-length array parameters and variable-length array pointers together with variable-length arrays (VLA). These take another parameter or variable as a length-parameter. These became optional in C11 together with VLAs (for some reason) but are supposed to again become mandatory in C23. However (yet, for some reason) the pointers can (in the latest published draft, still) only be inside procedures: not in structs or in global variables. I think it would not be impossible for a C compiler to detect and produce a warning if an index used with such an array-pointer is not checked against the array-pointer's length variable. This would not make bounds-checks automatic, but the use of these types could make compilers point out when bounds are not checked or checked incorrectly.
- melissalobos 5y agoPeople don't really get the distinction you make here, which is a shame. Often any VLA's are outlawed which is tossing the baby out with the bathwater.