When Clockwork Meets Logical Time
The escapement wheel of a printed orrery clicks with metronomic precision, each tooth advancing the gear train by exactly one increment. No planetary position can advance until the previous motion completes—a mechanical guarantee of causal ordering that would make Leslie Lamport proud.
In 1978, Lamport solved a similar problem in distributed computing: how do you timestamp events when physical clocks drift and network delays vary? His insight was elegantly simple—logical clocks that tick not with mechanical regularity, but with the rhythm of computation itself.
(defn tick-clock [clock]
(inc clock))
(defn receive-message [local-clock remote-clock]
(inc (max local-clock remote-clock)))
(defn send-message [clock]
{:timestamp (tick-clock clock)
:payload "orbital-update"})
Each process maintains its own logical timepiece. When sending a message, tick forward. When receiving one, synchronise by taking the maximum of both clocks and advancing. Just as an escapement ensures no gear skips ahead of its predecessor, Lamport timestamps guarantee that causally related events maintain their proper sequence.
package Logical_Clock is
type Timestamp is new Natural;
procedure Tick(Clock : in out Timestamp);
procedure Synchronise(Local : in out Timestamp;
Remote : in Timestamp);
end Logical_Clock;
package body Logical_Clock is
procedure Tick(Clock : in out Timestamp) is
begin
Clock := Clock + 1;
end Tick;
procedure Synchronise(Local : in out Timestamp;
Remote : in Timestamp) is
begin
Local := Timestamp'Max(Local, Remote) + 1;
end Synchronise;
end Logical_Clock;
Ada’s disciplined approach to concurrency echoes the mechanical constraints that make escapements reliable. Both systems trade raw speed for correctness—the escapement could run faster without its deliberate pauses, just as distributed systems could skip synchronisation. But in both clockwork and computing, precision trumps haste when the alternative is chaos.