23 ms·
Massacring C Pointers
- garryc01304 8y agoGARRY COLE We are a group of professional hackers,we are seasoned and professional hackers ...as a way of giving back to the world we are here to help with all hacking jobs some of which are , HACK INTO ANY SCHOOL DATABASE AND CHANGE UNIVERSITY GRADES, no matter how secured...Find out if your partiner is cheating ...... - Hack INTO ANY BANK WEBSITE - Hack into any COMPANY WEBSITE - HACK INTO ANY GOVERNMENT AGENCY WEBSITE - HACK INTO SECURITY AGENCY WEBSITE AND ERASE CRIMINAL RECORDS - Hack into CRAIGSLIST AND REMOVE FLAGGING - HACK INTO ANY DATABASE SYSTEM - HACK PAYPAL ACCOUNT - HACK WORD-PRESS Blogs - SERVER CRASHED hack - UNTRACEABLE INTERNET PROTOCOL etc - HAVE YOU OR YOUR CHILD BEEN BULLIED ONLINE BEFORE AND WANT TO GET BACk this are few among alll we can do try us out and you will not be disappointed we do all jobs with HONESTY .... Contact easyhackingguru@gmail.com WhatsApp/text:--- +12168104481
- bunkydoo 8y agoest a, cursus sodales sapien. Nunc euismod tortor sit amet lectus accumsan, et pulvinar nisl faucibus. Pellentesque eget nulla consectetur metus tempor cursus. Duis luctus molestie consectetur. Donec nec malesuada lectus. In mollis mattis ipsum. Fusce tristique molestie accumsan. Nulla id nunc elit. Pellentesque molestie metus eu ullamcorper dictum. Curabitur congue nec lectus viverra lacinia. Praesent finibus posuere enim, et dapibus mauris blandit vitae. Pellentesque sed lobortis nibh. Ut vel nibh a lorem egestas vehicula. Nulla pharetra ultricies dui, a elementum ex iaculis ac. Pellentesque sed purus ut nisl facilisis accumsan. Aenean sit amet dui molestie, scelerisque mauris nec, imperdiet nulla. Donec pharetra dignissim urna, nec porta metus fringilla et. Morbi non dui a lectus ultricies vestibulum sit amet et justo. Etiam purus neque, vulputate id feugiat in, cursus at velit. Integer in nulla at nibh ullamcorper congue hendrerit eu ante. Duis eu est leo. Maecenas scelerisque imperdiet blandit. Duis velit urna, facilisis ut euismod ut, luctus sed urna. Ut quis nisi bibendum, faucibus risus quis, fringilla risus. Ut odio dolor, porta sed consequat ut, mattis non ante. Quisque a ligula non lectus lacinia tristique sed in sapien. Mauris aliquet sed mi non commodo. Pellentesque semper a erat vel semper. Sed consequat cursus fermentum. Sed eu velit accumsan, viverra eros vitae, fringilla risus. Nunc ut leo id mauris consectetur volutpat. Fusce nec eleifend urna. Ut consequat vitae velit ac imperdiet. Nunc rhoncus vehicula libero, id finibus dui egestas at. Donec laoreet erat eget lobortis commodo. Aliquam at felis fringilla, vehicula est a, aliquet purus. Praesent ullamcorper dui porttitor, sodales ante id, mattis lacus. Quisque pretium dolor mi, vel placerat dui rhoncus sollicitudin. Vivamus tincidunt turpis a ante ultricies placerat. Mauris dapibus orci elementum lorem ultricies varius. Aenean commodo facilisis nisi, id egestas lectus tempus vitae. Aenean id ante at nisi vestibulum ornare. Nunc pulvinar ex augue, eu ultricies ligula vehicula a. Vivamus tempus, massa sit amet interdum egestas, elit ligula congue ligula, vel suscipit turpis sem in est. In eu elit massa. Mauris mauris leo, lobortis sed sollicitudin non, consequat vitae augue. In sed arcu eget quam dapibus hendrerit. Sed et egestas dui. Cras sed turpis tempor, interdum enim ornare, tempor mauris. Sed id tempor ante, in semper arcu. Praesent sollicitudin quam at sem consequat, vitae lobortis neque rutrum. Cras nec sollicitudin arcu. Morbi purus ante, elementum quis sapien ac, fermentum imperdiet sapien. Proin et accumsan est. Aenean tellus elit, tempus vitae dictum sed, condimentum in ligula. Maecenas rhoncus, libero ac efficitur iaculis, lacus ipsum vulputate nisl, at vulputate magna libero consequat magna. Phasellus consequat molestie nisl, vel aliquet ante ultrices non. Morbi rutrum vestibulum semper. Ut suscipit tincidunt velit, eu posuere ligula vulputate sit amet. Cras nec blandit tortor, a facilisis ipsum. Donec lacinia, metus maximus elementum porta, lacus nibh viverra lorem, nec faucibus nulla ipsum sit amet nulla. Etiam nunc tortor, volutpat non blandit at, porta et felis. Nunc malesuada ante ac sodales viverra. Mauris sollicitudin elit at iaculis iaculis. Sed sit amet velit sit amet eros rhoncus feugiat vel ut dolor. Morbi dignissim libero risus, id posuere ex cursus non. Cras urna nunc, pretium non efficitur et, cursus a leo. Ut efficitur euismod purus, eu commodo velit. Mauris sit amet auctor nunc. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed laoreet semper massa, et aliquam lorem cursus a. Nulla pretium egestas sem ac finibus. Proin fringilla accumsan tortor sed dignissim. In a lectus dui. Vivamus a placerat justo, eget condimentum diam. Proin porttitor ex a ex vehicula suscipit. In suscipit condimentum leo, vel suscipit diam suscipit ornare. Pellentesque pretium pretium massa ac posuere. Nulla pulvinar urna in fermentum tristique. Sed tortor erat, fermentum non ex non, bibendum pretium augue. Donec non consectetur quam, et blandit leo. Aliquam aliquam turpis rhoncus libero rhoncus, molestie pellentesque lectus dignissim. Quisque efficitur urna pulvinar accumsan ultricies. Nulla id ligula id metus suscipit sagittis. In libero nibh, facilisis vitae pellentesque eu, volutpat at purus. Morbi vel velit ut metus facilisis molestie. Duis vestibulum arcu id sapien molestie, sed ornare odio sollicitudin. Proin gravida vehicula dolor a placerat. Donec vel scelerisque odio. Sed venenatis, erat sed sagittis maximus, massa turpis ullamcorper eros, a malesuada nisl massa sed felis. Aliquam sed dui ultrices orci bibendum elementum ac vel turpis. Pellentesque viverra nec dui vitae dignissim. Cras maximus mi felis, vel efficitur tellus suscipit at. Integer mollis magna dui, at luctus quam eleifend id. Curabitur vel efficitur risus. Quisque sit amet malesuada magna. Fusce pretium iaculis nibh a elementum. In hac habitasse platea dictumst. Vestibulum feugiat dapibus neque et pulvinar. Fusce ac placerat leo. Nullam commodo ultricies augue, et pharetra justo rutrum et. Vestibulum non lectus ipsum. Donec mattis varius orci, vel laoreet ex hendrerit ut. Nunc viverra nibh neque, sit amet semper ex ultricies vel. Suspendisse hendrerit mauris ut sollicitudin commodo. Ut scelerisque elit in risus faucibus, at feugiat elit pulvinar. Integer porta eget purus vitae consectetur. Donec mattis pellentesque egestas. Proin at tortor ipsum. Suspendisse pharetra, ante in semper interdum, diam neque porta elit, a luctus est dolor ac enim. Cras maximus eu elit eu gravida. Sed dapibus dignissim imperdiet. In volutpat ante mauris, at convallis sem tincidunt eu. Suspendisse rhoncus feugiat rhoncus. Ut maximus enim ut convallis varius. Phasellus vitae lectus libero. Morbi ipsum ipsum, egestas quis elit at, placerat consectetur ligula. Nulla ac maximus nibh, sed rhoncus leo. Nunc et commodo lectus. Nunc aliquet tristique lacus, eu consectetur lacus dapibus at. Aliquam dictum ex urna, sit amet accumsan sapien iaculis et. Curabitur rhoncus, ipsum eget dictum facilisis, odio nisi tempor magna, id volutpat orci elit sed lorem. Sed iaculis neque lacus, vel interdum nisl pulvinar in. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur commodo purus vel ipsum posuere tempus. Integer ac iaculis velit. Integer viverra justo diam, nec molestie sem tristique nec. Fusce tempor quam vel ultrices convallis. Quisque purus ex, molestie non libero non, tincidunt aliquet metus. Praesent posuere finibus ante, in vehicula augue. In vehicula orci vel consequat feugiat. In ultricies ornare sollicitudin. Sed ut vulputate nisi. Nulla lacinia, nibh eu eleifend posuere, mauris velit luctus dui, non congue turpis leo vitae sapien. Proin mauris risus, vehicula in tortor sed, volutpat porta elit. Sed elementum, leo sollicitudin consequat rhoncus, odio nulla mollis odio, eget facilisis arcu est et dolor. Sed sit amet tellus dignissim odio sagittis venenatis. Phasellus luctus congue ligula ut varius. Sed ultricies purus sit amet lacus elementum, ut fringilla turpis volutpat. Nam volutpat nisl dictum erat varius, nec eleifend urna fermentum. Proin cursus elit tortor, quis dictum felis iaculis vitae. Curabitur feugiat aliquam magna, a vehicula leo auctor vitae. Donec malesuada, dolor at imperdiet pretium, ante ex tempus enim, eget viverra nisl leo pellentesque dui. Aliquam id pretium ante, eu maximus orci. Duis iaculis non turpis vitae ullamcorper. Suspendisse vitae magna pretium, malesuada nibh malesuada, aliquam quam. Integer vestibulum, massa eu ultrices porta, quam est hendrerit magna, in euismod nulla metus sit amet velit. Nunc cursus lobortis orci non vestibulum. Mauris a convallis turpis. Fusce sit amet nulla eu nunc interdum ultricies nec in metus. Pellentesque fermentum dui eu purus scelerisque, vitae congue diam finibus. Sed iaculis eros lorem, at bibendum libero consectetur in. Etiam pretium justo sit amet lectus pharetra eleifend. Vivamus pulvinar a libero ac dictum. Sed dui massa, dignissim eget dolor eu, accumsan congue odio. Suspendisse convallis lectus aliquam neque hendrerit, fermentum lobortis diam mollis. In hendrerit, massa sit amet volutpat hendrerit, diam quam vulputate diam, placerat gravida lacus velit vel eros. Donec aliquam porta nibh nec pulvinar. Phasellus consequat est justo, in maximus ex molestie in. Duis gravida odio nibh, non condimentum libero mattis ut. Donec ut accumsan risus, vitae consequat magna. Duis ullamcorper est dolor, id pretium turpis hendrerit vel. Nulla faucibus leo sit amet sem tincidunt, a maximus justo vestibulum. Interdum et malesuada fames ac ante ipsum primis in faucibus. S
- ZephyrP 8y agoI always wondered about the C tutorials Brian Kernigan mentions in his talk ( https://www.youtube.com/watch?v=8SUkrR7ZfTA https://www.youtube.com/watch?v=8SUkrR7ZfTA ) , many of the examples seem intentionally designed to be incorrect by some trickster spirit. Now I know the even darker truth.
- neya 8y agoThanks for sharing! I didn't know of that video until now, seems like a really good resource on its own and probably worth sharing on HN (as a post).
- leni536 8y agoThe exact same code sample appears in the talk as in the article.
- jwilk 8y agoYes, the article mentions the sample was taken from the talk.
- the_lurker 8y agoYesterday I encountered a similar program on a HN comment chain as shown in this link. I am genuinely confused as to why this program is bad. I am a student and I do not know the best practices regarding pointers, but it is how I would write a program to combine two strings. Can someone please elaborate why it is bad? Are their any good resources to fill gaps in my knowledge? Thanks in advance. Edit: Thank you guys for pointing out so many problems. It seems that I have a lot to learn. :)
- saagarjha 8y agoThe C syntax is a bit too dated for me, but I think it returns a pointer to a stack buffer (which is capped at 100 bytes, so it could overflow) and goes through s twice? Plus it's not concise at all.
- TomVDB 8y agoIt returns the result r, which is a temporary, stack allocated array that becomes undefined by the time your return from the function. That’s the worst violation. Furthermore, r is a fixed 100 bytes. There is no overflow checking whatsoever.
- LukeShu 8y agoBesides stylistic (dang, that code is hard to read), efficiency (it scans through s twice), and safety (it will do bad things if the combined length is > 100) concerns, it's also just plain wrong: It returns a pointer to memory on the stack; but the stack will shrink when the function returns, and that piece of memory will get re-used. Which is consistent with the article's later claim that "I don’t think he understands the call stack."
- saulrh 8y agoNot a C programmer, so I'm sure I'm missing a ton of more subtle issues, but some of the immediate questions to ask: * What happens if s or t are longer than 100 characters? * What happens if s and t are both longer than 50 characters? * What happens if no element of s == '\0'? How about t? * r is allocated on the stack. What happens to the memory pointed at by r when you call another function after calling combine? Say you wanted to combine three strings; could you call combine twice to build up the result?
- de_watcher 8y agoIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. - Dijkstra, "How do we tell truths that might hurt?" (1975) The author, Traister, has came from BASIC. We have the explanation.
- laumars 8y agoWell that is a dumb and inaccurate statement if ever I've read one. I mean I'm sure there might have been some nugget of truth back in the 70s in that it might have been frustrating to teach C or FORTRAN to BASIC programmers but it has as much relevance these days as any of the other memes people like to quite from yesteryear. I certainly managed the transition from BASIC to Pascal with ease and definitely follow good programming idioms. I also know a lot of others followed similar path of learning to myself.
- a_lieb 8y agoI teach programming, and I find people rarely have any special trouble in switching to a different style or paradigm. If I was teaching in the 80's and wanted to transition someone from old school BASIC to something like C or Pascal with structured programming and blocks, I'd show them an "if" with a code block and how it's different than a conditional GOTO, yet similar in a way. Gradually the mental model evolves to incorporate the new features, and when they look back, they can understand both ways, even though on paper it's "two different paradigms." Similarly, if I'm teaching JavaScript and want to show the student functional programming, I'll show them how a "for" loop could be converted to use map or filter, or recursion. Far from "corrupting their mind" so they can't understand other ways, the imperative style serves as a foundation to learn other styles. The paradigm shift occurs gradually on some subconscious level, with the previous paradigm serving as a mental model to build up the new one.
- de_watcher 8y agoWell, we're talking about the early nineties. Contemporary VBA developers (or whatever it is about) can point their pitchforks vertically, ok?
- bjoli 8y agoI doubt books like these are as common today, but tutorials are everywhere. I don't know how often I have found scheme tutorials that teach a language I barely understand. Not dangerous maybe, but very weird nonetheless. I see beginners writing code like that all the time, which makes me sad.
- buckminster 8y agoYeah, a few months (a year?) ago I was getting back into Javascript so I went to the mozilla website [1] to refresh my knowledge of prototypical inheritance. And it seemed all wrong. So I actually ran their short bits of example code in firefox and they worked like I expected them to. Their documentation is just nonsense. There hasn't been a lot of activity on it recently so it's probably still wrong. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...
- oldcynic 8y agoMake sure to click the link at the end of the article for code samples with potential for Segmentation fault:core dumped in 4 lines. Even more concerning is the book seems to have some positive reviews on Amazon(!), and just one shredding it.
- saagarjha 8y agoThe example given at the top of the article can cause a segmentation fault. See the other comments here for how.
- oldcynic 8y agoReturning out of bounds pointers will do that. Was more impressed by the range of errors in his 4 line examples - the sort of thing you'd expect from a struggling student not a tutor or author. :)
- patrickyeon 8y agoA few years ago, I saw a classroom video (I would guess ~8-10 year olds, in the American public school system) as a demonstration of a teacher's technique called "my favourite wrong answer". She would have them solve a problem (a math problem, in this particular case), collect the answers, show the distribution of the answers, and then pick out one answer (possibly with the student's name redacted) as her "favourite wrong answer". And then she would work through why she liked it so much with the students. In the examples, it was cases where the person was on the right track, but then made an incorrect, but justifiable by _some_ standard, step in solving it. It seemed like a good way to really try to understand where someone's comprehension broke down. It felt like it added some legitimacy to the students who got the answer wrong, if others could look at it and go "oh, I see why you thought that!" instead of just "wow try to get it right next time". I believe it's part of what good teachers (not limited to school educators, mind you) are doing all the time: looking for the student's gaps and trying to correct those, instead of just repeating the lesson that has already failed to stick. I guess this just makes me think of that teacher, trying to work out what her pupils were misunderstanding, by looking at their answers.
- nwmcsween 8y agoThe issue with really learning computer science outside top well known schools is that you're basically on your own for education (or worse if taught wrong). Open source software somewhat teaches you things but usually by trial by fire.
- eesmith 8y agoReally? I went to a non-top school and putting aside the formal education component, I felt like I also had plenty of co-learning. That is, I remember many study groups where we helped each other learn, including for programming. I certainly didn't feel like I was on my own.
- faceplanted 8y agoSimilar experience here, my university helped people form study groups near final exams and had a "homework club", where final year and grad students were paid to help first and second year students with their assignments for a couple hours a week, and people were encouraged to meet each other in that club and find "study buddies" (but no-one actually called it that, because ugh) Covered everything from the programming to the multivariable calculus and data science (much harder to find students confident enough to teach others for those last two though)
- narag 8y agoWhen I was learning C in the eighties, I bought a book about 3D programming, the worst programming book I've read. I believe that examples worked, at least the ones that I typed did, but the style was atrocious. The concept of function parameters seemed to be totally alien to the author. The idiot created x1, X1, x2, X3, x, xthis, xthat... variables instead. He was a former BASIC book author too. I can't warn you because I put it to the trash bin long ago.
- stinos 8y agoHe was a former BASIC book author too Hmm, I'm starting to see a pattern. Is it possible BASIC, plus lack of internet back in the day, plus attrocious books are the reasons for truning poeple into terrible programmers? I happen to know only a couple of seniors but without exception their code, no matter what language written in today, is horrible on all fronts. I used to think it was a lack of attention to detail, their lack of wanting to strive for even the tiniest bit of more than just 'good enough for tady'. Possibly stemming from lack of education and lack of continuous self-education. But maybe there's more to it. Maybe they were influenced by a bad book. And/or by a not-so-optimal language like BASIC.
- okyougotmenow 8y agoMost of the major game engines of the past 20-30 years were programmed in a large part by people that started with BASIC.
- oldcynic 8y agoI would say "it depends". Just as poor programmers came later from Visual Basic, or MSVC++ (somehow we went through a phase were everyone coming for interview with MSVC++ actually had C with classes, and for a while it was a warning sign and standing joke at the place I then worked). Getting people who claimed C++ who actually knew it was pretty challenging around the millennium. In the 80s just about everyone who had an 8 bit started with BASIC, and an awful lot of them managed to go on to be perfectly acceptable programmers when they moved on to C, C++, assembler, and more recent languages, or even turned out a decent game in something like Blitz Basic on the Amiga. Then again there were some who couldn't move beyond BASIC, because it was simple enough almost everyone could piece something together with it - so even back then it was a warning like PHP can be today. It's not age, and it's not BASIC - there's plenty of younger folks turning out abysmal code who've never been near it. I wonder how I'd have turned out if I'd learnt C from one of this guy's books instead of K&R and having a couple of experts handy.
- ensiferum 8y agoHeh, not only this but there are also plenty of C++ books that are literally less than worthless. Additionally another common domain of clueless writing is computer graphics and the related math. There are so many articles written by enthusiastic people (no doubt) where the information is just adding noise. Finding trustworthy good quality information requires that you know a considerable amount already so you know what is good and what is not (talking about online content here) :)
- flukus 8y agoDidn't some of the C++ books have to be crappy in some ways due to limitations of free (as in beer) compilers with arbitrary limitations? One I vaguely remember was a ridiculously (even for the time) limited stack size, so a lot of examples had to do unnecessary allocation just so readers could compile. I think it was this book (https://www.amazon.com/Flights-Fantasy-Programming-Video-Games/dp/1878739182/ref=pd_sbs_14_1?_encoding=UTF8&pd_rd_i=1878739182&pd_rd_r=6ce9213c-7912-11e8-8434-9191398a8362&pd_rd_w=5vYRm&pd_rd_wg=1DW3X&pf_rd_i=desktop-dp-sims&pf_rd_m=ATVPDKIKX0DER&pf_rd_p=5825442648805390339&pf_rd_r=MBCC0PXWQSFBW41PV2MT&pf_rd_s=desktop-dp-sims&pf_rd_t=40701&psc=1&refRID=MBCC0PXWQSFBW41PV2MT https://www.amazon.com/Flights-Fantasy-Programming-Video-Gam...) that taught me 3D programming better than anything else. The code was readable, the maths was well explained and it included sections on how to do things without those newfangled maths co-processors. I'd love to buy a copy now just to see if it really was a good book or if it led me astray.
- martin1975 8y agoApparently Mr Traister has written a number of other books - https://www.amazon.com/default/e/B001H6UPHY/ https://www.amazon.com/default/e/B001H6UPHY/ - according to Amazon... Made me wonder if the quality of the content in the other 11 books is anything like the one the Woz took apart.
- _7c18 8y agoIt's not Steve Wozniak. They just happen to share the same last name. From https://wozniak.ca https://wozniak.ca: > I’m Geoff Wozniak, just one of those persons on the Internet. My blog is hosted here, but not much else at the moment.
- martin1975 8y agoThank you!
- waffle_ss 8y agoI was going to ask if any attempt was made to reach the book author for comment, but it looks like he died in 2007. RIP. https://www.findagrave.com/memorial/29007415/robert-joseph-traister https://www.findagrave.com/memorial/29007415/robert-joseph-t...
- oblio 8y agoDamn, that's sad. I had a similar moment yesterday while thinking about Max Allen, the interviewer during that CBC show with Ted Nelson where they were talking about computers in 1979. I wonder if these people ever got to know a bit about the things they didn't understand at the time. I also wonder if I'll ever get to know about the unknown unknowns in my life :)
- feintruled 8y agoWhat's also sad is some idiot went there from that link and left an abusive comment on his memorial website referencing Hacker News. Pretty pathetic, whoever did that.
- goldenkey 8y agoI think I speak for all the developed brains on this website when I say that defacement is pathetic and weak, clearly coming from an impotent individual. Rest in peace Mr. Traister, we love you even though C kinda thorned ya. :-)
- Cerium 8y agoOr as my mother taught me: "people who write in public places have stupid names and ugly faces."
- Froyoh 8y agoRIP
- delhanty 8y agoIt appears that someone having read your comment here has left a horribly abusive comment on that memorial page now under the handle "Screw You Bob". > ... The Hacker News army is here. "Screw You Bob" you do not speak for me. Hopefully, you don't speak for many people on HN. Words fail me. Can't we let the dead rest in peace?
- DanBC 8y agoI'd be interested in a review of the author's C++ pointer book Conquering C++ Pointers https://www.amazon.com/Conquering-Pointers-Robert-J-Traister/dp/0126974209/ https://www.amazon.com/Conquering-Pointers-Robert-J-Traister...
- setquk 8y agoThis doesn't surprise me really. When I was at university the programming textbooks we had were vile nasty and plainly incorrect. And those of us who dared challenge it by writing correct, robust code were penalised as the staff teaching it didn't understand the domain of what they were teaching properly and didn't have any real experience and assumed we were doing it wrong. We learned quickly to approach education with a high level of scepticism and get your info from more than one source (textbook) and find out which ones were reputable and which ones were garbage. Basically there was a monolith in the middle of the course, a crap textbook, and monkeys were praying to it as the authority on everything.
- npsimons 8y ago> We learned quickly to approach education with a high level of scepticism and get your info from more than one source (textbook) and find out which ones were reputable and which ones were garbage. Ironically, I think this is one of the best lessons anyone can learn . . .
- beojan 8y agoAnd that's why just going to the cheapest university is a bad idea.
- Wrongthink 8y agoMy mid tier university has a fundamental problem where the lecturers aren't even hired to teach, they're hired for research. And since the university can't get enough American grad students to stay and be research slaves they bring in grad students from the third world. Then these grad students are required by law to teach a certain number of credit hours to conduct research and there you go. The result is every general class is poorly taught by people who can barely speak English and don't care about teaching so you end up teaching yourself or failing. CS courses generally don't have this issue but they do have a large amount of mediocre professors. Reason being anyone talented in CS can make 2-3x the salary out in the real world and so CS grads rarely stick around to teach. The saying "those who can't do, teach." is as relevant as ever.
- DanielBMarkham 8y ago"...But like analyzing a terrible movie that somehow gets made, it's more fun to reason through the “behind the scenes” parts..." I do too. Many times I find it much more interesting understanding how the sausage is made than what the actual sausage tastes like. This is a great meta review. As somebody who's just published a book for tech teams, I need to be acutely aware of my own work to make sure I'm not falling down the same hole: taking a little bit of knowledge and and trying to fluff it out to appear to be a comprehensive body of work. It's not just the 80s and old coding books. There has been quite a trend over the last decade or so of people over-publishing (I guess that's the term). Promising all sorts of things while delivering on little. In some ways I think this is okay. The received wisdom is that you don't have to know everything, you just have to know more than the reader and be able to explain how to move them a bit forward. Perhaps the key is attitude. Woz says "..'Ive always found the authors come from a position of earnestness, attempting to draw the best conclusions based on decent principles and what they knew at the time they wrote it..." A little humility, careful scoping, and honesty in a tech book can go a long ways. (Insert long discussion here about whether people would buy such a book, and how people are much more naturally attracted to books with a strong emotional impact "Make money with C Now!" than they are books that simply try to helpfully explain something without all the glitz) There is a natural tension at work here.
- blackrock 8y agoThe only thing worse than C, is that we got stuck with Java.
- azernik 8y agoBad reviews are always so much more fun to read than good ones.
- gumby 8y agoTo review your comment: "The author's well meaning and accurate comment is that well-written negative reviews are typically far more fun to read than positive ones of any quality -- in the positive case you usually want to simply read the book, while the implication of the comment is that the pleasure of reading the negative ones is a delicious Schadenfreude. "Regrettably, this insight was obscured by a regrettable poor choice of terminology ("bad" and "good"). The comments, azernik, has enough HN karma to suggest that this error ought be assigned to the casual, off-the-cuff nature of internet commenting, and that this comment is not up to the usual work (i.e. comments) of the author.
- EliRivers 8y agoBest thing about Fifty Shades of Grey; this review : https://www.goodreads.com/review/show/340987215 https://www.goodreads.com/review/show/340987215
- bitL 8y agoC'mon, viewing a book from 1990 with the lens of 2018 must be funny of course; almost nothing in programming languages aged well, baring some theoretical principles. Many of the things the book author tried to avoid (like not using integer indexes) were necessary for writing fast code on 4MHz processors with 256kB of RAM in primitive compilers back in the day... Can you please add some xBase book review to the mix for more outdated fun and facepalming from the heightened point of view on a hill of three decades next? /s
- Xophmeister 8y agoHindsight 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
- gumby 8y agoIt's books like this that lead to inventions like Java and Go, with explicit aims of avoiding certain difficult constructs. Not that pointers are particularly difficult in the scheme of things, but if someone who doesn't understand them tries to teach them, pointers inevitably do become "difficult"
- kosma 8y agoThe fixed-location variable allocation strategy the author mentions is called overlaying or compile-time stack[0]. It's still very much alive today, thanks to architectures like 8051 that are not really stack-friendly (even though they do have a stack). > The Keil C51 C Compiler works with the LX51 Linker to store function arguments and local variables in fixed memory locations using well-defined names [0] http://www.keil.com/support/man/docs/bl51/bl51_overlaying.htm http://www.keil.com/support/man/docs/bl51/bl51_overlaying.ht...
- cptnapalm 8y agoIs there anything I can read to learn more about overlaying in C? I was reading, to my limited abilities' limits, 2.11 BSD source and there was a lot of references to overlaying.
- basementcat 8y agoOn a modern POSIX environment, you can hack together an approximation of an overlay by loading some code to an area of memory, mprotect( ptr, len, PROT_EXEC) the segment, ((int(*)())ptr)() to call the function and if you did everything right, you don't segfault too hard. Later, you can overwrite that area of memory with other code and repeat. This is similar to what actually goes on under the hood of the dynamic loader. http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.html http://tldp.org/HOWTO/Program-Library-HOWTO/dl-libraries.htm...
- burfog 8y agoThat is a different sort of overlay, a code overlay. The other example was data, with the compiler assisting by changing local variables to have fixed addresses that get carefully reused for different variables at different times.
- chaosite 8y agoMaybe this weird strategy exists elsewhere, but he's supposedly teaching Borland Turbo C with the small memory model. That compiler uses a run-time call stack.
- userbinator 8y agoI've found that it's usually those with embedded systems experience who are most knowledgeable about pointers, but I suppose BASIC experence with embedded systems doesn't count --- the ones I'm referring to usually started in Asm/C, and others I know who started in Asm (not necessarily for embedded), also are extremely good at pointer use. The modern equivalent would probably be Arduino experience. I wonder if there are similar examples in books out there about C++ written by someone with only that...
- nemanjaboric 8y agoIt seems that the author followed the same logic as the author of the "English As She Is Spoke"[1] phrase book between Portuguese and English, with the French dictionary in between. [1]https://en.wikipedia.org/wiki/English_As_She_Is_Spoke https://en.wikipedia.org/wiki/English_As_She_Is_Spoke
- deleted 8y ago[deleted]
- bcaa7f3a8bbc 8y ago> "Both programs also contain another value of 43. This is the constant that was written directly into the program." (p. 29) — I have no idea what this means. > I believe that the author thinks that integer constants are stored somewhere in memory. The reason I think this is that earlier there was a strange thing about a "constant being written directly into the program." Later on page 44 there is talk about string constants and "setting aside memory for constants." I'm wondering now… Yes, most of the book is wrong. In this example, the author probably also presented this idea in a wrong way. But the author is correct for having the idea that "constant being written directly into the program" (by the compiler!) and "integer constants are stored somewhere in memory", they are correct and make perfect sense. Of course the integer constants and string constants are all allocated and stored somewhere in memory (or somewhere that can be mapped as memory). They are usually known the text segment and data segment. > …(remember, the array name becomes a pointer when used without the subscripting brackets)" > "…while a pointer, as always, is a special variable that holds the address of a memory location." (p. 57) — Still wrong, but slightly less wrong. Good enough IMHO. It is true that an array "name" is a pointer to its base address.
- goldenkey 8y agoA constant can simply be part of the actual assembly instructions in the code segment. Depending on what type of constant and how large it is, it might just be inlined instead of using a memory load. Shared use can also be a compiler heuristic, a large constant used 100 times is more likely to be a shared reference instead of inlined.
- bcaa7f3a8bbc 8y agoAccurate. They don't have to be inside the data segment - they can simply be part of the actual assembly instructions. But more or less, it means the constant is "being written directly into the program". If "program" refers to the object code unambiguously, I don't think this expression is problematic per se.
- caf 8y agoIt is true that an array "name" is a pointer to its base address... No, it's not. It is true that an expression of array type, when it is not the subject of either the unary-& or sizeof operators, evaluates to a pointer to the array's first element. sizeof array gives the size of the whole array, not the size of a pointer. &array gives the address of the whole array, not the address of a pointer.
- ngvrnd 8y agohttps://www.findagrave.com/memorial/29007415/robert-joseph-traister https://www.findagrave.com/memorial/29007415/robert-joseph-t...
- abakus 8y agoWTF is this "for (x=y; ...)" part?
- bcaa7f3a8bbc 8y ago> Pointers to functions are seen mainly as a way to obfuscate your program. "A pointer to a function serves to hide the name and source code of that function. Muddying the waters is not normally a purposeful routine in C programming, but with the security placed on software these days, there is an element of misdirection that seems to be growing." (p. 109) > "GIGO (garbage in, garbage out) is a term coined to describe computer output based on erroneous input. The same applies to a human being." (p. 152) — ??? (like the readers of this book?) Priceless.
- g051051 8y agoI have this book, a pristine first edition, with maximum wrongness. It's pristine because I bought it when I started learning C in 1990, and never opened it after my first read through.
- apo 8y agoThis was a fun read, but left me with the question: What book on C pointers would be the polar opposite of this one? I'd like to read that book.
- SloopJon 8y agoWhile I haven't read either of them, Pointers on C and Understanding and Using C Pointers both have good reviews.
- phaedrus 8y agoWhen I started my CS degree the school was transitioning from teaching C++ to teaching Java, and the state of instruction in C++ was almost as bad as these examples. I had a professor who wanted us to use "new Foo()" everywhere in our code (even local / static variables) because it, "gets the students ready for Java." No matching delete, of course, or mention of RAII. We were supposed to "pretend" we had a garbage collector. By that logic one might prepare students for a course in Spanish by speaking English with a "-o" on the end of every word. On one of the early homework assignments I realized my professor misunderstood how pointers work - he seemed to believe that (re)assigning pointers created chains rather than changing what the pointer points at. I.e. given "int x,y; int_pointer a,b,c; a=b=c=&x;" he seemed to believe that then executing "c=&y;" would also cause "a" and "b" to point at "y". I spent the first page of my turned-in assignment excoriating his lack of understanding. Then I presented a class template that implemented a special smart pointer which did behave in the unusual way he seemed to think C pointers work, so that I could write the code exactly as he presented in the assignment and make it actually work. In retrospect I could have been nicer and considered other pedagogical factors beside technical correctness. I think he took it with more grace than I deserved.
- Improvotter 8y agoSome of my professors also have ridiculous code standards or exam standards. One of them teaches "algorithms and data structures", but he's not allowing us to even use a break or continue in our loops because he thinks it's "bad practice". We end up with a nested hellhole. Another example from the same professor (correct me if I'm wrong on this as I'm not a C++ expert), but he's constantly inheriting from unique or shared pointers in his classes. Like why though? Why do you have to complicate your code like this? Why can't you just have a normal class with unique or shared pointers in it? Lastly, and this is taught by another professor, is my class for Linux. It includes bash and C++ programming and focuses a bit on the POSIX API. Our exam was last week and we had 3 parts. The first part was a theory exam by the professor that taught the class. It was about bash/POSIX commands and very little Linux specific stuff. He expected us to know all of the options from all of the commands you can think of: cut, split... You had to know all of them and off the top of your head. It's ridiculous. I'm pretty sure I failed that one, but I absolutely nailed the next part which was about bash scripting (where you could use if statements and the like, the first part did not allow it, only redirection and piping). The man is mad (hah man, that's what I needed during that first exam part).
- gwbas1c 8y agoI've definitely bought a few programming books that, on closer inspection, just appeared to be money-grabs from the author. But, my biggest memory is the book I didn't buy. I once worked with a programmer who wasn't very good, and then I heard he wrote a book. I typed his name into Amazon, and there was his book. It was all about the half-baked concepts he was trying to put into our failing project. (Ultimately canceled because we couldn't ship a very simple product. We couldn't ship it because everyone just wanted to add code generators and additional layers around a database... Instead of learning how to use a database.) I couldn't get out of that job fast enough.
- __david__ 8y agoOh wow, I have the "Going From BASIC to C" book! I remember reading it first because I knew Apple BASIC really well. I also had K&R. Looking back, I wonder if learning C was made harder or easier by that book…
- leafario2 8y agoAuthor of book is a Markov chain?
- korethr 8y agoI took a look at some of the transcribed code examples. Understand, I consider myself a novice at C, one who's just starting to get a clue about pointers. But reading the code examples, more than once I found myself going, "Wait...what?". I briefly tried to learn C++ an C in the 90s. I'm somewhat glad I didn't find this book in the library. I think it would have made attempting to learn harder, or given me some bad and dangerous habits.
- krylon 8y agoThis reminds me of the first textbook I tried to learn C++ from. It was fun to read, because the authors seemed to put more energy into writing Limericks than explaining object-oriented design. I don't think it touched on inheritance, and things like, I don't know, inline functions or templates were not mentioned at all. It did not even contain working example programs, let alone exercises. It was so bad, as the saying goes, it was not even wrong. I still have that book on my shelf as a reminder to not blindly buy the first/cheapest textbook I can find.
- microtherion 8y agoUsually, that kind of venom in C book reviews is reserved for books written by Herbert Schildt ;-)