[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Ports and streams

I think that we generally agree that were it not for performance
reasons, we would have only streams (in the FP/A&S sense), and not
ports; am I correct?  E.g., a stream object would need to be consed for
each character read from or written to a file; this would mean frequent
GC's if a lot of file I/O was happening.  It's unfortunate that our
design is driven by considerations like this, but I guess that's how
things are.

So the I/O primitives in the essential dialect manipulate things called
ports, which are positions on streams of characters.  The two notions
are equivalent (ports could be defined if the only primitives were stream
primitives, and vice versa), so people who care about writing code
which does I/O in a pure style can still do so, by implementing
I/O streams in terms of I/O ports themselves.

So far so good.  This message is about terminology, not semantics.  I
think that "port" is a bad term.  The real-life usage of the term "port"
(door or harbor) doesn't seem to be a good fit with that of the word
"stream".  I guess the image that's intended is of a door, with the
program on one side and a stream of things on the other, and the things
coming into the program's awareness or control through the door.  Or
perhaps the stream flows through the door?  Streams flow under bridges,
maybe, or through channels (I don't like "channel" because it has
incompatible connotations in computer science), or into aqueducts or
over waterfalls, but through doors?  The other meaning of "port"
doesn't make sense: rivers or possibly streams might flow into harbors
or ports, but that's not what makes a port a port; a port is someplace
where ships dock, load, etc.  So "port" is a very strange word to use in
connection with streams.

A different metaphor is that a "port" is a sort of a cursor or a marker
which moves along a sequence (stream).  Well, what moves up and down a
sequence or stream?  Here are some transportation metaphors:

	line, screen	cursor
	conduit		vehicle
	rail		train
	road		car
	river		boat
	stream		raft

How about "raft"?  A raft might be an appropriate vehicle for a stream.
I guess this is pretty cutesy, but it's an idea.  One argument in favor
is that "raft" doesn't have connotations in computer science like many
other words (port, channel) do.  Also, the metaphor is obscure enough
that no one would need to know how silly it is; users could imagine that
RAFT is an acronym, or some technical term derived from some obscure
branch of mathematics or semantics, or whatever.  Sounds sort of like
"rack" or "rail," terms that certain language designers use without
embarrassment.  And it's short, a distinct advantage.

These two metaphors reflect the difference between a stream and a
streambed.  If you want to see everything which floats by on a stream,
it's sufficient to sit one place (e.g. on a bridge, or on a bank, or at
its outlet) and relax and enjoy the view.  "Stream" here is the stuff
that is flowing.  If, however, you want to see all the places that the
stream goes, you have to get on a raft or boat or just wade the entire
length of the thing from source to outlet.  This "stream" is a
geographical thing, something you'd find on a map.

Besides the fact that "port" is a mixed (or at least poor) metaphor, I
am opposed to the term because it reminds me of Franz Lisp.  I'd rather
not be reminded of Franz every time I use Scheme.

I know this is pretty random, but I just wanted to voice my unhappiness
and get people thinking about more appropriate terms.