The Haunted Apple


Below is a story I submitted to the Computer Society Apple Users’ Group, which belonged to the University of Hong Kong Student Union. It was published in “Apple Users” magazine in the December 1984 issue.

Many of the ideas came from the work I did on personal computers during those years. I am always enthusiastic to apply paradigms from one area (in this case, ghosts and myths) to an unrelated area (in this case, Apple Computers, the favourite PCs of that day). I am glad that readers found this story amusing.

Most of the terms used are explained in the Afterwards section. Many readers asked me who Thomas Lam was. He is a real person I worked with in the months before writing this article. We were fond of talking about computer ghosts, which inspired me to write all this.

Finally, there are a lot of interesting quotes in the Appendix section.

Please note that the story is copyrighted material. Do not copy without the explicit authorisation of the author.

Preface to the August 2001 Edition

Since the article was written quite some time ago, people nowadays may not be familiar with (or remember) the technology of that era. Therefore, I would like to explain some of them here.

Disk Drives

In the 21st Century, most people are using PCs. Back in 1980s, the most popular computer is the Apple II Computer, with its many look-alikes.

In those days, “disk” meant 5-1/4 inch floppy disks. Each of them holds 140K bytes. Can you imagine an operating system sitting on a 140KB floppy? You cannot even install Windows 95 on a 100MB IOMEGA ZIP disk.

The disk drives were very primative. There was a manual switch to open/close the drive door. When you close a drive door, you actually physically lock the floppy from being removed, and press the the read/write head on the disk surface. When you open a drive door, you pull the head from the disk surface, and unlock the floppy so that it can be removed.

When you start up or shut down the computer, there are usually irregular power fluctuations throughout the system. If you had a floppy disk inserted and drive door closed, this power fluctuation might result in the drive head writing nonsense on the disk surface, rending the floppy unreadable. Therefore, the standard practice to power on an Apple was to insert the floppy, power on, and then close the drive door. When you wanted to shut down the system, you must first open the drive door. Contemporary floppy drives (since the 386 days) have special circuitry against this, and therefore you can safely leave a floppy in your PC. Unfortunately it also means that in the new era you can easily get infected by STONE or other boot sector viri by booting from a floppy disk accidentally left in the drive.

The floppy controller cannot be compared with the ones nowadays, which is itself an intelligent computer. The then controllers only accepted a single byte from the CPU, and wrote the magnetic flux directly to the read/write head. As a result, the operating system was responsible for encoding the bytes (click here to see why encoding is needed),

Not all patterns written to the disk are recognisable by the read head. Consecutive “one” bits are always readable, because there are timing bits (which are actually “zero” bits) between them. On the other hand, patterns with too many “zero” bits cannot be detected by the read head. Also, patterns must start with a “one” bit for it to be recognized as a byte at all. Therefore, out from all 256 different 8-bit patterns, only 34 of them can be reliably read back are used. Two of them are reserved for disk formatting (used in sector header and trailer), and the remaining 32 patterns are used for representing data.

So how come it appears we can write all 256 different 8-bit patterns to the disk? It is done by encoding. A sector (256 bytes) of 8-bit data was reformatted to a block of 410 5-bit data. For each 5-bit data, a corresponding 8-bit pattern (there are 32 reliable 8-bit patterns) is written to the disk. When a block of 410 data patterns is read back, they are decoded back to 256 8-bit data bytes.

Controllers nowadays do all these encoding for you. The CPU only need to talk to it in terms of sectors of bytes. For the Apple, the operating system needed to do the encoding itself.

writing the headers and trailers, doing the checksum, moving the drive head across tracks etc. In short, the operating system did everything the disk controller is doing today.

Copy Protection

Commercial software are sold on floppy disks. In order to protect against piracy, vendors used a variety of ways to stop their disks from being copied. Since the full process of reading the disk was done in software, vendors used their own routines to do all sorts of crazy things. Click here to see what kind of crazy things they did.

They would use techniques like non standard headers, non standard trailers, bad checksum, substandard inter section gap lenghts, invalid bit patterns, missing sectors or tracks, or by advancing the head by half track or quarter track increments… to make sure normal copy programs cannot read it. Another approach was to measure the skew angle between two consecutive tracks at run time, because this angle is not normally preserved by the copying process. Some even have physical damages (eg burn a hole) on the media, and detect for the presence of the defect at run time.

While it means pirates can’t easily copy them (they usually eventually can), legitimate customer can hardly make a backup copy. Unfortunately, a similar trend is being done in many CDROMs today. On this issue, I recommend you to read an article on why Content Protection must be stopped, written by John Gilmore.

Against these disk protectors, there came disk crackers. There are lots of software specialized in copying protected disks. Many of them needed expert knowledge to use, because there were hundreds of adjustable parameters, depending on what the disk protector did with their disks. These people are known as Disk Crackers.

Ghost Story

One final thing not related to the technology. The story about the Happy Valley graveyard is true. That is, it is a real rumour, not one that I made up for the article.

Do you believe in ghosts? It is not the answer that matters, but why — if yes, why yes? if no, why no?

