<story><title>Some Were Meant for C (2017) [pdf]</title><url>https://www.cs.kent.ac.uk/people/staff/srk21//research/papers/kell17some-preprint.pdf</url></story><parent_chain><item><author>aap_</author><text>I never really got that complaint, I&amp;#x27;d like to see some examples of what people consider so ugly about C strings.</text></item><item><author>drb91</author><text>I stopped writing C because string manipulation sucked.</text></item><item><author>aap_</author><text>I don&amp;#x27;t like how people on the internet hate on C all the time. To me C is a wonderfully simple and elegant language that I can most of the time very clearly express my thoughts in. I find that this not the case with many other languages. This is the reason I use C. Of course compiler writers are trying to sabotage this but I don&amp;#x27;t write any critical code so if I get hit by an occasional bug it&amp;#x27;s not a big problem.
I think C is misunderstood, perhaps because it is used everywhere and standards for critical pieces of software are applied to non-critical ones.
E.g. never freeing memory, even leaking it by destroying all references to it, can be totally fine if your program just runs for a few seconds. Just allocate what you need, throw it away, and let the OS clean up when you&amp;#x27;re done. This is perfectly fine but I feel like many people wouldn&amp;#x27;t accept this kind of code because it&amp;#x27;s not acceptable in other circumstances.&lt;p&gt;Anyway, the author makes a few good points that are important but often overlooked, but I don&amp;#x27;t think I&amp;#x27;d agree with him on the safety aspect in section 6. Making a safe C implementation doesn&amp;#x27;t really appear possible. If you allow casting integers to pointers, how do you implement these saftey checks he&amp;#x27;s talking about?</text></item></parent_chain><comment><author>pjmlp</author><text>1 - string contents and actual length are handled in separate variables without correlation&lt;p&gt;2 - no enforcement that a null terminator actually exists in the string&lt;p&gt;3 - C brags about performance and is probably the slowest language to compute string length&lt;p&gt;4 - manipulating strings requires very carefull handling of buffers, usually forcing everyone to use the heap as easier way out</text></comment>
<story><title>Some Were Meant for C (2017) [pdf]</title><url>https://www.cs.kent.ac.uk/people/staff/srk21//research/papers/kell17some-preprint.pdf</url></story><parent_chain><item><author>aap_</author><text>I never really got that complaint, I&amp;#x27;d like to see some examples of what people consider so ugly about C strings.</text></item><item><author>drb91</author><text>I stopped writing C because string manipulation sucked.</text></item><item><author>aap_</author><text>I don&amp;#x27;t like how people on the internet hate on C all the time. To me C is a wonderfully simple and elegant language that I can most of the time very clearly express my thoughts in. I find that this not the case with many other languages. This is the reason I use C. Of course compiler writers are trying to sabotage this but I don&amp;#x27;t write any critical code so if I get hit by an occasional bug it&amp;#x27;s not a big problem.
I think C is misunderstood, perhaps because it is used everywhere and standards for critical pieces of software are applied to non-critical ones.
E.g. never freeing memory, even leaking it by destroying all references to it, can be totally fine if your program just runs for a few seconds. Just allocate what you need, throw it away, and let the OS clean up when you&amp;#x27;re done. This is perfectly fine but I feel like many people wouldn&amp;#x27;t accept this kind of code because it&amp;#x27;s not acceptable in other circumstances.&lt;p&gt;Anyway, the author makes a few good points that are important but often overlooked, but I don&amp;#x27;t think I&amp;#x27;d agree with him on the safety aspect in section 6. Making a safe C implementation doesn&amp;#x27;t really appear possible. If you allow casting integers to pointers, how do you implement these saftey checks he&amp;#x27;s talking about?</text></item></parent_chain><comment><author>flohofwoe</author><text>I agree, but C (the language) doesn&amp;#x27;t even have the concept of a &amp;#x27;string&amp;#x27;. It&amp;#x27;s just the convention how some C standard library functions interpret an array of bytes with a zero at the end.&lt;p&gt;At least in C it&amp;#x27;s quite obvious that strings are not trivial if you want both an intuitive way to work with strings, and high performance. The C++ std::string type is neither intuitive to work with, nor does it allow to write high-performance code.&lt;p&gt;For string processing it&amp;#x27;s really better to use another language with different trade-offs.</text></comment>