David Maddalena Portfolio


Does It Tick,


What Do Programming Languages Have To Do With A 130 Year-Old Watch Company?

When Jeff Dyer, owner and principal of Mountain View Compiler Company, talks about the process of writing compilers—the software machines that transform source code into machine code—it is not long before the conversation turns to watches. He might talk about the similarities between the history of watch making and the development of programming technology, or point out the skill required to build something compact, yet reliable and precise. ... One way or another he always works a conversation around to a device that is decidedly low tech compared to the macines he works on. But, he'd say, it's all about how things work: when Dyer inquires about the current state of a work in progress, he asks, "Does it tick?" Jeff Dyer has a thing for watches, and sees strong parallels between his work and that of the watchmaker.

Complicated Layers

Few people understand the complicated movement of a watch, the inner engine made up of layers of gears, levers, and springs. Nevertheless, when a person looks at the face of a watch, they expect to find the time of day. Dyer points out that our relationship to computers can be like that. As a program executes on the computer screen, few people reflect on the complicated layers of technology—software or hardware—that have enabled it to do so. The springs and gears of a watch movement mark time, communicating mechanically to the hands of the watch so that they, in turn, can communicate visually to the user the time of day. In the same way, there is a chain of events that make a computer work: there are software programs written that pass information in a source language, there are compilers that interpret that language and then send commands in a machine-readable language on to the processor, which finally translates the stream of inputs into a human-readable communication—some audio or visual representation.

But, what exactly does the compiler do? Most programming languages exist at a relatively high level, close to our own natural language, making it possible for programmers to easily learn and share their work. When first written, a program is described as source code. Computers can’t do anything with source code, because they only understand machine code, a low-level language consisting of sequences of zeros and ones. There is no way for a program to run on a computer without first being compiled. Compilers analyze the source code instructions, and translate them so that they are recognizable to the machine.

Compilers in action: language translation

In order to illustrate the work of the compiler, imagine a simple equation as it might exist in source code: "X=1+2." In order to evaluate this equation, it must be compiled. First, the compiler interprets the original, analyzing each part, and the whole. It will then reconstruct the equation into an assembly code, which may read,

push 1
push 2
sto x

Finally, the compiler produces machine-readable code:

124  1
124  2
167  2385000

The above are the decimal numbers associated with the binary zeros and ones the compiler actually sends to the computer.

And More Complicated Layers …

If the above seems simple, remember that each language used in writing for the computer must have its own compiler and each of these compilers must optimize their output for the target CPU. Not to mention the fact that programs are considerably more complicated than "X=1+2," and improvements in computers are constantly changing the rules. Compiler writing is not simple. At least the watchmaker never has to deal with "new and improved" systems of time measurement. Nevertheless, says Dyer, "A compiler is constrained by the definition of a language in the same way that the function of a watch is constrained by the nature of time." He agrees, "A watchmaker has limited freedom to innovate. He or she may find ways to make a smaller, more efficient movement, but in the end the watch always has to tick at a certain rate". Because writers of compilers usually specialize in particular languages, and because languages are always moving toward standardization, these limits will necessarily apply to compilers as well. The writer of compilers "can make an implementation small or fast, for example. But in the end, the simple fact is that it must compile the language." Does it tick?

Dyer is currently writing compilers for JavaScript, a programming language that powers the dynamic pages of a new interactive web. In addition to building JavaScript compilers into web browsers, he is involved in establishing the standard for JavaScript, known internationally as ECMAScript, which is based on the original language developed by Netscape. He sits on the small ECMA standards committee with representatives from Netscape, Microsoft, Sun, Hewlett Packard, and IBM.

Listening to Dyer drift between descriptions of the finer points of watchmaking and the details of his work on the ECMA committee one wonders if this business of writing compilers is closer to science or art. "I think neither," says Dyer. "Compiler making doesn’t seem to me to be a pure science." That would imply that there were laws governing the perfect compiler, and that’s just not the case, he says. "And there is something too final about a work of art. It can’t be improved. It "can be restored … but not improved." He decides on "craft" as the correct descriptor. A craftsperson constantly improves on their work, and builds on the work of others. "I can’t imagine a craftsperson making a quality watch movement without having done it a hundred times before. You get better at it, make thinner watches, lighter watches, etc. The craft is refined."

History of The Craft

Sometimes craft is refined so much that the craftsperson becomes obsolete. About the time that IWC started making watches, American automation technology changed the nature of most watch production, so that pieces could be mass-produced to a specification that allowed for precision in larger quantities. With the exception of a few companies, like IWC, machines now make most watches. "You probably can’t buy a watch that doesn’t tell time with reasonable accuracy. … Craft as process inevitably gets mastered and, ultimately, automated", says Dyer. So where does the craft of compiler making stand?

"I feel like we are still in a kind of middle ages of compiler making. It is still a craft. It can’t be automated yet, which is probably why I like it so much." While tools exist for the automation of certain aspects of the craft, such as "compiler compilers" like Lex and Yacc, these are tools that merely support the work of good programmers. "Think of a lathe in the hands of a watchmaker hundreds of years ago: it still took an extremely skilled craftsperson to produce a finished product. The same is true of compiler making today. For any particular language, there are only a small handful of production-quality compilers on the market.  The main reason for this is the great skill and effort required to make them."

Fifteen years of experience in compiler making means that Dyer has a deep knowledge of his craft. "You get to know the definition of a language inside-out. You know the architecture of the implementations. You know the outcome before you start, and you know how to get there."  Like a crafter of fine watches, Jeff Dyer wants to make machines that ‘tick’ and then some. "My goal is always to build a gem, a language machine that is perfect in every way."