The Philosophical Programmer: Reflections on the Moth in the Machine
In one of the most unorthodox yet necessary programming books ever to appear, Daniel Kohanski, a seasoned programmer and systems consultant, delves into the foundational concepts and basic mechanics of computers and computer programming. Rather than writing yet another book that teaches readers how to write code, Kohanski penetrates more deeply into the nature of programming istelf. By exploring what programming is all about, The Philosophical Programmer: Reflections on the Moth in the Machine offers an introduction for the computer neophyte as well as an opportunity for experienced programmers to understand better the fundamental nature of their craft.
1120871929
The Philosophical Programmer: Reflections on the Moth in the Machine
In one of the most unorthodox yet necessary programming books ever to appear, Daniel Kohanski, a seasoned programmer and systems consultant, delves into the foundational concepts and basic mechanics of computers and computer programming. Rather than writing yet another book that teaches readers how to write code, Kohanski penetrates more deeply into the nature of programming istelf. By exploring what programming is all about, The Philosophical Programmer: Reflections on the Moth in the Machine offers an introduction for the computer neophyte as well as an opportunity for experienced programmers to understand better the fundamental nature of their craft.
14.99 In Stock
The Philosophical Programmer: Reflections on the Moth in the Machine

The Philosophical Programmer: Reflections on the Moth in the Machine

by Daniel Kohanski
The Philosophical Programmer: Reflections on the Moth in the Machine

The Philosophical Programmer: Reflections on the Moth in the Machine

by Daniel Kohanski

eBook

$14.99 

Available on Compatible NOOK devices, the free NOOK App and in My Digital Library.
WANT A NOOK?  Explore Now

Related collections and offers


Overview

In one of the most unorthodox yet necessary programming books ever to appear, Daniel Kohanski, a seasoned programmer and systems consultant, delves into the foundational concepts and basic mechanics of computers and computer programming. Rather than writing yet another book that teaches readers how to write code, Kohanski penetrates more deeply into the nature of programming istelf. By exploring what programming is all about, The Philosophical Programmer: Reflections on the Moth in the Machine offers an introduction for the computer neophyte as well as an opportunity for experienced programmers to understand better the fundamental nature of their craft.

Product Details

ISBN-13: 9781466878792
Publisher: St. Martin's Publishing Group
Publication date: 08/19/2014
Sold by: Macmillan
Format: eBook
Pages: 234
File size: 1 MB

About the Author

Daniel Kohanski, author of The Philosophical Programmer, is a consulting systems engineer who works for the Bank of America. He lives in San Francisco.


Daniel Kohanski, author of The Philosophical Programmer, is a consulting systems engineer who works for the Bank of America. He lives in San Francisco.

Read an Excerpt

The Philosophical Programmer

Reflections on the Moth in the Machine


By Daniel Kohanski

St. Martin's Press

Copyright © 1998 Daniel Kohanski
All rights reserved.
ISBN: 978-1-4668-7879-2



CHAPTER 1

BEYOND THE CUCKOO CLOCK


The degree to which we make and use tools is one of the qualities that distinguishes us from the rest of the animal kingdom. Even so simple a thing as a pointed rock gave our hominid ancestors new powers: They could use it to cut up meat, and could even kill game that had previously been too strong, too fast, or simply too big for their unaided bodies to handle. A dead limb might become a lever to pry up a boulder that their muscles by themselves could never budge. The essence of a tool is that it extends our reach, multiplies the power of our limbs, improves our eyesight, and in countless other ways increases our ability to manipulate and control the world around us. The development of new tools is one of the ways in which we measure the progress of our species from hominid to human.

Until recently (that is, recently even by historical standards), tools were used primarily to extend the physical powers of our bodies. We use the hammer to increase the power of our fist; we use the plow to help break up soil too hard for our fingers; we use sacks to carry more seed than our hands can hold. All of these require our physical presence and our physical involvement, and for all of them, no matter how much they magnify the power of our muscles, they are limited to providing an incremental increase of the enabling muscle power.

