home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / transput / 930 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  7.8 KB

  1. Path: sparky!uunet!mcsun!uknet!uos-ee!ee.surrey.ac.uk!R.Peel
  2. From: R.Peel@ee.surrey.ac.uk (Roger Peel)
  3. Newsgroups: comp.sys.transputer
  4. Subject: Why should you consider using occam?
  5. Message-ID: <1992Aug14.155639.1045@EE.Surrey.Ac.UK>
  6. Date: 14 Aug 92 15:56:39 GMT
  7. Sender: ees1rp@ee.surrey.ac.uk (Roger Peel)
  8. Organization: University of Surrey, U.K.
  9. Lines: 125
  10.  
  11.  
  12. A recent item asked whether anyone still used occam to program
  13. transputers.  My response is a definite YES!  Perhaps I should also retort
  14. by asking why anyone should wish to program these exciting processors in
  15. an insecure sequential language such as C - but I am not that brave.
  16.  
  17. I have programmed in occam for 7 or 8 years now, and have no plans to
  18. switch.  Apart from personal use, I teach it as a vehicle for parallel
  19. programming, and I supervise many project students (from undergraduate to
  20. research levels) who use occam, typically, to control transputer-based
  21. hardware.  In appropriate circumstances, of course, I also use a number of
  22. other languages.  I suggest that my occam program design experience, in
  23. particular, has made me a better sequential programmer.  Why?
  24.  
  25. Occam is a small(ish) language with well-defined semantics.  It
  26. incorporates many features not found in other mainstream languages,
  27. especially its built-in timer.  Being a fully-typed language, the compiler
  28. checks that expressions are consistent (like many other modern languages -
  29. but not C).  The need for explicit type conversion is irritating at times,
  30. but is catching on elsewhere because it allows one to reason about how
  31. expressions are evaluated without having to memorise complicated automatic
  32. coercion rules.  Remember that addition and multiplication are not
  33. strictly associative or commutative if their results are only finite-width
  34. binary words.  In occam, functions are guaranteed to have no side-effects,
  35. and therefore (for any set of operands) will ALWAYS return the same
  36. result.
  37.  
  38. OK - so much for sequential safety features.  But what makes occam unique
  39. is that the concept of proper support for multiple parallel processes and
  40. inter-process communication is built in, and is very easily accessible by
  41. the programmer.  For any task which involves real-time activity, I/O
  42. buffering, interfacing with peripheral devices or just plain parallel
  43. processing, this is really profitable.  It means that we can keep the
  44. separate elements of our task apart - with processes which supervise the
  45. slow peripherals, FIFO buffers to keep them fed, and processes for the
  46. separate computational activities which drive them.  A big fuss is being
  47. made about object-oriented methods these days, but message-passing
  48. parallelism is an even more powerful concept - not only cannot processes
  49. interfere with each other unless invited to communicate, but they can also
  50. run in parallel on appropriate hardware!  All this is achieved by the
  51. strict type-checking of what is communicated along the channels between
  52. processes, as well as stored within.  Hence any message-passing parallel
  53. language without an equivalent of the occam channel PROTOCOLs does not
  54. provide this necessary security.
  55.  
  56. So why is occam not liked by so many programmers?  Well, some write
  57. sequential code for which occam only provides a few extra benefits.  Fine
  58. - they can justifiably continue to use a sequential language provided they
  59. only attempt to run their code on a single transputer.  Parallel
  60. enhancements to a sequential language might be acceptable for particularly
  61. large-grained parallel tasks, too, but this is not where occam stands out,
  62. either.  Some objectors - rightly - object to occam's lack of standard
  63. facilities such as structures or records (although these will become
  64. available in occam 3).  Others may be worried that they will suffer
  65. withdrawal symptoms if they are unable to use untyped pointers.  A few
  66. maybe even enjoy wasting time wading between breakpoints inside a
  67. debugger, rather than picking up their mis-conceptions and typos in a
  68. compiler.  Instead, I prefer the world of dozens of lightweight parallel
  69. processes, buffers, multiplexers, FIFOs, PROTOCOLs, ALTs and a simple,
  70. clean syntax to describe them.  But I suggest that the majority of
  71. objectors have not been able to re-organise their thought processes
  72. sufficiently to see how to exploit the novel features occam provides, and
  73. in particular they do not see the need for fine-grained parallelism and
  74. data management.  Many are still struggling to manage their real-time task
  75. using polling inside their main program loop, with semaphores, shared
  76. memory buffers and interrupts for added entertainment.
  77.  
  78. So how should one learn about occam?  My experience is that it only takes
  79. about 4 hours to teach the whole of the occam _syntax_ to competent Pascal
  80. or C programmers, so an evening reading the Occam Reference Manual is a
  81. good start.  However, just this is likely to create the doubters who
  82. voiced the original question.  It is then necessary to spend a couple of
  83. days looking at the applications side of the language - the occam idioms -
  84. with an experienced occamist.  Sequential programming courses have their
  85. sorting, searching, pointer manipulation and data organisation elements,
  86. and one should not expect to understand occam until aspects of buffering,
  87. real-time response, deadlock and so on have been clearly demonstrated.
  88. Many such courses are available, perhaps especially in the U.K.  Even
  89. better, go to a technical meeting or workshop run by NATUG, WoTUG or your
  90. own national transputer user group, and take the opportunity to talk with
  91. the tutors, speakers and delegates about their occam experiences.
  92.  
  93. And what of the future of occam?   Occam 3 will provide more of the
  94. facilities which are found in the larger sequential languages, but
  95. provided in a secure, type-checked fashion.  More importantly, it will
  96. include a sophisticated scheme for modularising programs, enabling very
  97. large occam programs to be created by teams of programmers in a controlled
  98. fashion.  Think of this as the provision of library modules which can call
  99. the user's program as well as be called by other programs (and remember
  100. that this has to work in a parallel environment) and you will get a feel
  101. for the ideas in the pipeline.  Occam 3 will also have new facilities for
  102. shared channels, which not only maps onto the new fast ALT mechanism
  103. provided by the T9000, but also means that a process can monitor such a
  104. channel without having to know how many processes may send messages along
  105. it, which will make such processes more general-purpose and easier to
  106. design for re-use in a module.
  107.  
  108. It would be nice to see future occam compilers which generate code to run
  109. on processors other than the transputer.  I would love to be able to
  110. program DSP chips or single-chip microprocessors in occam, rather than in
  111. C or assembler.  In order to facilitate this, WoTUG (with considerable
  112. support from INMOS) will be running an Occam Re-targeting Workshop at the
  113. University of Kent, England, on 15th-16th September 1992.  This will
  114. provide a complete insight into the occam compiler front-end which is
  115. available from INMOS and provides a framework for code generation onto the
  116. processor of your choice.  There will, of course, be the opportunity to
  117. discuss a joint strategy for such re-targeting exercises.
  118.  
  119. Immediately before the Occam Workshop, on 14th-15th September, WoTUG will
  120. be running a T9000 Systems Workshop in which yet more INMOS staff will be
  121. presenting a comprehensive guide to how best to utilise the new facilities
  122. found on the T9000.
  123.  
  124. For details of both workshops, contact : Judith Farmer, Computing
  125. Laboratory, University of Kent, CANTERBURY, Kent  CT2 7NF, U.K., or email
  126. jcf@ukc.ac.uk.
  127.  
  128.  
  129. Roger M.A. Peel
  130. Department of Electronic and     Phone : +44 483 509284   (0483 from UK)
  131.       Electrical Engineering       Fax : +44 483 34139
  132. University of Surrey             Telex : 859331
  133. Guildford                        JANET : R.Peel@uk.ac.surrey.ee
  134. Surrey  GU2 5XH                   UUCP : ...mcsun!ukc!ee.surrey.ac.uk!R.Peel
  135. United Kingdom
  136.