[mercury-users] Mercury as a 1st class prototyping language ?

Richard A. O'Keefe ok at atlas.otago.ac.nz
Thu Oct 26 09:16:43 AEDT 2000


It is quite possible to have brevity, safety, and efficiency.

I've been looking at the STL in C++ lately; several books (including
one by Kernighan and Pike) praised it, so I decided to try their
examples, thinking that C++ compilers might have improved their
STL handling dramatically since my (1996? 1997?) benchmarks where
Scheme was outperforming C++.  Well, they haven't.  I'm getting
a factor of 5 or worse for C++/STL raced against simple clean C.
The efficiency of the STL is largely a myth.

I'm getting *better* ratios for Haskell vs C (using recent versions
of ghc and hbc), and of course extremely good ratios for Clean vs C.

What has that to do with Mercury?
Mercury and Clean have very similar type systems, and Haskell's is not
so very different.  Clean and Haskell code can be very concise, and of
course you don't have to write down any types even though they are
strictly typed.

Actually, you do have to write down the types of exported functions in
Clean, twice (once in the interface and again in the implementation).
But there's a neat hack:  write the code without exporting any functions,
run it through the compiler with the "-lat" (List All Types) option, and
paste the output back in.

There are two problems in Mercury.  One is modes.  Given the distinction
betweeen "in" and "di", which is important for *design*, no compiler is
ever going to infer everything you might want.  The other is the syntax.
Haskellish syntax really gets more done with less typing than anything
I've used except APL.  Adroit use of operators helps.

But the real strength of a prototyping language is not what the code
you do write looks like, but how much code you don't have to write at all.
An *intelligent* lazy programmer doesn't mind writing 200 lines of type
and 500 lines of mode declarations if it will enable her to avoid writing
10 000 lines of code.  (A really clever programmer, like me, will happily
spend an hour writing declarations if that will save two hours of debugging.)
Any effort spent improving Mercury's suitability as a prototyping language
should go on extending the coverage of the library, not tinkering with
syntax.

--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list