Will.Whim

A weblog by Will Fitzgerald

I have to use words when I talk to you

Jim Waldo writes that it’s a good idea to send objects over wires (when doing IPC, etc.), and Tim Bray challenged him somewhat to consider sending XML instead. Waldo replied that you still have to define the semantics, and, of course, Bray agrees.

TANSTAAFL, of course. There has to be some kind of social agreement in place for the systems that people write to make sense of messages. Sometimes that agreement is to use natural language (English, etc.) tags that will help other people more or less understand what you mean. Sometimes the agreement is so strong you can use shortcuts–like sending bits representing programming language objects, with all of their implied semantics (class structure, types, role in a system, etc.).

In a system I’m writing at NASA, we send a UTM coordinate as a string like “[584180, 4142030, -20]”. If we store this in a definition file, that same coordinate looks like this:


<target>...
      <utm_easting>584180</utm_easting>
      <utm_northing>4142030</utm_northing>
      <utm_height>-20</utm_height>
</target>

Presumably, the later is easier to understand to a human reader familiar with UTM coordinates. But the key is agreeing to what a series of bits means. And it’s certainly easier to understand in general than inspecting the bit patterns underlying Java or Lisp or C++ objects. Strings (that is, sequences of characters) turn out to often be useful for communication between disparate systems just because they can be more easily interpreted by people. TANSTAAFL, but we can take advantage of several millenia of hard work at writing systems and maybe get a discount on dessert. (Using relatively ‘bare’ strings as the format for inter-process control is a lesson I learned from Jim Firby).

Advertisements

Comments are closed.

%d bloggers like this: