Just for Fun : The Story of an Accidental Revolutionary

Home > Other > Just for Fun : The Story of an Accidental Revolutionary > Page 5
Just for Fun : The Story of an Accidental Revolutionary Page 5

by Linus Benedict Torvalds


  “About that size.”

  “And what about your grandfather? Do you remember much about him?”

  “He was probably my closest relative but I don’t… Okay. He was overweight, but not fat. He was balding. He was withdrawn, sort of like an absent-minded professor, which he was. I used to sit on his lap and type in his programs.”

  “Can you remember what he smelled like?”

  “No. What kind of a question is that?”

  “Everybody’s grandfather smells like something. Cheap cologne. Bourbon. Cigars. What did he smell like?”

  “I don’t know. I was too preoccupied with the computer to notice.”

  Birth of an OPERATING SYSTEM[1]

  I

  Some people remember time according to the cars they drove or the jobs they held or the places they lived or the sweethearts they dated. My years are marked by computers.

  I had only three computers while I was growing up. There was the aforementioned Commodore VIC-20, which I inherited from my grandfather. It was one of the first “home” computers, the predecessors to the present-day PCs. The Commodore 64 became sort of the big brother to the VIC-20, followed by the Amiga, which had a particularly strong following in Europe. Those computers never became truly popular, like the PC or even the Apple II, which was already common about the time I played around with the VIC.

  In those days before the proliferation of PCs, most of the programming on home computers was done in assembly language. (I can’t believe I’ve taken to starting sentences with “In those days…”) Computers had their own home-brew operating system, the equivalent of what DOS was on a PC. Depending on the computer, it was either a rudimentary format or a slightly more enhanced one. Like DOS, the OS had a program loader and a basic language environment. Back then there were no standards and a number of companies wanted to control the market. Commodore was one of the better known of these.

  When I had gotten about as much as I could out of the VIC-20, I started saving up for a next-generation model. This was a big deal in my life. As I mentioned, I’ve lost track of who in my family was living where at what particular time, and a lot of other things, but the path to my second computer was something that’s hard to forget.

  I had some Christmas-and-birthday money stashed away (because I was born on December 28th, the two occasions are sort of melded together). I also earned some money one summer working on the clean-up crew in Helsinki’s parks. Many of the parks in Helsinki aren’t landscaped and well-maintained, but are more like recreational or green areas that are overgrown forests. What we had to do was saw off overgrown bushes or pick up dead branches—it was even interesting. I’ve always liked the outdoors. I also had a newspaper route, too, at one point—except that it wasn’t newspapers, it was junk mail. Actually, I wasn’t really into summer jobs, come to think of it. But I did them in those days. On the whole, I probably got more money from school stipends.

  In Finland, it’s relatively common for people to give endowments to schools, even the public elementary schools. So, starting in fourth grade, money gets distributed to students based on whatever the person setting up the fund had in mind. I remember one of the endowments in my school went to the best-liked kid in class. This was in sixth grade and we actually voted within the class on who should get the money. It wasn’t me who won, I might add. The bounty amounted to only about 200 Finnmarks, which was maybe forty dollars, at the time, but it seemed like a lot of money to give a sixth grader just for being popular.

  Quite often the money went to the best person in a particular subject or sport. And a lot of the awards were school-specific or funded through the government. In some cases, the funds dwindled over time. I remember one that amounted to about a penny in value. When that was the situation, the school would chip in to make it somewhat more useful, but it still was a fairly small sum of money; more than anything else, this was a way of maintaining the tradition of giving out money every year. Finland takes its academic traditions seriously, which is a good thing.

  So I would receive these stipends every year for being the Math Guy. By high school the awards got bigger. The biggest ones were on the order of $500. So that’s where most of the money for my second computer came from; my weekly allowance wouldn’t have paid for a computer. I also borrowed some money from my dad.

  It was 1986 or 1987. I was sixteen or seventeen. My basketball years were behind me. I spent an inordinate amount of time researching the field before deciding which computer to buy. PCs weren’t very good back then, so when I fantasized about my new machine I knew it wasn’t going to be a PC.

  I opted for a Sinclair QL, which many of you are probably too young to remember. Here’s the history. The Sinclair was one of the first 32-bit machines on the market for home use. Sir Clive Sinclair, the founder of the company, was the Steve Wosniak of Britain. He made these computer kits that were sold as Timex computers in the United States. That’s right, the same company that made Timex watches imported the Sinclair computer stuff and sold it here under the Timex name. The early ones were sold as kits before he started selling ready-made computers.

  The Sinclair had this operating system called Q-DOS. I knew it by heart back then. It was written especially for that particular computer. It had quite an advanced Basic for the time, and fairly good graphics. One of the things that excited me the most about the operating system was that it was multitasking: You could run multiple programs at once. However, the Basic part wasn’t multitasking, so you couldn’t run more than one Basic program at once. But if you wrote your own programs in assembly language, you could let the operating system schedule them and time slice it so you could run many of them at the same time.

  The computer contained the 8-megahertz 68008 chip, which was the second and cheaper version of Motorola’s 68000 chip. Internally, the first generation of 68000 chips were 32-bit, but externally had a 16-bit interface to anything outside the CPU (central processing unit)—such as memory or hardware add-ons. Because it could only load 16 bits at a time from memory, 16-bit operations were often quicker than the 32-bit operations. The architecture was hugely popular and it still exists today in a lot of embedded devices or cars. It’s not the same chip, but it’s based on the same architecture.

  The 68008 chip, the version in my computer, used 8 bits, not 16 bits, for its interface with the world outside the CPU. But even though it interacted with the outside world at 8 bits at a time, internally it was 32 bits. That made it more pleasant to program in many ways.

  It had 128 kilobytes of memory—not megabytes—which was huge at the time for a home machine. The VIC-20 it replaced had only 31/2 kilobytes of memory. And because it was a 32-bit machine it could access all the memory with no problem at all, which was unheard of back then. That was the main reason I wanted to buy the computer. The technology was interesting and I loved the CPU.

  I was hoping to get the computer at a discount by buying it at a store where a friend knew the owners. But it would have taken so long for the computer to arrive that I just shlogged down to Akademiska Bokhandeln, the largest bookstore in Helsinki, which had a computer section. I just bought it from them over the counter.

  The computer cost nearly $2,000. There used to be this rule that entry-level computers were always $2,000. It’s only in the last couple of years that this has changed. Now you can buy a new PC for $500. It’s like cars. Nobody makes cars for under $10,000. At some point, it’s not worth it anymore. Sure, companies can build a car that can be sold for $7,000, but the automakers reason that people who could afford $7,000 for a car are happier buying one for $10,000 that has extra stuff, like air conditioning, as standard equipment. If you compare entry-level cars this year with entry-level cars from fifteen years ago, they cost about the same. In fact, adjusted for inflation they might cost slightly less. But they’re a lot better.

  That’s how it used to be with computers. When computers were not something that everybody bought, there was a pain threshold of around $2,000. If th