Brooks Atkinson once said that people everywhere enjoy believing things that they know are not true, because it spares them the ordeal of thinking for themselves and taking responsibility for what they know. Go find a copy of How to Think about Weird Things: Critical Thinking for a New Age written by Theodore Schick Jr. and Lewis Vaughn. It is a very complete introduction to critical thinking — a skill which is more desperately needed now than in any other time.

The percentage of Americans today who take astrology seriously is larger than the perentage of people who did so in the early Middle Ages. I think it would be naive to write off so many people as stupid. It has been a mystery to me (that so many people can believe in so many weird things), until recently I learn that “Truth is not one of the strong selectors for memes”. The memes of Tarot card reading and crystal balls prey on the fear of uncertainty and of making the wrong decisions in a horribly complex world. When one cannot control one’s destiny, an illusion of control would be a good substitute.

Memes, like genes, evolve on their own. Unfortunately, the mechanism of evolution has no purpose in itself; it is simply the inexorable battle of replicators for access to whatever replication mechanisms are available. The world is full of memes spread by mind viruses, all competing for a share of your mind, your perception, your attetion. They care nothing for your well-being, but instead add to your confusion and subtract from your fulfillment. If you care for yourself, go read Virus of the Mind to innoculate yourself from their influence! The first chapter (Introduction) of the book is available on-line, free. If you like the book, buy it at Barnes & Noble (this link marks me as your referer, so please use this one).

Besides ghost stories, there are plenty of urban legends floating around. You have heard of people harvesting kidneys, or placing HIV-infested needles in theatre seats, haven’t you? Check out The Urban Legend Combat Kit to equip yourself against them!

The Article

The Haunted Apple
by Alex Fung, TC, DC, FS.


I would like to take this opportunity to thank Mr. Thomas Lam who introduced me to the subject of computer ghosts. I could not have become TC without his help. Credit must also be given to KSU corporation, that provided me with a haunted house for my TC(s) and FS training.

The Text

For every culture that survives long enough, there will be myths around. So does our Appleland. Lots of the legends and myths are imported from the continental Computerland. These are firmly believed by all Computerland and Appleland citizens, although the scholars refused to admit it openly. One of them is:

To err is computer. The holy mission of all programmers is to stop the computers from making mistakes.

However, owing to the research of the TCs, it was discovered that the computers are innocent — the trouble makers are actually ghosts. In fact, the work “TC” comes from the name of an ancient Chinese exorcist who was well known for his ability to locate and exterminate ghosts. Every computer with its power supply switched on is doomed to be haunted by ghosts. At first, very few people believe in ghosts, just as they had not believed in virus and germs in the old days. Yet, the truth find ways to manifest itself. TCs have gathered enough evidence that ghosts are responsible for computer misbehaviour.

A well known proof is the drive door phenomenon. If you live in Happy Valley (跑馬地), you might have noticed that one of the gates of the graveyard on Wong Nei Chung Road (黃泥涌道) is opened every evening and left unlocked until sunrise of the next day. The administrative staff tried to lock it before midnight, but then the ghosts that went out in the evening cannot come back, and start banging at the gate until it is unlocked. The same applies to our Apple. When you turn off the Apple, the ghosts will go away through the door of the [floppy] drives. If you do not open them before turning off the Apple, the ghosts will get trapped on your diskette, and you end up with a haunted diskette (with a lot of I/O errors). On the other hand, if you do not open the doors before turning on the power supply, the ghosts will knock your diskette off centre when they rush into the Apple. This will sometimes end up in an unsuccessful boot.

As in the case of most creatures, ghosts can be separated into what we called sexes. The TC word for ghost sexes is W. The W that corresponds to male sex is HW. H-ghosts are strong enough to play with voltage levels, drink up currents, and block signal paths. The corresponding female sex is SW. S-ghosts are more friendly. Most of the time, they are chattering with the CPU, persuading it to do things unanticipated by programmers. Animals like snails display both male and female characteristics on each individual. The W with this hermaphroditical feature is called FW, which only amounts to a very small portion of the total ghost population. Though yet without a formal proof, TCs believe that there is a fourth W of ghosts called NW. They are mutants that resembles the high impedance state output of tri-state logics. Essentially, they have existence but not properties, and they interfere with the working of the computer by their mere existence.

Note: some authors prefer to use the name No-W instead of NW. They claimed that it is more authentic and is rooted from the ancient word that means “without a home”. Yet for compatibility reasons, I considered the name NW to be superior, and is used throughout this document.

Since ghosts has four Ws, TCs can be logically divided into TC(s), TC(f), TC(h) and TC(n), while most TCs study in more than one discipline.

TC(s)s are responsible for exterminating s-ghosts. The followings are some typical methods they have been using.

The first step to prevent s-ghosts from living in your program is by proper design. If you have visited haunted castles, you will notice that all of them are old, large, dusty, with complex corridors. A program like that is a sure invitation for s-ghosts. Therefore, programs should be small, clean and tidy.

