Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.37 KB | None | 0 0
  1. The Beauty of Programming
  2. by Linus Torvalds
  3.  
  4. I don't know how to really explain my fascination with programming, but I'll try.
  5.  
  6. To somebody who does it, it's the most interesting thing in the world. It's a
  7. game much more involved than chess, a game where you can make up your own
  8. rules and where the end result is whatever you can make of it.
  9. And yet, to the outside, it looks like the most boring thing on Earth.
  10. Part of the initial excitement in programming is easy to explain: just the fact
  11. that when you tell the computer to do something, it will do it. Unerringly.
  12. Forever. Without a complaint.
  13.  
  14. And that's interesting in itself.
  15.  
  16. But blind obedience on its own, while initially fascinating, obviously does not
  17. make for a very likeable companion. What makes programming so engaging is
  18. that, while you can make the computer do what you want, you have to figure
  19. out how.
  20.  
  21. I'm personally convinced that computer science has a lot in common with
  22. physics. Both are about how the world works at a rather fundamental level. The
  23. difference, of course, is that while in physics you're supposed to figure out how the world is made up, in computer science you create the world. Within the
  24. confines of the computer, you're the creator. You get to ultimately control
  25. everything that happens. If you're good enough, you can be God. On a small
  26. scale.
  27.  
  28. And I've probably offended roughly half the population on Earth by saying so.
  29. But it's true. You get to create your own world, and the only thing that limits
  30. what you can do are the capabilities of the machine and, more and more often
  31. these days, your own abilities.
  32.  
  33. Think of a treehouse. You can build a treehouse that is functional and has a
  34. trapdoor and is stable. But everybody knows the difference between a
  35. treehouse that is simply solidly built and one that is beautiful, that takes
  36. creative advantage of the tree. It's a matter of combining art and engineering.
  37. This is one of the reasons programming can be so captivating and rewarding.
  38. The functionality often is second to being interesting, being pretty, or being
  39. shocking.
  40.  
  41. It is an exercise in creativity.
  42.  
  43. The thing that drew me into programming in the first place was the process of
  44. just figuring out how the computer worked. One of the biggest joys was
  45. learning that computers are like mathematics: You get to make up your own
  46. world with its own rules. In physics, you're constrained by existing rules. But in math, as in programming, anything goes as long as it's self-consistent.
  47. Mathematics doesn't have to be constrained by any external logic, but it must
  48. be logical in and of itself. As any mathematician knows, you literally can have a set of mathematical equations in which three plus three equals two. You can do
  49. anything you want to do, in fact, but as you add complexity, you have to be
  50. careful not to create something that is inconsistent within the world you've
  51. created. For that world to be beautiful, it can't contain any flaws. That's how
  52. programming works.
  53.  
  54. One of the reasons people have become so enamored with computers is that
  55. they enable you to experience new worlds you can create, and to learn what's
  56. possible. In mathematics you can engage in mental gymnastics about what might
  57. be. For example, when most people think of geometry, they think of Euclidian
  58. geometry. But the computer has helped people visualize different geometries,
  59. ones that are not at all Euclidian. With computers, you can take these made-up
  60. worlds and actually see what they look like. Remember the Mandelbrot set¾the
  61. fractal images based on Benoit Mandelbrot's equations? These were visual
  62. representations of a purely mathematical world that could never have been
  63. visualized before computers. Mandelbrot just made up these arbitrary rules
  64. about this world that doesn't exist, and that has no relevance to reality, but it turned out they created fascinating patterns. With computers and programming
  65. you can build new worlds and sometimes patterns are truly beautiful.
  66.  
  67. Most of the time you're not doing that. You're simply writing a program to do a
  68. certain task. In that case, you're not creating a new world but you are solving a problem within the world of the computer. The problem gets solved by thinking
  69. about it. And only a certain kind of person is able to sit and stare at a screen
  70. and just think things through. Only a dweeby, geeky person like me.
  71.  
  72. The operating system is the basis for everything else that will happen in the
  73. machine. And creating one is the ultimate challenge. When you create an
  74. operating system, you're creating the world in which all programs running the
  75. computer live¾basically, you're making up the rules of what's acceptable and
  76. can be done and what can't be done. Every program does that, but the
  77. operating system is the most basic. It's like creating the constitution of the land that you're creating, and all other programs running on the computer are just common laws.
  78.  
  79. Sometimes the laws don't make sense. But sense is what you strive for. You
  80. want to be able to look at the solution and realize that you came to the right
  81. answer in the right way.
  82.  
  83. Remember the person in school who always got the right answer? That person
  84. did it much more quickly that everybody else, and did it because he or she
  85. didn't try to. That person didn't learn how the problem was supposed to be done
  86. but, instead, just thought about the problem the right way. And once you heard
  87. the answer, it made perfect sense.
  88.  
  89. The same is true in computers. You can do something the brute force way, the
  90. stupid, grind-the-problem-down-until-it's-not-a-problem-anymore way, or you
  91. can find the right approach and suddenly the problem just goes away. You look
  92. at the problem another way, and you have this epiphany: It was only a problem
  93. because you were looking at it the wrong way.
  94.  
  95. Probably the greatest example of this is not from computing but from
  96. mathematics. The story goes that the great German mathematician Carl
  97. Friedrich Gauss was in school and his teacher was bored, so to keep the
  98. students preoccupied he instructed them to add up all the numbers between 1
  99. and 100. The teacher expected the young people to take all day doing that. But
  100. the budding mathematician came back five minutes later with the correct
  101. answer: 5,050. The solution is not to actually add up all the numbers, because
  102. that would be frustrating and stupid. What he discovered was that by adding 1
  103. and 100 you get 101. Then by adding 2 and 99 you get 101. Then 3 and 98 is 101.
  104. So 50 and 51 is 101. In a matter of seconds he noticed that it's 50 pairs of 101, so the answer is 5,050.
  105.  
  106. Maybe the story is apocryphal, but the point is clear: A great mathematician
  107. doesn't solve a problem the long and boring way because he sees what the real
  108. pattern is behind the question, and applies that pattern to find the answer in a
  109. much better way. The same is definitely true in computer science, too. Sure, you
  110. can just write a program that calculates the sum. On today's computers that
  111. would be a snap. But a great programmer would know what the answer is
  112. simply by being clever. He would know to write a beautiful program that attacks
  113. the problem in a new way that, in the end, is the right way.
  114.  
  115. It's still hard to explain what can be so fascinating about beating your head
  116. against the wall for three days, not knowing how to solve something the better
  117. way, the beautiful way. But once you find that way, it's the greatest feeling in
  118. the world.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement