From: wgd@ukc.ac.uk (W.G.Day)
Newsgroups: comp.sys.transputer
Subject: Re: occam
Date: 14 Aug 92 14:48:49 GMT
Reply-To: wgd@ukc.ac.uk (Warren Day)
Organization: Computing Lab, The University, Canterbury, Kent. CT2 7NF, UK

In article <2490@news.cerf.net> jcbhrb@nic.cerf.net (Jacob Hirbawi) writes:

>Elegant tool for expressing parallelism? definitely.
>Elegant tool for expressing everything else? definitely not.

True, but parallelism is not the only thing it is good at expressing.

>The Occam syntax leaves a lot to be desired:

>(1) It is not free formatted; I thought the days of counting columns were over.

Column counting is, the formatting is done elegantly in occam.  One space is not
enough indentation visually, three is too much when one has lots of indenting.

Formatting a program in this way is good as one uses spacial relationships to indicate
the programs structure.  The must be some advantage to the fact that spacial
arrangements are processed by the right hand side of the brain, standard programming
logic by the left.

Formatting a language in this way is also good as one can use it to indicate
information to the compiler, which cuts out the need of lots of end, od, esac, }
and fi keywords.

>(2) I fail to see the advantage of having no operator hierarchy or default 
>    data types:

>    why write this:

>       (1.0 (REAL32) + (2.0 (REAL32) * 3.0 (REAL32))) - 4.0 (REAL32)

>    and count brackets when all I'm trying to do is:

>       1.0 + 2.0*3.0 - 4.0

My experience has lead me to do things like this,

  {{{ 1 + 2*3 - 4.0
  ( 1.0(REAL32)  +  (2.0(REAL32) * 3.0(REAL32)))  -  4.0(REAL32)
  }}}

One can add to readability by just adding a spaces (like before the 1) over just
leaving things in the most natural way (like before the 2).
The removing of the space between the zero and the open brackets bonds the
number and the type much better visually thus they read as the one object they are.

By the way, the occam compiler (the one here at any rate) constant folds the above
to 3.0(REAL32).

Occam's approach to typing like this is hard on the fingers and brain sometimes, but
it does make look at what you want the machine to do.  I once realised that although
the obvious way to do something was,

  REAL64 hello, there:
  INT world:
  ((REAL32 ROUND hello) * (REAL32 ROUND there)) + (REAL32 ROUND world)

it was faster to do,

  REAL32 ROUND (hello * there) + (REAL64 ROUND world)

although I think C gets it right in this case, it may not in general and in a
critical loop its nice to have full control.

No the above doesn't answer your point about the advantages, but others have,
here I have decided giving out experience and ideas is more advantageous.

>(3) Is it really elegant to write this:

>     IF
>       var1 < 1.0 (REAL32)
>         SEQ
>           var1 := 2.0 (REAL32)
>           var2 := 2.0 (REAL32)
>       TRUE
>         SKIP

>     instead of  If( var1 < 1.0 ) Seq{var1 = 2.0;var2 = 2.0;}

As others have said, yes.  The occam IF is very elegant in many ways.

Another way to write the above is,

  IF
    var1 < 1.0 (REAL32)
      var1, var2 := 2.0(REAL32), 2.0(REAL32)
    TRUE
      SKIP

Perhaps the multiple assignment isn't more readable, I don't think my personnel taste
prefers it, but its easier to type and were all lazy occasionally.

Jan's comment about wanting

TRUE
  STOP

as the default is a common one.  I wanted it too until I was told why.  I think
it was to catch and stop sloppy programming (not that any of us do that, all of
our programs are bug free aren't they:-).  There might be a case the programmer
has overlooked.

>> On a similar note the TDS, like every new and elegant code managing tool;
>> once one is fluent with it's workings, has its own continually growing set
>> of advantages over traditional editors.
  
>I think I'll complain about this one too :-)

>My objection is why?. Who needs a new editor?; I mean just how many 
>ways can you do a cut-and-paste operation!.

The important issue is that of abstraction.  Making a large thing managable by
humans.  Also as we get more experience at writing editors we get better at
making the c-n-p operations easier to use and more intuitive to the first time
user.

>I like to have more direct control over the files on my disk.

Yes, it needs to be better at actually deleting files.

>Jacob Hirbawi

Warren