Now consider an example of a different kind of tool: the medieval clock. It was driven not by the constant action of our muscles but by the movement of weights and counterweights; once set in motion, it could function for hours or days with no further human intervention. Whereas other tools altered our environment, the clock altered our perception of the environment instead. Much of this was done deliberately; monks in their medieval monasteries had committed themselves to saying their prayers at precisely defined times of the day, and to miss even once was to put their immortal souls in peril. Rather than guess at the hour of Prime (6 A.M.), they developed ever more sophisticated instruments to announce the time for them. Thus they left the natural time of circadian rhythm and daily course of the sun, choosing instead to be guided by instruments which they had devised but over which they had somewhat less than complete control — for of course they could not arbitrarily change the time once it had been established. In a small way, this tool exerted control over the toolmaker.

Because tools such as the clock expand the power of our minds rather than our muscles, it becomes part of their function to give us guidance and even control. The human mind cannot measure time with the accuracy of even a cuckoo clock, so we have learned to rely on timepieces to determine the proper time and will even cite them as authority for our actions. When the cuckoo comes out to sound the hour, we assume that it is correct. That is to say, we depend on the clockmaker's skill to provide us with an accurate device. And as with other tools of this sort, as their complexity increases it becomes harder and harder for the ordinary, unskilled user to fix them when they go wrong, or sometimes even to be aware that they have gone wrong at all.

The modern computer is even more a tool of the mind than is the cuckoo clock. Although its appendages can manipulate physical objects with great precision and dexterity, the computer itself is essentially a tool that extends the power of our thoughts. But it goes far beyond the cuckoo clock and any other mind tool we have invented thus far because, unlike any of them, it is a general-purpose tool that can be transformed almost at whim into nearly anything that our minds can conceive.

Yet there are still some ways in which the cuckoo clock resembles the computer. It processes raw data — the movement of weights or a spring or a pendulum — into useful information: the time. Once started and set, it operates for the most part without human intervention. It makes decisions, such as when to send the cuckoo out to sound the hour, on its own, again without human intervention once the clockmaker has designed and built its gears. The cuckoo clock and its contemporaries are in fact early examples of what today would be called an analog computer.

Analogs are representations of objects in the world. An analog computer processes these representations as continuous streams of information — a flow rather than a set of discrete intervals. It is the difference between a sweep second hand and one that jumps from second to second; the sweep movement is an exact analog of all the infinite instants of time. What makes the cuckoo clock a kind of analog computer is its processing of the continuous swings of its pendulum or the smooth rise and fall of its weight and counterweight.

Analog computers are not widely used these days. While they can handle infinitely varied input, they are limited in their ability to preserve and manipulate this data. A telephone circuit can carry the nuances and tones of a human voice in all its infinite varieties, but as the voice travels from switch to switch on its way to its destination, it loses more and more of its quality until, sent far enough, it can become unrecognizable gibberish. The power of the modern computer comes in large part from its processing of data as a set of discrete units — as digital information. Digital technology analyzes the continuous voice curve and assigns a number to various points on the curve. These numbers are then transmitted to the receiving end, which reconverts them into sounds that, while not a perfect match for the original, provide a close approximation. Digital technology trades perfect representation of the original data for a perfect preservation of the representation. To return to our clock example, an analog clock may use a sweep second hand which might be exactly accurate, but which cannot be exactly described. On the other hand, one can look at the face of a modern digital timepiece and describe exactly what time it reads, though such a clock is accurate, at best, only to the nearest second.

Digital technology provides far more flexibility in toolmaking than the analog world can. The cuckoo clock can decide when to send out the cuckoo, but that is about it. The microcomputer in a modern answering machine, however, can tell us what time a call came in, how long the message ran, and perhaps even where it came from. In theory, we could build an analog device to do these things as well. But it would not be able to do anything else unless we disassembled it and rebuilt it for its new task. The digital computer, however, uses for its instructions a set of discrete numbers rather than a series of gears or other analog devices. Thus the advantage of the digital computer is that to change what it does, we need only change these instruction numbers — its programming — and start it up again. If we want to add new features to the answering machine, in many cases we can do so simply by reprogramming it.

It is this idea of programming that gives the modern computer its power. Merely by changing a set of written instructions we create new tools out of the same physical device: we can turn the computer into a clock, an adding machine, a typewriter, or even a chess or Scrabble player. For the first time, words themselves have become tools which in and of themselves cause things to happen. Manual dexterity need no longer be a requirement for a physical creation; instead, it is the ingenuity of the programmer's thinking that is crucial to bringing an idea to fruition. In this new era, the primary creative force is becoming less and less the hand and more and more the word.

