Recently I re-read Stephen Kell's article, "Some Were Meant for C: The
Endurance of an Unmanageable Language", where he argues that C owes
its longevity in part to its "communicative" design: memory may be
treated as a bundle of communication channels, bits can be interpreted
as objects and vice versa.
The communicativeness of C is something that I recognize and appreciate.
Nevertheless, I feel like Swift could be a better "communicative"
language than C if it had primitives or a library with which to describe
binary interfaces such as protocol packets, storage formats, device
registers, or DMA descriptors, as those interfaces actually operate in
Binary interfaces have some concepts in common, including address space,
address space regions and mappings, and so on. Several properties
commonly describe address spaces and the regions therein:
- allowed/advised access alignments & widths
- un-RAM-like access side-effects
- access-type restrictions: read-only, non-executable
- granularity of exception reporting
In software that uses binary interfaces, it is common to push layers of
interpretation onto regions:
- storage type
- mutually-exclusive region roles or agent ownership
- binary-encoded "arrows" linking one region to another
- roles deriving from position, linkage, and/or self-description
- synchronization requirements
- source of authority: content in one region imparts access and/or
interpretation to other regions
I cannot see any reason in principle that Swift should not be able
to operate on binary interfaces using expressions that are precise,
predictable, and efficient. Is anyone already working on Swift
primitives or an API for this?