Live data from Hacker News

Linus Torvalds' good taste argument for linked lists, explained

github.com

181–190 of 339 posts

Re: Linus Torvalds' good taste argument for linked lists, explained

#181

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…

Lines of code are expensive! They're the only thing that's ever been shown to be correlated with the number of bugs in a given codebase.

Re: Linus Torvalds' good taste argument for linked lists, explained

#183
post #91

Earlier 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.

Which solution do you think of as simple?

Re: Linus Torvalds' good taste argument for linked lists, explained

#184

I'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…

The comment is correct. The "thing" is the variable that holds the "entry". The entry is removed by updating the "thing".

Re: Linus Torvalds' good taste argument for linked lists, explained

#185
post #57

Earlier 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.

To be fair, many programmers who do use C have that character flaw as well.

Re: Linus Torvalds' good taste argument for linked lists, explained

#186
post #114

Earlier 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.

Who is little Jimmy?

Re: Linus Torvalds' good taste argument for linked lists, explained

#187
I've seen the "better" version a few times before. I wrote something equivalent from first principles.

It 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

#189

I'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.

It's a small class in good coding 101. Concise, well commented/documented, good variables names vs verbose in explanation , terse in code.

Re: Linus Torvalds' good taste argument for linked lists, explained

#190

Earlier 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?

[deleted]
Post reply on HN