Skip navigation
Linus Torvalds explains "taste" in code by showing how to remove an entry from a singly linked list…
0:00 / 2:21

Linus Torvalds explains "taste" in code by showing how to remove an entry from a singly linked list…

tetsuo

@tetsuoai253K followers

Visit on X
4,932 likesDownloadOriginal post

8,911,071 views

Linus Torvalds explains "taste" in code by showing how to remove an entry from a singly linked list in C without adding extra complexity. Source: TED

10 Comments

Comments from the original post on X (Twitter)

  • tetsuo.ai's profile picture

    @7etsuo

    Source:

    64 likes

  • 🇵🇹Ninja Dynamics☀️🌴🍹's profile picture

    @ninjadynamics

    Oh man, seeing how elegantly a simple linked list can be optimized really blew my mind! Beautiful! Linus really is the goat!

    38 likes

  • dinn's profile picture

    @dinn

    "Better taste" would not work if entry is a value, not a list element that needs to be deleted. Last string needs indirect->next

    12 likes

  • Kevin Dai's profile picture

    @theonecarrot1

    I'd argue the first one is better *because* it's more intuitive and understandable (biased as a compiler developer). In reality, the compiler has no trouble optimizing this trivial logic: and actually yields better code in the "untasteful" one (1/3)

    10 likes

  • Ghasem Ramezani's profile picture

    @ghasem_ccore

    Looking at the problem from a different perspective is extremely hard when you are in the problem. 😫

    9 likes

  • Araf's profile picture

    @arafleaf

    had to do some soul searching

    9 likes

  • wundram's profile picture

    @wundram

    That while loop tastes pretty sour.

    7 likes

  • Teobastus's profile picture

    @teobastus

    But it doesn't really handle the case where you reach the end of the list without finding the element you're looking for. If you reach the end it will crash and probably segfault.

    7 likes

  • Method's profile picture

    @method1cal

    “code taste”

    6 likes

  • Noga Navon🏳️‍⚧️ الزهرة الحكيمة נוגה נבון's profile picture

    @Noga_Navon

    This is the kind of thing that make having pointers in your language worth it.

    6 likes