I understand the general point (and value) of reframing the problem or the solution in a way that removes special cases ... but in this case I would actually prefer the first solution over the second. The second solutions reminds me of the old-school perl culture, and JavaScript culture, where 'cleverness' (which always manifests itself as terseness as if lines of code were expensive), takes precedence over maintaina…
Linus Torvalds' good taste argument for linked lists, explained
181–190 of 339 posts
Re: Linus Torvalds' good taste argument for linked lists, explained
#182https://www.ted.com/talks/linus_torvalds_the_mind_behind_lin...
Re: Linus Torvalds' good taste argument for linked lists, explained
#183Earlier quoted context omitted.
You make a very good point, and that it has to do with the relative foundational conceptualisational ability of the types of mainteners. That's great because it kind of speaks to the crux of the problem. But the first solution does use pointers :) The second uses double pointers. I'd argue that 'even kernel maintainers' may not be so easy with the second in reality. It's probably worth it if there is a performance ga…
The simple solution is faster.
Re: Linus Torvalds' good taste argument for linked lists, explained
#184I'm not sure why the article removed comments from the code and replaced variable names like "indirect" with "p". Here are the two code samples verbatim from Linus's presentation: remove_list_entry(entry) { prev = NULL; walk = head; // Walk the list while (walk != entry) { prev = walk; walk = walk->next; } // Remove the entry by updating the // head or the previous entry if (!prev) head = entry->next; else prev->next…
This comment seems wrong to me: // The "indirect" pointer points to the // *address* of the thing we'll update The "indirect" pointer points to the thing we'll update. See at the bottom, it's updating *indirect, so "indirect" points to the thing being updated. On the other hand, "indirect" points to the address of the thing we'll remove. There's a specific item being removed, and there's a specific thing that will be…
Re: Linus Torvalds' good taste argument for linked lists, explained
#185Earlier quoted context omitted.
I was only ever taught the second, more concise one, so this discussion is kind of confusing. How is it not shorter and more explicit?
Many Programmers who don't use C are afraid of pointers and prefer superficially simpler (but overall more complicated) things like Java's abstraction towers, despite the extra expense.
Re: Linus Torvalds' good taste argument for linked lists, explained
#186Earlier quoted context omitted.
Much clearer when read as Linus intended. Reminds me of the editor(s) who helped "fix" bukowski's poems
I’m not a fan of everything Bukowski wrote, but I wouldn’t try to censor him so that little Jimmy could read it, and I liked the movie Barfly. Similarly, I’m not a fan of everything Linus wrote, but I wouldn’t enforce bad CS101 code on him so that little Jimmy could read it, and I like Linux.
Re: Linus Torvalds' good taste argument for linked lists, explained
#187It is NOT better. It is much more difficult to understand. Software engineering is about making the code intelligible for the people who follow you. The simple two pointer with conditional is MUCH easier to read and understand.
Re: Linus Torvalds' good taste argument for linked lists, explained
#188for(p=NULL,q=head; q!=entry;p=q,q=q->next); *(p?&p->next:&head) = q->next;
Re: Linus Torvalds' good taste argument for linked lists, explained
#189I'm not sure why the article removed comments from the code and replaced variable names like "indirect" with "p". Here are the two code samples verbatim from Linus's presentation: remove_list_entry(entry) { prev = NULL; walk = head; // Walk the list while (walk != entry) { prev = walk; walk = walk->next; } // Remove the entry by updating the // head or the previous entry if (!prev) head = entry->next; else prev->next…
Thank you, I found that much easier to read than the article posted.
Re: Linus Torvalds' good taste argument for linked lists, explained
#190Earlier quoted context omitted.
I’m not a fan of everything Bukowski wrote, but I wouldn’t try to censor him so that little Jimmy could read it, and I liked the movie Barfly. Similarly, I’m not a fan of everything Linus wrote, but I wouldn’t enforce bad CS101 code on him so that little Jimmy could read it, and I like Linux.
Who is little Jimmy?