Chapter 8. On-the-Fly Code Generation for Image Processing

Charles Petzold

Among the pearls of wisdom and wackiness chronicled in Steven Levy’s classic history Hackers: Heroes of the Computer Revolution (Doubleday), my favorite is this one by Bill Gosper, who once said, “Data is just a dumb kind of programming.” The corollary, of course, is that code is just a smart kind of data—data designed to trigger processors into performing certain useful or amusing acts.

The potential interplay of code and data tends to be discouraged in most conventional programming instruction. Code and data are usually severely segregated; even in object-oriented programming, code and data have their own special roles to play. Any intermingling of the two—such as data being executed as if it were machine code—is considered to be a violation of natural law.

Only occasionally is this barrier between code and data breached. Compiler authors write programs that read source code and generate machine code, but compilers do not really violate the separation of code and data. Where the input and output are code to the human programmers, they are just data to the compilers. Other odd jobs, such as those performed by disassemblers or simulators, also read machine code as if it were data.

As we all accept rationally, if not emotionally, code and data are ultimately just bytes, and there are only 256 of them in the entire universe. It’s not the bytes themselves but their ordering that gives them meaning and purpose. ...

Get Beautiful Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.