e lowest-cost computer is much more expensive, a company isn’t going to be able to sell many of them. But they were expensive enough to manufacture that it didn’t make sense for a company to make them much cheaper. People would always pay the extra $200 or so to get a better machine.

  In the last two years they have become a lot less expensive to make. And even the low-end machines have gotten pretty good. Companies have lost many of the people who would pay the extra $200 for a slightly better machine. Since companies couldn’t sell on features alone, they’ve had to sell on price.

  I admit it: Back in 1987, one of the selling points of the QL was that it looked cool.

  It was entirely matte black, with a black keyboard. It was fairly angular. This was not a rounded, pretty-boy machine. It tried to be kind of extreme. The keyboard was about an inch thick because it was part of the same unit as the computer. That’s the way most of the home computers were designed. On the right-hand side of the keyboard, where you would have a keypad, you had two slots for the revolutionary Sinclair microdrive, which was this endless loop of tape that was used only on a Sinclair machine. It acted and was organized like a disk drive. Because it was one long loop, you could just spin it until you hit what you wanted. It turned out to be a bad idea because it was not as reliable as a disk drive.

  So I spent close to $2,000 for the Sinclair QL. Most of what I did with it was one programming project after another. I was always searching for something interesting to do. I had a Forth language interpreter and compiler, just to play around with. Forth was a strange language that nobody uses anymore. It was kind of a fun, niche-market language that was fairly widely used in the 1980s for different things, but it never became very popular, being difficult to follow for non-techie people. Actually it was kind of useless.

  I wrote programming tools for myself. One of the first things I bought for the machine was an expansion bay with an EEPROM card (Electrically Erasable and Programmable Read Only Memory). It’s memory you write yourself with special modules, and it stays around when you turn the power off. That way, I could have the tools easily available to me whenever I wanted, without having to load them into RAM (random access memory) and use precious RAM for programs.

  What got me interested in operating systems: I bought a floppy controller so I wouldn’t have to use the microdrives, but the driver that came with the floppy controller was bad so I ended up writing my own. In the process of writing that I found some bugs in the operating system—or at least a discrepancy between what the documentation said the operating system would do and what it actually did. I found it because something I had written didn’t work.

  My code is always, um, perfect. So I knew it had to be something else, and I went in and disassembled the operating system.

  You could buy books that contain partial listings of the operating system. That helps. You also need a disassembler, a tool that takes the machine language and turns it into assembly language. That’s important because when you only have a machine language version, it’s difficult to follow the instructions. You find that an instruction will jump to a numerical address, which makes it very hard to read. A good disassembler will make up names for the numbers and also allow you to specify names. It also can be used to help you identify particular instruction sequences. I had my own disassembler that I could use to create reasonably nice listings. When something didn’t work, I could go in and tell it to find the listing from a particular spot, and I could see everything that the operating system was going to do. Sometimes I used the disassembler not because something was buggy but because I was trying to understand what it was supposed to do.

  One of the things I hated about the QL was that it had a read-only operating system. You couldn’t change things. It did have hooks—places where you can insert your own code to take over certain functions—but only at particular places. It’s so much nicer to be able to replace your operating system completely. Doing an operating system in ROM (read-only memory) is a bad idea.

  Despite what I’ve said about Finland being such a technology butt-kicker, the Sinclair QL wasn’t making big inroads in Europe’s seventh-largest nation. Because the market was so small, whenever you wanted to buy upgrades for the iconoclastic, leading-edge machine, you had to do it from England, via postal order. It involved scouring catalogues until you found someone who sold whatever it was you wanted. Then you had to get together certified checks and wait weeks for delivery (this being before the days of Amazon.com and credit cards). That’s what I had to do when I wanted to expand my RAM from 128 kilobytes to 640 kilobytes. That was the drill when I bought a new assembler, to translate assembly language into machine code (the ones and zeros), and an editor, which is basically a word-processing program for programming.

  Both the new assembler and editor worked fine, but they were on the microdrives and couldn’t be put on the EEPROM. So I wrote my own editor and assembler and used them for all my programming. Both were written in assembly language, which is incredibly stupid by today’s standards. It’s complicated and time-consuming—I’d guess it takes a hundred times longer to solve a problem in assembly language than in the C language, for example, which was available at the time.

  I added a few commands to the basic interpreter that came with the machine so that when I wanted to edit something I basically just ran my editor automatically and it was instantly there. My editor was faster than the one that came with the machine. I was particularly proud of how fast I could write characters to the screen. Normally, with a machine like that, it would take so long to fill the screen with characters that you could see text scroll. And I was pleased with the fact that with my editor, you wrote text so fast that when you scrolled quickly down you created a blur. That was important to me. The improvement made the machine feel much snappier, and I knew that I had done a lot of work to make it operate so fast.

  At this time, there weren’t very many people I knew who were as involved in computers as I was. There was a computer club at school, but I didn’t spend much time there. It was basically for kids who wanted to know about computers. There were only about 250 students in my entire high school, and I don’t think anybody else had been using one since the age of ten.

  One of the big things I liked doing on my Sinclair QL was to make clones of games. I wrote clones of the games from the VIC-20 that I had enjoyed and sometimes I added enhancements. But mostly they were not better: a better machine, not a better concept.

  My favorite game was probably Asteroids, but I could never make a good clone of it. The reason was that, at the time, all the arcade Asteroids games were done with real vector graphics. Instead of having graphics based on small dots—pixels—they had graphics that were actually done the way a cathode-ray tube (CRT) works, which is to have electrons shot out from an electron cannon from behind the CRT and deflected with magnets. They got much higher-resolution graphics that way, but you couldn’t reproduce this very easily. You could make a clone, but it wouldn’t look like the original Asteroids game if you wrote it on a computer that didn’t have the special graphics capability.

  I remember making a Pac Man clone in assembly language. The first step is to kind of remember what the Pac Man characters are supposed, to look like. Then you try to draw them on a sixteen-by-sixteen grid of paper, with color. And if you are artistic, you can do a good job. But if you are Mr. Non-Artistic, like I am, it ended up looking like Pac Man’s sick cousin.

  Okay, so it wasn’t a very good clone. But I was really proud of it. The game was actually playable, and I sent it in to one of the magazines that published computer code. I had sold other programs to magazines and thought this would be a natural.

  Not.

  One of the problems was that the program had been written in assembly language. That meant that if you made the slightest, slightest mistake copying it from the magazine, it wouldn’t work.

  I wrote some of my own games, too. But it takes a certain mindset to create games. Because games require a lot of perfo
