Linus Torvalds on Programming: Creating Worlds and Finding Elegance

Programming

Linus Torvalds explores his profound fascination with programming, likening it to creating new worlds, solving complex problems with elegance, and blending art with engineering.

Linus Torvalds, the visionary behind Linux, shares his profound fascination with programming, a pursuit he describes as the most captivating endeavor imaginable. Far more intricate than chess, programming allows one to define the rules and shape the outcome entirely, yet from an external perspective, it often appears mundane.

The initial thrill stems from the computer's unwavering and eternal obedience. Command it, and it complies without complaint. This blind adherence, while initially intriguing, isn't what sustains the passion. The true engagement lies in the challenge of how to achieve your desired outcome.

Torvalds draws a compelling parallel between computer science and physics: both explore fundamental aspects of how the world functions. The key distinction is that while physics seeks to understand an existing world, computer science empowers you to create one. Within the digital realm, you become the architect, controlling every event. "If you’re good enough, you can be God. On a small scale," he provocatively states, acknowledging the potential to offend while emphasizing the profound creative power. Your capabilities and the machine's limits are the only constraints.

Consider a treehouse: there's a difference between one that's merely functional and one that elegantly leverages the tree's structure, blending art with engineering. This synthesis is why programming is so rewarding. Functionality can sometimes take a backseat to ingenuity, aesthetics, or even sheer audacity, making programming a profound exercise in creativity.

His initial draw to programming was the sheer joy of deciphering how computers operate. Like mathematics, computers offer the freedom to construct worlds with self-defined rules. While physics is bound by inherent laws, math and programming permit anything as long as it maintains internal consistency. A mathematical system can define 'three plus three equals two,' provided it remains logical within its own framework. As complexity grows, meticulous attention to internal consistency is paramount for creating a 'beautiful' world, free of flaws.

Computers have captivated people by enabling the exploration and creation of new worlds and possibilities. Beyond Euclidean geometry, computers have helped visualize diverse mathematical realities, like the Mandelbrot set – fractal images derived from arbitrary rules that unveil fascinating patterns. Programming allows the construction of these new worlds, sometimes yielding truly beautiful patterns.

Often, programming involves more mundane tasks – writing a program for a specific function. Here, one isn't creating a new world but solving a problem within the computer's existing environment. This demands a unique kind of person: one who can patiently ponder solutions, "a dweeby, geeky person like me."

Building an operating system is the ultimate challenge because it defines the foundational 'world' for all other programs. It sets the constitution, the fundamental rules of what can and cannot be done. While all programs impose rules, the operating system's are the most basic. The aim is always for logical, elegant solutions.

Torvalds recalls the 'right answer' phenomenon, where some students effortlessly grasp solutions. They didn't memorize steps but inherently understood the problem's core, making the answer seem obvious in retrospect. This applies to computing: one can force a solution through brute-force, or find an elegant approach that makes the problem disappear. A shift in perspective often reveals the problem was only a problem due to a flawed initial viewpoint.

The classic example isn't from computing but mathematics: the story of young Carl Friedrich Gauss quickly summing numbers from 1 to 100. Instead of tedious addition, he noticed the pattern of pairs summing to 101 (1+100, 2+99, etc.), yielding 50 * 101 = 5,050. This, whether factual or apocryphal, illustrates that great minds don't just solve problems; they discern underlying patterns for superior solutions. A great programmer, too, wouldn't simply write a brute-force summation program, but would understand the elegant solution, crafting a "beautiful program" that tackles the problem optimally.

It remains challenging to articulate the allure of struggling with a problem for days, yet the moment an elegant, beautiful solution is found, it delivers an unparalleled sense of triumph and satisfaction.


Reprinted with permission from 'Just for Fun: The Story of an Accidental Revolutionary,' by Linus Torvalds and David Diamond, HarperCollins, 2001.