5 ms·
Hindsight isn't really in play, here. The examples given are just plain wrong, rather than outmoded.
by Xophmeister 8y ago
Hindsight isn't really in play, here. The examples given are just plain wrong, rather than outmoded.
- bitL 8y agoBack in those days 100 bytes was like a huge string; when you raised your hands that there will be a problem you were told to shut up, that you don't get the efficiency of computing and that you won't see strings longer than 16 characters or similar. This Zeitgeist is completely lost and viewing it with contemporary optics is just funny at best. IIRC most of early hacks on Internet exploited the lack of boundaries in strings and returning pointers on stack, which is something the book author got wrong but given how wide-spread it was, likely most of C programmers were doing it incorrectly. With contemporary optics I'd tend to say: "It's purely fault of C language designers!" but I know better.
- irishsultan 8y agoThis doesn't explain why one would ever want to return a pointer to a local variable.
- blub 8y agoAs mentioned by another commenter, they were probably targeting the Keil C51 compiler which stores local function arguments in fixed memory locations: https://news.ycombinator.com/item?id=17399633 https://news.ycombinator.com/item?id=17399633
- mikeash 8y agoUnless the book states this explicitly and explains that their examples are only good with that compiler and are not actually valid C, that doesn’t really help.
- bitL 8y agoWhy would you assume the book author (if he indeed used Keil C51) would be aware of more dialects and their intricacies? Do you really think that in the early 90s there was a wide-spread rigor in software books? There was no Internet, whatever software one could get was the one that was their "standard", there was very limited knowledge exchange between academia and practitioners etc.
- mikeash 8y agoI’d assume that because he wrote a book about “C”, not about “C targeted for the Keil C51 compiler.” I read plenty of programming books around that time. They were almost always specific to some platform, but they always said so. I never saw, say, a “Pascal” book that turned out to be completely specific to ORCA/Pascal. It would say what it was for.
- mannykannot 8y agoIn the 90's there was at least one good software book: 'The C Programming Language' by messrs. Kernighan and Ritchie - you may have heard of it? It correctly told you, among other things, everything you really need to know about using pointers in C. It is still available.
- bitL 8y agoI was a kid back then; K&R was pretty hard to find in my area and it was quite outdated anyway, most people were happy to use whatever resources they could get; the best in mid-to-late 90s ended up things like what DJ Delorie wrote, stuff from John Carmack, Dave Eberly etc. that were pretty low on rigor but very high on practical value.
- mannykannot 8y agoYou are defending 'Mastering C Pointers' on the grounds that K&R was outdated?
- 8y ago
- mannykannot 8y agoBy following the link in that post, you can see that this is a niche product, for the Intel MCS-51 microcontroller.