rmance, you have to get really low down into the hardware of the computer. I could do that, but I didn’t have the game play mentality. What makes a great game is not usually how fast it is or how good the graphics are. There has to be something that makes you play it—something that keeps you with it. It’s just like movies. Special effects are one thing, but you also need a plot. And my games never had a plot. A game has to have a progression, an idea. Often, the progression is just that the game gets faster. That’s what Pac Man does. Sometimes the maze changes or the monsters get better at following you.

  One of the things that interested me about Pac Man was tackling the problem of making graphics that don’t flicker. It’s a fairly common problem in older computer games, because without special hardware your characters just flicker. The way you move your characters around is to take away the old copy and write a new copy. If you happen to have bad timing, people can actually see when there’s no copy, so it flickers. You can get around this in multiple ways. You can actually draw the new guy first and then remove the old guy, but you must be careful not to remove that part of the old guy that was occluded by the new guy. Instead of seeing an irritating flicker, you get a good effect—you sometimes see the shadow of the old character on the screen. The brain interprets that in a good way. It doesn’t flicker, but it creates a motion blur. The trouble with this solution is that it is fairly expensive and time-consuming to create.

  There’s a reason that games are always on the cutting edge, and why they often are the first types of programs that programmers create. Partly it has to do with the fact that some of the smartest programmers out there are fifteen-year-old kids playing around in their rooms. (It’s what I thought sixteen years ago, and I still suspect it’s true.) But there’s another reason games are so pioneering: Games tend to push hardware.

  If you look at computers today, they’re usually fast enough for anything. But the place you test the limits of the hardware are with action games, like some of the 3-D ones that are now popular. Fundamentally, games are one of the few things on computers where you can tell if things aren’t happening in real time. In word processing, you don’t mind a delay of a second here or a second there. But in a game, it starts to be noticeable at a sub-tenth of a second. Games used to be fairly simple. These days, programming is actually a fairly small part of any game. There’s music, there’s the plot. If you compare it to making a movie, the programming component is just the camera work.

 

‹ Prev