<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">I wrote a very simple program to check whether Haskell improved its array processing libraries or not. Here is how to compile and run the program arr.hs in Haskell (I have used the GHC compiler):<br><br>>ghc -O arr.hs -o arr.exe<br><br>$ time arr.exe +RTS -K32000000<br>2.8e8<br><br>real 0m3.938s<br>user 0m0.031s<br>sys 0m0.000s<br><br>The same program in Clean:<br>C:\Clean 2.2\exemplos\console>arraytest.exe<br>280000000<br>Execution: 0.01 Garbage collection: 0.01 Total: 0.03<br><br>C:\Clean 2.2\exemplos\console>arraytest.exe<br>280000000<br>Execution: 0.01 Garbage collection: 0.01 Total: 0.03<br><br>This means that Clean is 390 times faster than Haskell in this particular problem. These results makes me worder whether Haskell is safer than Clean. It turns out that
Haskell checks index out of range at runtime, exactly like Clean. Larger problems make the difference between Clean and Haskell even worse. For instance, neural networks like the one described in Schmidtt et al. run 400 times faster in Clean.<br><br>Haskell seems to be slow, and not safe. For instance, GHC compiler does not at a program trying to write into a closed handle. <br><br>module Main where<br> import System( getArgs )<br> import IO<br><br> main = do <br> args <- getArgs<br> if (length args /= 2)<br> then putStr "Usage: f1a f2a <n>"<br> else (do<br> fromHandle <- openFile (head args)
ReadMode<br> contents <- hGetContents fromHandle<br> toHandle <- openFile (head (tail args)) WriteMode<br> hClose toHandle -- Comment this line<br> hPutStr toHandle contents<br> hClose toHandle<br> putStr "Done.")<br><br>The Clean equivalent program is somewhat smaller. In my opinion it is easier to understand. What is more important, Clean compiler balks at closed handles.<br><br>module cleancopy<br>import StdEnv, ArgEnv<br><br>Start w<br> # argv=
getCommandLine<br> | size argv < 3 = abort "Usage, etc." <br> # (ok, f, w)= fopen argv.[1] FReadText w<br> (contents, f)= freads f 64000<br> (ok, f, w)= fopen argv.[2] FWriteText w<br> f= fwrites contents f<br> = fclose f w<br><br>Below you will find the array examples. You can check that Clean is really much faster than Haskell. I wonder why the Benchmarks Game site does not report such a large difference between Haskell and Clean performances. I believe that people who wrote Haskell benchmarks for the Benchmarks Game site cheated in using foreign pointers to access arrays.<br><br>-- arr.hs<br>import Control.Monad.ST<br>import Data.Array.ST<br>main = print $ runST<br> (do arr <- newArray (1,2000000)
<br> 137.0 :: ST s <br> (STArray s <br> Int Double)<br> a <- readArray arr 1<br> b <- readArray arr 1<br> fn 2000000 arr 0.0 )<br><br><br>fn i a acc | i < 1 = do (return acc)
<br>fn i a acc= do <br> b <- readArray a i<br> writeArray a i (b+3.0)<br> c <- readArray a i<br> fn (i-1) a (acc+c)<br><br>//Clean version<br>module arraytest<br>import StdEnv<br>fn i a acc | i<1 = acc<br>fn i a=:{[i]=b} acc<br> # a= {a&[i]= b+3.0}<br> # (c, a)= a![i]<br> = fn (i-1) a (c+acc)<br> <br>Start= fn 2000000 vt 0.0<br>where<br> vt:: .{#Real}<br> vt = createArray 2000001 137.0<br><br><br><br>--- On <b>Mon, 10/12/09, rinus plasmeijer <i><rinus@cs.ru.nl></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: rinus plasmeijer
<rinus@cs.ru.nl><br>Subject: [clean-list] Re: Clean<br>To: "Henrique" <henrique_gusmao_@hotmail.com><br>Cc: clean-list@science.ru.nl<br>Received: Monday, October 12, 2009, 1:22 AM<br><br><div id="yiv1742543503">
<style></style>
<div><font size="2" face="Arial">
<div dir="ltr">Hi Henrique<br></div>
<div dir="ltr"> </div>
<div dir="ltr">> Is this e-mail still working? <font size="2" face="Arial"><a rel="nofollow" target="_blank" href="http://clean.cs.ru.nl/">http://clean.cs.ru.nl/</a></font></div>
<div dir="ltr"> </div>
<div dir="ltr"> </div>
<div dir="ltr">Yes.</div></font></div>
<div><font size="2" face="Arial">
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">>I want to know more about Clean: news?
updates?</font></div>
<div><font size="2" face="Arial">> What is the future of Clean?</font></div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">See: <a rel="nofollow" target="_blank" href="http://wiki.clean.cs.ru.nl/Latest_developments">http://wiki.clean.cs.ru.nl/Latest_developments</a></font></div>
<div><font size="2" face="Arial">We are working on a new version which allows you to
mix Clean and Haskell 98 code.</font></div>
<div>It is a lot of work, it will still take some time. </div>
<div><font size="2" face="Arial"></font> </div>
<div><font size="2" face="Arial">> Is Haskell killing Clean? </font></div>
<div><font size="2" face="Arial">Haskell is certainly much more used, which is also
the raison for adding a Haskell front end.<br></font><br>> I would like to
learn and test Clean, and maybe then use it commercially. <br>> Where do I
can download it? I send e-mail to <a rel="nofollow">clean@cs.ru.nl</a> , asked for
Clean at the site above, but I got no answer.<br><br>We did not got your
email.</div>
<div>To download browse to: <a rel="nofollow" target="_blank" href="http://clean.cs.ru.nl/Download/main/main.htm">http://clean.cs.ru.nl/Download/main/main.htm</a></div>
<div> </div>
<div>> Obs: I am using windows platform. </div>
<div>Thats fine, it should work on any windows platform.</div>
<div> </div>
<div><br>Greetings,</div>
<div> </div>
<div>Rinus</div>
<div> </div></font></div></div><br>-----Inline Attachment Follows-----<br><br><div class="plainMail">_______________________________________________<br>clean-list mailing list<br><a ymailto="mailto:clean-list@science.ru.nl" href="/mc/compose?to=clean-list@science.ru.nl">clean-list@science.ru.nl</a><br><a href="http://mailman.science.ru.nl/mailman/listinfo/clean-list" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/clean-list</a><br></div></blockquote></td></tr></table><br>
<hr size=1>The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! <a href="http://downloads.yahoo.com/ca/internetexplorer/"><b>Get it Now for Free!</b></a>