4 ms·
Poul-Henning Kamp: The Most Expensive One-byte Mistake
- zurn 15y agoVery good article. There is a huge cultural blindfold that Unix/C have formed indirectly formed on everybody's thinking about computers. Most of us have never used computers outside the Unix sphere of influence. The point about hardware (in this case instruction set) adapting to Unix/C strings is also a recurring pattern, and makes it hader to climb out of the pit of local optimum /path dependence. Fun thought experiment to think how things might have turned out if ideas from Burroughs mainframes, Transputer, Lisp machines or Intel i432 type of things had taken off. But Unix was easy to port because of simplicity, kinda-open-source for universities, etc. even though those properties soon disappeared after it became popular. And we know the rest.
- wladimir 15y agoUnix is not all-terrible though. It also has quite a few very sane ideas such as combining simple commands into pipelines and "everything is a file descriptor". I do agree that zero-terminated strings are the worst idea ever. It's almost impossible to use them in a secure and performant way (at the least it requires a lot of extra thinking). Alternative string libraries such as bstring make string handling in C sane, but unfortunately the default C strings mean a lot of people still use char* and str(l)cpy/str(l)cat/strlen/... The worst thing is that many are religiously convinced that it is a good idea just because it's the UNIX and C way (TM). It's so deeply ingrained.
- epo 15y agoActually most have never knowingly used computers outside the Windows sphere of influence but we shall let that pass. Unix was a massive breath of fresh air at the time, it became popular and widespread because it was so much better (and more accessible/cheaper) than commercial operating systems of the time. The cultural bindfold you refer to is because there has been no comparable revolution in operating systems design since Unix, people tinker (comparatively) at the edges because Unix got so much right. NUL terminated strings is a minor aspect of library design. Yes with hindsight if things had been done differently then things might now be different, but like the QWERTY keyboard once decisions get out in the world they become too difficult to reverse.
- arethuza 15y ago"Fun thought experiment to think how things might have turned out if ideas from Burroughs mainframes" Have you ever used a Burroughs mainframe? They did have a rather wonderful architecture but the interactive user experience from CANDE left a lot to be desired.
- daeken 15y agoI don't think anyone is saying that we should go back to Burroughs mainframes, or anything else from the past for that matter. But we should definitely draw more inspiration from them.
- arethuza 15y agoSorry, bit of a knee jerk reaction there, clearly the eldritch horror that was Burrough's idea of an interactive user environment left me with some mental scars. However, one positive thing about briefly using CANDE was that it made me REALLY appreciate Unix when we eventually moved to using it.
- wglb 15y agoLike the idea of virtual memory?
- gaius 15y agoYes; it's next to impossible to buy a processor now that isn't really a "C-machine", just as Symbolics made "Lisp machines" (or Chuck Moore will sell you a "Forth machine" with hardware designed to efficiently deal with stacks). The concept that processors really aren't language-agnostic (i.e. they actually do care whence originated the machine code) needs more publicity.
- deleted 15y ago[deleted]
- EvilTerran 15y ago"the costs of the Ken, Dennis, and Brian decision will keep accumulating, like the dust that over the centuries has almost buried the monuments of ancient Rome" ... look upon my gets(), ye mighty, and despair?
- franciscoapinto 15y agoInteresting discussion on the rationale behind null-terminated strings: http://stackoverflow.com/questions/4418708/whats-the-rationale-for-null-terminated-strings http://stackoverflow.com/questions/4418708/whats-the-rationa...
- pja 15y agoI knew without looking that this was going to be about NUL-terminated strings. Now, if it had been about NULL pointers, then Tony Hoare has called them his billion $ mistake. Is there an anti-pattern here?
- pja 15y agoThinking about it, NULL in SQL databases has been a big source of issues too. NULL. Just say no :)
- josteink 15y agoA programmer who worked with the compilers on the Convex C3800 series supercomputers related his experience as "having to program as if the compiler was my ex-wife's lawyer." Reading this made me realize very few people fully appreciate how good compilers have become these days. I'll add some love to the MS C# compiler, despite its shortcomings, just because whoever worked on it absolutely deserves some love.