Words — instructions to a computer — have become tools largely because of another major component of the modern computer: its memory. Early computing devices were driven by numbers punched as holes in cards or paper tape; even today, a Jacquard loom will weave a cloth pattern as directed by a punched card, and player pianos will play music according to the notches on a drum. The Harvard Mark I, which started operation in 1944, followed instructions punched on holes in paper tape to produce gunnery tables for the U.S. Navy. All such devices, however, had a common limitation: they could not change the instructions or the data on their own. If any change was needed — a new formula for a table, for example — the entire tape had to be punched all over again.

By the time the Mark I was running, engineers had already recognized this restriction and were working to overcome it by developing methods of storing numbers in a modifiable medium — that is, memory. Early forms of memory included mercury delay lines, vacuum tubes, and magnetic drums. The ENIAC, another prototype computer built during World War II, used 18,000 vacuum tubes — a phenomenal number for the time. By 1954, core memories — small doughnut-shaped magnets on a wire grid — were in use in commercial computers, and the transistor was replacing the vacuum tube. It was now possible to store large groups of numbers that could be easily manipulated at electronic speed.

The EDVAC project, successor to the ENIAC, inspired another breakthrough, one that now defines the modern computer: the idea of a program as data. The ENIAC was programmed, as some of its predecessors had been, by setting wire plugs in a board. This method not only made reprogramming a time-consuming chore, but it also made programs slow to execute. The mathematician John von Neumann, assisting the ENIAC and EDVAC projects in 1944–45, documented a new approach that has since been likened to the invention of the wheel: storing the instructions in the computer's memory along with the data.

Storing the program in memory meant that the new computer could access each instruction at the same electronic speed with which it accessed the data. But it also meant that the computer could treat instructions as though they were themselves data — that is, numbers to be manipulated. This ability is the basis of all modern programming. A programmer writes a program — a set of instructions — using words that more or less resemble English (or other natural language) and enters these words into the computer as data. A program called a compiler then examines these words and converts them into numeric instructions, which the computer circuitry can execute. It then puts these new numbers into memory, and the computer executes them. A program can even alter its own instructions in response to changing circumstances, which is a basic prerequisite of artificial intelligence. Just as we change and refine our actions as we learn more about our environment, so the computer is capable of altering its programming as it acquires more data.

Each instruction that the computer executes is stored in a particular location in its memory, and the computer normally proceeds from one instruction to the next. However, there are some instructions which will alter the flow of execution based on some condition — for instance, if the value of a piece of data exceeds a defined threshold, the computer will be directed to execute a different set of instructions than it would have otherwise. These types of instructions are called conditional branch instructions, and they give the computer the ability to make decisions. In a rocket guidance system, for example, the computer is constantly receiving new data — the current position, speed, and angle — and making decisions based on that data to increase or decrease the fuel flow to the various thrusters that keep the rocket on target.

Although we often speak of the computer as making decisions, in reality it is the programmer who decides, or rather, it is the programmer who determines the conditions under which the computer will execute one or another set of instructions. The computer does nothing on its own, but only what some programmer has told it to do. If the programmer gives incorrect instructions, the computer will blithely follow them. In this respect the computer is no more than an infinitely more complex cuckoo clock, which is only as accurate as the skill of the clockmaker. But where a faulty cuckoo clock might result only in a missed appointment, the consequences of a failure in a computer program can be drastic indeed.

The cuckoo clock affected the lives of those who depended on it although it provided only a single piece of information (the correct time), and even the earliest computers quickly became indispensable for solving all kinds of mathematical problems. But the ultimate difference between the computer and the cuckoo clock lies in the computer's generalized ability to process almost any kind of information, not just the value of a formula or the time of day. Stock transactions and bank transfers can be instantly ordered and credited. Telephones can be made to hold calls, to transfer or reject calls, to remember who called while the line was busy, all by prior instruction to a computer. Photographs and movies can be enhanced, colorized, and even completely altered through computer graphics. Pacemakers can adjust a heart's rhythm instantly in response to the changing state of the heart muscles. Our era has barely begun to explore the possibilities of the computer, and yet it is already known as the Computer Age.

