<story><title>Learn enough C to survive</title><url>https://codeofhonor.substack.com/p/learn-enough-c-to-survive</url></story><parent_chain><item><author>stevekemp</author><text>Compared to writing code in assembly language it is a dream, though!&lt;p&gt;I think C lets you think about low-level details of how systems work, strings being arrays of characters with an explicit terminating NUL character, for example.  Although again assembly language gives you _real_ lower-level understanding and insights if you use it.</text></item><item><author>Beltalowda</author><text>I can&amp;#x27;t say I learned much by programming in C, if I even learned anything at all. Mostly I just grumble at the needlessly verbose and complex way of doing some things (e.g. anything with strings) and get annoyed by the syntax and quirks of the language and surrounding toolchain.&lt;p&gt;It is of course &lt;i&gt;useful&lt;/i&gt; for a whole bunch of reasons, including being able to figure out &amp;quot;why does this do X?&amp;quot;, but that&amp;#x27;s not really &amp;quot;deeper knowledge&amp;quot;, IMO.</text></item><item><author>throwawaaarrgh</author><text>You should learn C because it&amp;#x27;s a gateway to deeper knowledge. The kernel uses it, about a thousand programs shipped with Linux use it, embedded programming uses it. It helps you understand how lower level network protocols have been designed, how to efficiently use memory, how to design algorithms and why they&amp;#x27;re harder than you think. There&amp;#x27;s a crapton of libraries in C, most higher level languages have some extensions to take advantage of them. Sensitive security software will use it, due to various attack vectors that are slightly easier to deal with at a lower level. It&amp;#x27;s handy and expands your brain. And it&amp;#x27;s not going away anytime soon.</text></item></parent_chain><comment><author>cyber_kinetist</author><text>By the way, null-terminated strings are not the only way to express strings, it’s a legacy of C that many low-level programmers dislike but need to stick to it because of legacy reasons (every major OS is written in C).&lt;p&gt;All the low-level languages aiming to replace C basically abandoned this approach, and opted for slices instead (ptr + size pair, used in Rust, Zig, etc.) This has the benefit of easier and faster string manipulation (strlen can be O(1) instead of O(n)), as well as better memory safety (can do bounds checking with the size information). The primary reason we are still using and teaching null terminators is because we still have to live with POSIX&amp;#x2F;Win32 and many low-level libraries written on this platform.</text></comment>
<story><title>Learn enough C to survive</title><url>https://codeofhonor.substack.com/p/learn-enough-c-to-survive</url></story><parent_chain><item><author>stevekemp</author><text>Compared to writing code in assembly language it is a dream, though!&lt;p&gt;I think C lets you think about low-level details of how systems work, strings being arrays of characters with an explicit terminating NUL character, for example.  Although again assembly language gives you _real_ lower-level understanding and insights if you use it.</text></item><item><author>Beltalowda</author><text>I can&amp;#x27;t say I learned much by programming in C, if I even learned anything at all. Mostly I just grumble at the needlessly verbose and complex way of doing some things (e.g. anything with strings) and get annoyed by the syntax and quirks of the language and surrounding toolchain.&lt;p&gt;It is of course &lt;i&gt;useful&lt;/i&gt; for a whole bunch of reasons, including being able to figure out &amp;quot;why does this do X?&amp;quot;, but that&amp;#x27;s not really &amp;quot;deeper knowledge&amp;quot;, IMO.</text></item><item><author>throwawaaarrgh</author><text>You should learn C because it&amp;#x27;s a gateway to deeper knowledge. The kernel uses it, about a thousand programs shipped with Linux use it, embedded programming uses it. It helps you understand how lower level network protocols have been designed, how to efficiently use memory, how to design algorithms and why they&amp;#x27;re harder than you think. There&amp;#x27;s a crapton of libraries in C, most higher level languages have some extensions to take advantage of them. Sensitive security software will use it, due to various attack vectors that are slightly easier to deal with at a lower level. It&amp;#x27;s handy and expands your brain. And it&amp;#x27;s not going away anytime soon.</text></item></parent_chain><comment><author>Beltalowda</author><text>It&amp;#x27;s useful to know how things like strings and arrays work and that they&amp;#x27;re not just &amp;quot;magic&amp;quot;, but I don&amp;#x27;t think you really need to learn C to do that. I understood that kind of stuff long before I did any serious C programming, and knowing C didn&amp;#x27;t really add much to that. The thing is that I don&amp;#x27;t want to think about it &lt;i&gt;every time&lt;/i&gt;.&lt;p&gt;I &amp;quot;just&amp;quot; want to do X, but instead I need to write a whole bunch of code to handle it all manually. It&amp;#x27;s useful that this is possible, but a lot of times you don&amp;#x27;t need it, and some other languages still keep the &amp;quot;common case&amp;quot; easy while still enabling the high-performance stuff C can do.&lt;p&gt;I wish we had C+: C + a few niceties (and not C ++ everything). There&amp;#x27;s a whole bunch of newer languages aiming at the space C is sitting in, but with a few additions C could be much more ergonomic without having to invent an entire new language.</text></comment>