home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / arch / 11989 < prev    next >
Encoding:
Internet Message Format  |  1992-12-29  |  8.0 KB

  1. Xref: sparky comp.arch:11989 comp.sys.dec:6642 comp.sys.sgi:18373 comp.sys.hp:14415
  2. Path: sparky!uunet!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  3. From: torek@horse.ee.lbl.gov (Chris Torek)
  4. Newsgroups: comp.arch,comp.sys.dec,comp.sys.sgi,comp.sys.hp
  5. Subject: Re: Comparison of Alpha, MIPS and PA-RISC-II wanted
  6. Date: 30 Dec 1992 00:01:31 GMT
  7. Organization: Lawrence Berkeley Laboratory, Berkeley CA
  8. Lines: 136
  9. Message-ID: <28164@dog.ee.lbl.gov>
  10. References: <1992Dec29.044012.1@cc.curtin.edu.au> <3623363@zl2tnm.gen.nz>
  11. NNTP-Posting-Host: 128.3.112.15
  12.  
  13. (Note, I have no idea what any of this is doing in any of these
  14. newsgroups, but....)
  15.  
  16. [someone---the names have been deleted to protect the guilty :-) ---writes]
  17. >>But U*** still loses because it has no way of telling the application what
  18. >>TYPE of file structure it is...
  19.  
  20. [someone else writes]
  21. >Exactly.  Well, you can pull kludgery with magic numbers....
  22.  
  23. OK, I can see it is time to go back to basics here.  (Not BASIC, basics :-) )
  24.  
  25. The first principle is that there must be *some* shared ideas in order
  26. to make communication possible.  If I were to write this article in
  27. Swahili, you could read it if and only if: a) you knew it was in
  28. Swahili; and b) you knew Swahili, or had a translation system.  Without
  29. both of those, no communication would occur.  This article, like too
  30. many others, would all be noise.
  31.  
  32. This sort of thing---links via shared ideas that allow one to
  33. understand part of a message, which then allows still further
  34. understanding, and so on---is just what happened with the Rosetta
  35. Stone.  Pre-Rosetta, trying to read Dead Sea Scrolls was something like
  36. trying to read a structured file without any idea what the structure
  37. was.  (I may have some details confused; I am not into archaeology.
  38. But the idea is valid: you need to have some key to get started.)
  39.  
  40. Now let us consider computer files.
  41.  
  42. A computer data store simply holds a sequence of bits.  Those bits,
  43. those 1s and 0s, have no inherent *meaning*---all the meaning arises
  44. through interpretation.  We need some way to interpret each bit.
  45. This interpretation occurs at many levels: some of the bits on a
  46. disk, for instance, are for error correction.  Others mark sector
  47. headers; still others (`gap' bits) are left simply for timing.  The
  48. remainder are what we usually think of as `user and system data'.
  49.  
  50. (Incidentally, note that I have started several levels up.  The disk
  51. does not actually contain *bits* but rather merely records magnetic
  52. domain changes.  When moved across a conductor, these generate a
  53. sequence of electrical signals which must be carefully interpreted in
  54. order to derive the individual bits.)
  55.  
  56. In our case, these `data bits' are grouped in sets of 8.  This was not
  57. always true, and there are probably a number of systems that still
  58. group them differently, but most modern machines use `bytes' as a basic
  59. building block.  Each set of 8 again has an arbitrary interpretation:
  60. 01101001 may mean `the number 105' (a `big-endian' integral
  61. interpretation) or `the number 150' (a `little-endian' integeral
  62. interpration) or perhaps `the letter lowercase i' (an ASCII
  63. interpretation of code 105).  They could be part of a larger integer,
  64. or maybe they are even part of a floating point number or something
  65. equally bizarre.
  66.  
  67. Fortunately, most of use use computers with a few standard
  68. interpretations.  If we agree, for purposes of netnews, to write the
  69. bits in a big-endian fashion, we can talk about 8, 16, 32, and 64 bit
  70. integers---these are available on practically every modern system---and
  71. 32, 64, 80, and often 128-bit floating point numbers in either IEEE or
  72. some proprietary notation.  Textual strings can be represented in
  73. ASCII, either with a leading count, or more typically just by enclosing
  74. in special `quote' characters.  More complicated interpretations, such
  75. as Lisp-like S-expression structures or relational database tables, we
  76. generally represent using some ad-hoc notation and hope that our
  77. readers apply the proper interpretation from that.
  78.  
  79. Of course, our computer systems are generally not as flexible as our
  80. people, and our people have far more experience with various forms of
  81. communication than do our machines.  So when we use a computer we
  82. generally have to instruct it, in gory detail, as to just how we want
  83. those 1s and 0s interpreted.  And here we reach the point where the
  84. flamage occurs.  Some OSes provide an enormous collection of `standard
  85. interpretations', and some provide only a few.  The VMS people insist
  86. that it is better to have 16 built-in record formats; the UNIX people
  87. insist that it is better to have none.
  88.  
  89. Both are right, both are wrong; neither way is `better'.
  90.  
  91. (By the way, the `16' above was selected at random.  I have no idea
  92. how many formats RMS officially supports, and if you count each record
  93. length as a different format you will get a different number than if
  94. you count all `fixed block' variants as one format.  It does little
  95. good to set an exact number.  The fact is that RMS provides a number
  96. of standard formats---fixed and variable block, stream-LF, etc.---and
  97. the usual UNIX interface is just `a stream of bytes'.)
  98.  
  99. Let us suppose you want to, say, keep an inventory.  Under VMS, you can
  100. choose a fixed block format with a particular record size, and store a
  101. sequence of records: manufacturer, model, serial number, quantity on
  102. hand, stock level, prices, date last ordered, date last sold, etc.  On
  103. a UNIX system you have to package up the records yourself.  But this is
  104. the easy part!  Managing a sequence of records is trivial.  The hard
  105. work goes into deciding what data to keep, how to cross-index, what
  106. operations to support, what kind of security to provide, and so forth,
  107. and into developing tools for answering questions about the data
  108. (`should we drop the Baby Spits Up doll?').  As far as I know, no OS
  109. solves these problems directly (yet?).  One can buy canned solutions
  110. for both VMS and UNIX systems, of course, but in that case the
  111. underlying OS implementation is irrelevant; one can hardly argue that
  112. having or lacking RMS is inherently superior just because FooBase sells
  113. a system for VMS or UNIX (or both or neither).
  114.  
  115. Now, one can say that RMS is provided but need not be used.  This is a
  116. valid point.  But the argument cuts both ways: features provided may be
  117. used inappropriately.  Indeed, for some purposes a largely-unstructured
  118. text file may prove better than a highly-structured collection of
  119. records.  Grep's regular expressions are quite simple and yet act as
  120. a powerful query tool (this reminds me of Kernighan's story of using
  121. egrep to find words one can spell on a calculator, but never mind that).
  122. Fortunately or not, grep does not work on records.  If one had records,
  123. grep would need some way of `flattening' them for display anyway.
  124.  
  125. And then there are `magic numbers'.  Are they a kludge?  Well, no and
  126. yes.  They are an ad-hoc method to insert a `representation key' in a
  127. file.  Given a simple `stream of bytes' file, if one takes the first
  128. two or four bytes of a file and puts an `unlikely' value there, one can
  129. write programs that find these `magic numbers' and change their
  130. behavior based upon them.  One might further wonder how exactly this
  131. differs from reading a few bytes from a specially-defined location in
  132. every file, and deciding the file's type based on that information.
  133. Indeed, there *is* *no* difference except in convention: RMS stores
  134. file types in a system-decreed manner, and RMS is included in
  135. everything used in the system, so that, by convention, everything makes
  136. the same interpretation of the magic number.  UNIX systems are, in this
  137. sense, looser: each individual program can attempt to interpret file
  138. types or not, in an individual manner.  A rigid system avoids chaos,
  139. but also stifles novel solutions.
  140.  
  141. This is why, when we speak in generalities, it does no good to say that
  142. either VMS or UNIX is `better'.  I know which one *I* prefer, but then
  143. I know the kinds of tasks I do and how I go about them.  I also know
  144. whether I prefer raspberry ice cream over peach, but I would not claim
  145. one is `better' and the other `loses'. :-)
  146. -- 
  147. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  148. Berkeley, CA        Domain:    torek@ee.lbl.gov
  149.