3 ms·
The Most Expensive One-Byte Mistake (2011)
- fargle 7y agoNot the worst paper, but I had to get to the bottom before the author regains partial sanity. Of course we shouldn't really blame K&R(&K) for the _mistake_ right? (a little backhanded argument, IMHO). Except, um, it wasn't a mistake. It was an on-purpose. They were fully aware of the pros and cons of the approach they picked, and the long term success of their systems is testament to them balancing those trades, and a hundred others, very effectively. The author even goes on to explain he had no information about why they choose that option. Which undercuts the whole argument. Still, a sensational headline though! Furthermore null-terminated strings are not the cause of any particular problem. They work fine. They are merely a contributing factor to the bugs. The enable a certain class of common bugs, but do not cause them. I'll tell you another not-a-mistake they made. Making things like string handling part of the library, written in the high(ish)-level language, not part of the compiler and language itself. You are completely free to use whatever kind of strings you want, if they are better. Like http://bstring.sourceforge.net http://bstring.sourceforge.net. Which I have never done - why? because C-strings work just fine for what I need. But the library is just a toolbox and C-strings are one of those tools. It is a poor workman indeed who blames his tools.