But each new use of the computer's abilities means a new demand on the programmer's talents. The early days of simple computation of a mathematical formula have long since given way to complex manipulations of vast quantities of data, with each innovation giving rise to demands for more — and all of it is controlled by some programmer's instructions to a machine that is both blindingly fast and witheringly intolerant of error. This almost inhuman requirement for accuracy in computer programming has both philosophical and practical ramifications. The next chapters and Part IV explore some of these issues, while Parts II and III explain some of the means by which we ease the burden of dealing with them.

CHAPTER 2

IS THERE AN AESTHETIC OF PROGRAMMING?


A program is a set of detailed instructions given to a computer to perform a specific task. The computer will take no action without such instructions. In this respect, the computer is no different from a shovel. Just as a shovel will do nothing on its own, and performs its function only when someone picks it up and shoves it into the dirt, so a computer does nothing unless we give it orders. It matters not whether the motivating force is muscle power or typed commands; what is important is the motivation, which in all cases comes from the human mind.

It is therefore appropriate to speak of computer programming, as we speak of all other human activities, as having an aesthetic aspect. While aesthetics might be dismissed as merely expressing a concern for appearances, its encouragement of elegance does have practical advantages. Even so prosaic an activity as digging a ditch is improved by attention to aesthetics; a ditch dug in a straight line is both more appealing and more useful than one that zigzags at random, although both will deliver the water from one place to the other. Getting a computer program to deliver its intended result is a far more complex task than digging a ditch from a well, and attention to the aesthetic aspects ought to be an essential part of the process.

To begin with, there are aesthetic concerns inherent in the design of a program. Every program is the expression in computer language of a series of actions that the computer needs to take in order to solve a problem. Each such action or set of actions, when described in theoretical terms, is called an algorithm. While there may be a seemingly endless number of algorithms that can be used to solve a problem, some are more efficient, more elegant — more aesthetically correct — than others.

Consider, for example, the designing of a house. Did the architect put the bathroom near the bedrooms, or at the other end of the hall? And are there enough bathrooms for the people who will be living there? Is the kitchen near enough to the bathrooms to use the same water supply, or will extra money need to be spent to lay more pipes? Are there useless corners and dead ends? How much sunlight will each room have? There is not necessarily one right answer to any of these questions — it may be that putting the bathroom near the bedrooms justifies the cost of extra pipe — but it is clear that there are better designs and there are worse designs. The better designs are more aesthetically pleasing because they are more efficient and take more considerations into account.

The same is true with programming design. Although we use algorithms instead of blueprints, the same types of questions need to be raised: Is this piece of the structure necessary? Will it get in the way of other parts? Is it too far from — or too close to — other steps in the process? How much weight should be given to each part in order to achieve an overall balance? Is there another, more efficient way to reach the same solution? And, of course, what can be done to ensure that this is a correct solution?


(Continues...)

Excerpted from The Philosophical Programmer by Daniel Kohanski. Copyright © 1998 Daniel Kohanski. Excerpted by permission of St. Martin's Press.
All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Table of Contents

Contents

Title Page,
Copyright Notice,
Epigraphs,
Dedication,
Preface,
PART I: A PHILOSOPHICAL INTRODUCTION,
1. Beyond the Cuckoo Clock,
2. Is There an Aesthetic of Programming?,
3. The Ethical Quotient,
PART II: THE STRUCTURE OF THE COMPUTER,
4. Types of Computers,
5. The Parts of a Computer,
6. The Construction of Memory,
7. "On a Clear Disk You Can Seek Forever",
8. A Brief Interruption,
9. Operating Systems,
PART III: FUNDAMENTAL TOOLS OF PROGRAMMING,
10. The Language of the Machine,
11. Forms of Data Definition,
12. Classes and Types of Statements,
13. The Functional Program,
14. A Short Commentary,
15. Algorithms and Objects,
PART IV: THE PROGRAMMER'S TRADE,
16. The Moth in the Machine,
17. The Real World Out There,
18. The Limitations of Design,
19. Programming as Abstraction and Reflection,
Appendix: Number Representations,
Acknowledgments,
Glossary,
Selected Bibliography,
About the Author,
Copyright,

From the B&N Reads Blog

Customer Reviews