To prevent s-ghosts from entering your program when it is getting old, you should ask a TC(s) (who is often known as a guru) to write juju inside your program. Juju is a special form of calligraphy used by TCs to keep ghosts away. Computer languages often offer ways to bracket out the juju (eg /*…*/) so that the compilers will not be reading the juju as if they were part of the program content. Whenever you change anything in the program, you should always see if the juju needs refreshing, so that the s-ghosts would not get a chance of sneaking in.

Finally you should walk through every path of the program to make sure that no s-ghosts are hiding in some dark corners.

Against h-ghosts, a TC(h) typically uses magic wands to probe into the computer to locate the ghosts. Once located, he can use spells (some authors maintained that “welds” are used, but no one ever knows what a weld is) to cast them away.

Due to some unknown reasons, there is very few naturally occurring f-ghosts. It is believed by some TCs that all f-ghosts are introduced by a group of people known as DPs. In order to protect their diskettes from being duplicated, they implant f-ghosts to their disks. If you try to copy the disk, the f-ghosts will drive your Apple crazy. So, a portion of the TCs specializes in what we called DCs. They logically crack the disk by locating all the ghosts and try to make them behave. Some of the DCs using binding spells to stop the ghosts from disturbing the copy process, while the more powerful TCs locate and exterminate the ghosts to get a disk that can be copied in peace.

The n-ghosts are the most difficult ones to handle. Some TC(n)s are so powerful that they can cast spells to turn n-ghosts into some other Ws. Suppose one day your compiler yells an undeclared identifier, while your eyes, your CRT, your printer, your Wordstar, and your younger brother all claim to be able to see the declaration, what can you do? You may compile it once more, you may change the sequence of the declaration statements, you may try to declare the identifier an additional time, … — but until you try it out, you can never tell which of these would work. Some TC(n)s are specialized in the job of rearranging the environment so that the n-ghosts will go away. They are called the FSes, named after a special branch of Chinese knowledge that deals with a similar task. To the uninitiated, what an FS is doing is completely beyond their imagination. People have always found difficulties in understanding the frontier of rapidly developing technologies, like their inability to believe in virus or black holes not very many years ago.

You should now be convinced that wizardry is vital for survival on the Computerland and Appleland. Appleland citizens are strongly advised to visit Wong Tai Shin (黃大仙) periodically for the sake of their peace of mind.


Some people may found difficulties in understanding this article. To make sure that the message is conveyed, most of the disguised words are explained here.

KSU is a Pascal compiler working on CP/M. I used it heavily last summer and located over twenty s-ghosts inside the compiler. The real name of the compiler can be found by looking up the predecessor (in the Pascal sense) of each character.

HW is hardware, SW is software, FW is firmware (used quite inconsistently in the article), NW is nowhere. TC in “Tin C” (天師), juju is comments, magic wand is the probe of CRO or multimeters, DP is Disk Protection, DC is disk cracker, FS is “fone sui” (風水).

Ghosts are not exactly bugs. When we say there is a bug, we know what is wrong; when we say there is a ghost, we know nothing except that the program doesn’t work. It is this dimension of uncertainty that inspired Thomas the very notation of ghosts.

Appendix: Some More Computer Myths

Programmers are part time telepaths who can divine meanings from the ether when they are reading an undocumented program.

Computer users are just too happy to receive a program and would demand no more than what is provided by the programmer.

The most essential part of program development is coding. Whether it is ever used at all by whatever people for whatever purposes is of no concern to the programmer.

Operating Systems should be friendly. They should echo all commands and ask for confirmation. They should list all issued commands every five minutes so that the programmer can know what he is doing. Furthermore, the programmer should be able to undo commands issued (up to six months before) to protect himself against making mistakes.

The quickest way of getting a program written is to turn on your Apple, invoke Wordstar, look at the blank screen and wait for aspirations.

When writing a program, the programmer should concentrate on the most interesting parts. After these parts are coded, the boring and complex parts will get itself written somehow, sometime.

Programs are written for computers to read, not for humans. Therefore, it should be written in a condensed, cryptic form, so that the computer will waste less time in understanding what you are trying to tell it to do.

Every program is a fragile baby belonging to its creator. Any maintenance programmer attempting to touch it is an insult to the creator. Therefore, programmers should protect their own programs like how the Pharaohs protected their tombs.

Programming is a poetic art. Therefore, programmers should have a thesaurus by their side, and be sure that they do not use the same algorithm twice in any program.

Computers work extremely fast. To use them properly, one should write programs that run as fast as possible. Efficiency has virtues in itself.

The surest way to avoid obvious mistakes is to make things so complicated that there aren’t any obvious mistakes.

A good way to display brilliance and win admiration is to write programs that no one can understand. For better effects, do not write any comments, so that people will think that you can understand it.

December 1984.

If you like this article, consider sending me a donation!

Click the bold text to expand/collapse the details. When your mouse is over them, text change color to red and mouse pointer changes to hand. When details is expanded, you may also click the detail lines to collapse them (so you don’t need to scroll back to title line to collapse the details).

At several places, additional information is available as tool tips. Move the mouse on the words looking like these to see them.

back to My Favorite Things
Back to my home page