Fundamentals 6 min read

Linus Torvalds on Open Source, Coding Philosophy, and Elegant Linked‑List Removal

In a candid interview, Linus Torvalds shares his pragmatic engineering mindset, explains why Git was his second major project, and demonstrates how a clean pointer‑indirection technique can simplify linked‑list element removal, contrasting it with a more cumbersome approach.

ITPUB
ITPUB
ITPUB
Linus Torvalds on Open Source, Coding Philosophy, and Elegant Linked‑List Removal

Linus Torvalds, creator of the Linux kernel and Git, discusses his practical engineering philosophy in a TED interview, emphasizing that he is an engineer, not a dreamer, and that he builds tools to solve immediate problems he faces.

Why Linux and Git Were Built

Torvalds explains that Linux was not a collaborative effort by design; it originated from a personal need and grew organically. He did not initially intend to open‑source the kernel, but as the project expanded, community involvement became inevitable. Git, his second major project, was created to manage the development of the Linux kernel, embodying his belief that tools should serve the creator’s own requirements.

Open Source as a Working Method

He argues that open source is more than code availability—it is a collaborative work style and educational approach that enables diverse contributors to cooperate without needing to like each other, sometimes even tolerating conflict.

Code Quality and Taste

Torvalds stresses that good code should be simple, cover all cases, and be elegant. He illustrates this with a comparison of two linked‑list removal functions.

Less Elegant Version

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 = entry->next;
    }
}

This version requires a special case for removing the head element and uses separate variables for traversal and previous node.

Elegant Version Using Indirect Pointer

remove_list_entry(entry) {
    indirect = &head;
    while ((*indirect) != entry) {
        indirect = &(*indirect)->next;
    }
    *indirect = entry->next;
}

The refined version eliminates the special‑case handling by using an "indirect" pointer that always points to the next field of the preceding node (or the head pointer). Once the target entry is found, a single assignment removes it, resulting in cleaner and more maintainable code.

The accompanying diagram shows how *indirect references the next member of the previous list node, simplifying the removal operation.

Takeaway

Torvalds’ interview underscores that practical needs drive tool creation, open source fosters collaborative learning, and elegant code often stems from simple, universal patterns rather than ad‑hoc special cases.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Software Engineeringopen sourcecode qualitylinked listLinus Torvalds
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.