What Linus Torvalds Reveals About Open Source, Git, and Writing Elegant Code
Linus Torvalds shares his dual impact on technology through Linux and Git, explains his pragmatic engineering mindset, the philosophy of open source collaboration, and demonstrates the difference between messy and elegant C code using real‑world examples.
01 Linus Torvalds
Linus Torvalds changed technology twice: first with the Linux kernel that helped the Internet, then with Git, the source‑code management system used worldwide. In a TED interview he discusses his open attitude, work style and personality.
Torvalds says: “I’m not a dreamer, I’m an engineer… I enjoy working with dreamers, but I’m the one who keeps my feet on the ground and fixes the immediate problems.”
02 About Open Source
He explains that Linux was not created as a collaborative project; it started as a personal need. He didn’t think about open‑sourcing it, but as the project grew he wanted others to see his work.
Thousands want to join the Linux kernel project, yet he often becomes the bottleneck. Git was his second major project, created to maintain the first one. He codes for fun and to solve his own problems, designing each program for his own needs.
He loves that open source lets diverse people cooperate without needing to like each other; conflicts are common but productive. Open source also restores openness to science, enabling arXiv and open journals.
03 Code Taste
Torvalds believes good code can be rewritten from a different angle to cover all cases simply and elegantly. He expects collaborators to have good taste.
He compared two functions during the interview.
1. Less Elegant Code
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 needs a special case when the entry to remove is the head of the list.
2. More Elegant Code
remove_list_entry(entry)
{
// The "indirect" pointer points to the
// *address* of the thing we'll update
indirect = &head;
// Walk the list, looking for the thing that
// points to the entry we want to remove
while ((*indirect) != entry))
{
indirect = &(*indirect)->next;
}
// .. and just remove it
*indirect = entry->next;
}This version eliminates the special‑case handling, using an “indirect” pointer that always refers to the next field of the previous node (or the head).
The diagram below shows how *indirect points to the next member of the preceding list element.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
21CTO
21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
