4 ms·
It was a bad essay at the time and I don't think you can make a good essay by trying to build off it. Adding "megachurch" to the already strained metaphor didn'
by tptacek 10mo ago
It was a bad essay at the time and I don't think you can make a good essay by trying to build off it. Adding "megachurch" to the already strained metaphor didn't improve it.
https://news.ycombinator.com/item?id=35939383 https://news.ycombinator.com/item?id=35939383
- deleted 10mo ago[deleted]
- networkadmin 10mo ago[flagged]
- wizzwizz4 10mo agoPeople are still talking about null pointers: that doesn't mean they were ever a good idea.
- networkadmin 10mo agoThat's just how the hardware works. Don't like it? Make your own CPU.
- wizzwizz4 10mo agoNo, the CPU doesn't have a special pointer value which is designated invalid (except as far as modern address spaces are so large that you cannot possibly map memory to each address without mirroring). In many OSs, e.g. CP/M, address 0 is actually meaningful. The C idiom of cramming sum-type semantics into the nooks and crannies of a return value that ordinarily means something entirely different is an extremely poor one, and null pointers are the poster child: Tony Hoare's billion-dollar mistake. It's absolutely fine to have a packed representation of a sum type "under the hood": this is how Rust implements Option<&T> (where T: Thin), for example. It's also fine to expose the layout of this packed representation to the programmer, as C's union does. But it's a huge footgun to have unchecked casts as the default. If not for this terrible convention, C wouldn't have any unchecked implicit casts: something like f(1 + 0.5) performs a coercion, a far more sensible behaviour. The only reason we're talking about null pointers at all is because they were an influential idea, not because they were a good idea. Likewise with the essay.
- leoc 10mo agoWhile it's narrowly true that CPU instruction sets generally don't have a null-pointer concept, I'm not sure how important that is: the null pointer seems to have been (I don't know enough to be sure) a well-established idiom in assembly programming which carried across naturally to BCPL and C. (In much the same way that record types were, apparently, a common assembly idiom long before they became particularly normal to have in HLLs.) Programmers like being able to null out a pointer field, 0 is an obvious "joker" value, and jump-if-0 instructions tend to be convenient and fast. Whether or not you'd want to say it's "how the hardware works" it does seem to have a certain character of inevitability. Even if the Bell Research guys had disapproved of the idiom they would likely have had difficulty keeping it out of other people's C programs once C became popular. The Hoare ALGOL W thing seems to be more relevant to null pointers in Java and the like.
- wizzwizz4 10mo ago> Programmers like being able to null out a pointer field, 0 is an obvious "joker" value, and jump-if-0 instructions tend to be convenient and fast. And there's nothing wrong with that! But you should write it union { char *ptr; size_t scalar; } my_nullable_pointer; if (my_nullable_pointer.scalar) { printf("%s", my_nullable_pointer.ptr); } not: char *my_nullable_pointer; if (my_nullable_pointer) { printf("%s", my_nullable_pointer); } Yes, this takes up more space, but it also makes the meaning of the code clearer. typedef in a header can bring this down to four extra lines per pointer type in the entire program. Add a macro, and it's five extra lines plus one extra line per pointer type. Put this in the standard library, and the programmer has to type a few extra characters – in exchange for it becoming extremely obvious (to an experienced programmer, or a quick-and-dirty linter) when someone's introduced a null pointer dereference, and when a flawed design makes null pointer dereferences inevitable. > The Hoare ALGOL W thing seems to be more relevant to null pointers in Java and the like. I believe you are correct; but I like blaming Tony Hoare for things. He keeps scooping me: I come up with something cool, and then Tony Hoare goes and takes credit for it 50 years in the past. Who does he think he is, Euler?
- II2II 10mo ago> No, the CPU doesn't have a special pointer value which is designated invalid Sort of right, sort of wrong. From my understanding: older, simpler, architectures treat memory location zero as a normal memory address. On x86 and x64, the OS can configure the MMU to treat certain pages as invalid. Many years ago, I ran across a reference to Sparcs treating accesses to memory location zero as invalid. In other words, it depends upon which architecture you're dealing with.
- tptacek 10mo agoSo the case that you're making here is that CATB is renowned amongst the kind of practitioners who think NULL pointers are "just how the hardware works". Sounds about right.
- dvt 10mo agoI know you're replying to a brand new (likely troll) account, but I'm also very confused by this and would be curious to learn if there's any truth to it. I personally don't really see what a Von Neumann machine has to do with null pointers (or how an implication would go either way), but maybe I'm missing something.
- tptacek 10mo agoIt has nothing to do with NULL pointers and is instead a property of a programming language.
- z3512 10mo agoNULL pointers working the way they do was a design decision made my hardware engineers a long time ago because it saved some transistors when that mattered. We’re past that point now for most ASICs and hardware can be changed. Although backward software compatibility is a thing too.
- wizzwizz4 10mo agoNull pointers have nothing to do with the instruction set architecture, except as far as they are often represented by the value 0. Can you describe the scheme you're imagining, whereby their use saves transistors?
- networkadmin 10mo ago[dead]
- networkadmin 10mo ago[dead]
- mrkeen 10mo agoThey aren't there in asm.
- charcircuit 10mo agomov rax, qword ptr [0]
- nyc_data_geek1 10mo agoThere are lots of proven bad ideas still being bandies about today, and it does not prove they are anything but enduringly worthless.
- munificent 10mo agoPeople are still talking about a flat Earth and creationism. Given 8 billion people, there are enough available braincells to keep even the stupidest idea floating around in the memesphere.
- sethev 10mo agoAs you point out in your linked comment, the original essay captured the zeitgeist of the time. It also influenced and inspired many people. From that perspective, it's hard for me to agree that it was bad. However, I don't think the content was original at the time (perhaps that's what you mean by bad?) - in the sense that ESR wasn't out ahead of people blazing some new trail and it also didn't hold up very well factually.
- Taniwha 10mo agoYeah, it's worth remembering that at the time a compiler cost $10k+, an OS $1000s/year - you couldn't work on OS or compiler work unless you worked for a big hardware company - a whole lot of interesting work was locked away from most programmers
- sethev 10mo agoYes, that is the context in which I first read it (likely around 1999 when it appeared on slashdot), as a senior in high school with no access to the tools used by most professional programmers at the time.
- tptacek 10mo agoFreeBSD 2.0 was 1994.
- sethev 10mo agoYes, I'm speaking about my experience as I remember it - not what was objectively possible for someone with the right resources and knowledge at the time :)
- tptacek 10mo agoRight, I'm not so much pushing back on you as I am establishing a chronology for CATB. Ordinary people were absolutely belting out (what we would now call) open source software by the time it was written. (That's not the biggest flaw in the essay, of course. It made predictions, some of which turned out to be comically wrong. The true parts of it weren't new, and the new parts of it weren't true.)