Re: Clean

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: Clean

by rinus plasmeijer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi Henrique
 
> Is this e-mail still working? http://clean.cs.ru.nl/
 
 
Yes.
 
>I want to know more about Clean: news? updates?
> What is the future of Clean?
 
We are working on a new version which allows you to mix Clean and Haskell 98 code.
It is a lot of work, it will still take some time.
 
> Is Haskell killing Clean?
Haskell is certainly much more used, which is also the raison for adding a Haskell front end.

> I would like to learn and test Clean, and maybe then use it commercially.
> Where do I can download it? I send e-mail to clean@... , asked for Clean at the site above, but I got no answer.

We did not got your email.
 
> Obs: I am using windows platform.
Thats fine, it should work on any windows platform.
 

Greetings,
 
Rinus
 

_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Re: Re: Clean versus Haskell

by Philippos Apolinarius :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi, Henrique.
I couldn't resist adding a few comments. Clean is much better than Haskell, in the following senses:

(i) It generates faster code, smaller exec files, and uses less memory. The compiler is also much smaller than GHC. Clean has even more features than Haskell, but occupies less space in your hard disk.
    (a) Distribution: GHC 6.10.4 --- 52M versus Clean 2.2 --- 14 M.
    (b) Fibonacci compiled code (below): GHC  --- 1M versus Clean 2.2 --- 57 K
    (c) Fibonacci time (fib 40): GHC --- 7.422 s versus Clean 2.2 --- 1.7s
    (d) Schmidtt's Neural net: GHC --- 12.8 s versus Clean 2.2 --- 0.37 s

(ii) Clean has efficient array processing, as you can see from the example of Neural Network. Clean takes less than 0.1s to train and run the neural network in my machine.  I won't tell you how long Haskell takes, because you will not believe me. A hint: Haskell takes much, much longer.

(ii) Clean is safer, since it does not allow things like trying to write into a closed file.

Well, Henrique, I would be very happy if I had an option  in functional programming. Competition is good. However, it seems that Clean is alone in the arena. I wrote many letters to the Haskell community, requesting smaller exec files, and better array processing. This is necessary to make Haskell a realy good tool.

By the way, the Neural Network example comes from a paper by Peter Schmidtt et al.

//Fibonacci in Clean
module fibo
import StdEnv, ArgEnv

fib n | n  < 2    = 1
      | otherwise = fib (n-1) + fib (n-2)

Start= fib (toInt argv.[1])
where
   argv= getCommandLine

-- Fibonacci in Haskell
module Main( main ) where
 import System( getArgs )


 fib n | n  < 2    = 1
       | otherwise = fib (n-1) + fib (n-2)

 -- Function f_print  prints the n'th Fibonacci number
 f_print n = print(show n ++ "th Fibonacci number is " ++ show (fib n))

 -- Function main is the entry point of the program
 main = do
    args <- getArgs
    if (length args /= 1)
        then putStr "Usage: f1a <n>"
        else (f_print (read (head args)))
    putStr "\n"


// Neural network in Clean
module arrays
import StdEnv

sig x = 1.0 / (1.0 + (exp (~ x)))

error vt = loop vt 0 0.0
where
    loop vt i acc | i>= size vt = (acc, vt)
    loop vt i acc
      # (e, ww) = vt![i]
      = loop ww (i+1) (acc+e)

na vt=:{[4]=x, [5]=y, [6]=z} [i1, i2]=
  (sig (x+y*i1+z*i2), vt)

ns vt [i1, i2, i3]
  # (v0, vt)= vt![0]
  # (v1, vt)= vt![1]
  # (v2, vt)= vt![2]
  # (v3, vt)= vt![3]
  = (sig(v0+i1*v1+i2*v2+i3*v3), vt)
 
gate vt [i1, i2]
    # (n1, vt)= na vt [i1, i2]
    # (n2, vt)= ns vt [i1, n1, i2]
    = (n2, vt)
 
errSum v2 [] acc= (acc, v2)
errSum v2 [ex:s] acc
   # v= hd ex
   # (vc, v3)= gate v2 (tl ex)
   = errSum v3 s (acc+(vc-v)*(vc-v))
  
updweight vt nvt err0 ns exs = loop 0 vt nvt
where
   dx = 0.01
   mu = 0.5
   loop i vt vs | i > ns = (vs, vt)
   loop i vt vs
     # (v, v1) = vt![i]
     # v2 = {v1 & [i]= v+dx}
     # (nerr, v3)= errSum v2 exs 0.0
     # nv= v + mu*(err0 - nerr)/dx
     = loop (i+1) {v3& [i]=v} {vs & [i]=nv}

train exs = loop v1 v2
where
    v1 :: .{#Real}
    v1 = {0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0}
    v2 :: .{#Real}
    v2 = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
    loop vt nvt
      # (nerr, vt) = errSum vt exs 0.0
      | nerr < 0.01 =vt
      # (vt, nvt)= updweight vt nvt nerr 6 exs
      = loop vt nvt
 
Start = xor 0.0 0.0 // (xor 0.0 0.0, xor 0.0 1.0, xor 1.0 0.0, xor 1.0 1.0)
where
    vt :: .{#Real}
    vt = train exs
    exs = [eg e\\ e <- [0,1,2,3,3,2,1,0]]
    xor i1 i2= fst(gate vt [i1,i2])
   
eg 0 =  [0.0, 1.0, 1.0]
eg 1 = [1.0, 1.0, 0.0]
eg 2 = [1.0, 0.0, 1.0]
eg 3 = [0.0, 0.0, 0.0]


--- On Mon, 10/12/09, rinus plasmeijer <rinus@...> wrote:

From: rinus plasmeijer <rinus@...>
Subject: [clean-list] Re: Clean
To: "Henrique" <henrique_gusmao_@...>
Cc: clean-list@...
Received: Monday, October 12, 2009, 1:22 AM

Hi Henrique
 
> Is this e-mail still working? http://clean.cs.ru.nl/
 
 
Yes.
 
>I want to know more about Clean: news? updates?
> What is the future of Clean?
 
We are working on a new version which allows you to mix Clean and Haskell 98 code.
It is a lot of work, it will still take some time.
 
> Is Haskell killing Clean?
Haskell is certainly much more used, which is also the raison for adding a Haskell front end.

> I would like to learn and test Clean, and maybe then use it commercially.
> Where do I can download it? I send e-mail to clean@... , asked for Clean at the site above, but I got no answer.

We did not got your email.
 
> Obs: I am using windows platform.
Thats fine, it should work on any windows platform.
 

Greetings,
 
Rinus
 

-----Inline Attachment Follows-----

_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list


All new Yahoo! Mail - Get a sneak peak at messages with a handy reading pane.
_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Clean versus Haskell

by Philippos Apolinarius :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
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):

>ghc -O arr.hs -o arr.exe

$ time arr.exe +RTS -K32000000
2.8e8

real    0m3.938s
user    0m0.031s
sys     0m0.000s

The same program in Clean:
C:\Clean 2.2\exemplos\console>arraytest.exe
280000000
Execution: 0.01  Garbage collection: 0.01  Total: 0.03

C:\Clean 2.2\exemplos\console>arraytest.exe
280000000
Execution: 0.01  Garbage collection: 0.01  Total: 0.03

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.

Haskell seems to be slow, and not safe. For instance, GHC compiler does not at a program trying to write into a closed handle.

module Main where
 import System( getArgs )
 import IO

 main = do
          args <- getArgs
          if (length args /= 2)
        then putStr "Usage: f1a f2a <n>"
            else (do
              fromHandle <- openFile (head args)  ReadMode
              contents   <- hGetContents fromHandle
              toHandle <- openFile (head (tail args)) WriteMode
              hClose toHandle  -- Comment this line
              hPutStr toHandle contents
              hClose toHandle
              putStr "Done.")

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.

module cleancopy
import StdEnv, ArgEnv

Start w
  # argv= getCommandLine
  | size argv < 3 = abort "Usage, etc."
  # (ok, f, w)= fopen argv.[1] FReadText w
      (contents, f)= freads f 64000
      (ok, f, w)= fopen argv.[2] FWriteText w
      f= fwrites contents f
  = fclose f w

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.

-- arr.hs
import Control.Monad.ST
import Data.Array.ST
main = print $ runST
          (do arr <- newArray (1,2000000)
                        137.0 :: ST s
                                  (STArray s
                                    Int Double)
              a <- readArray arr 1
              b <- readArray arr 1
              fn 2000000 arr 0.0 )


fn i a acc | i < 1 = do (return acc)
fn i a acc= do
             b <- readArray a i
             writeArray a i (b+3.0)
             c <- readArray a i
             fn (i-1) a (acc+c)

//Clean version
module arraytest
import StdEnv
fn i a acc | i<1 = acc
fn i a=:{[i]=b} acc
  # a= {a&[i]= b+3.0}
  # (c, a)= a![i]
  = fn (i-1) a (c+acc)
 
Start= fn 2000000 vt 0.0
where
   vt:: .{#Real}
   vt = createArray 2000001 137.0



--- On Mon, 10/12/09, rinus plasmeijer <rinus@...> wrote:

From: rinus plasmeijer <rinus@...>
Subject: [clean-list] Re: Clean
To: "Henrique" <henrique_gusmao_@...>
Cc: clean-list@...
Received: Monday, October 12, 2009, 1:22 AM

Hi Henrique
 
> Is this e-mail still working? http://clean.cs.ru.nl/
 
 
Yes.
 
>I want to know more about Clean: news? updates?
> What is the future of Clean?
 
We are working on a new version which allows you to mix Clean and Haskell 98 code.
It is a lot of work, it will still take some time.
 
> Is Haskell killing Clean?
Haskell is certainly much more used, which is also the raison for adding a Haskell front end.

> I would like to learn and test Clean, and maybe then use it commercially.
> Where do I can download it? I send e-mail to clean@... , asked for Clean at the site above, but I got no answer.

We did not got your email.
 
> Obs: I am using windows platform.
Thats fine, it should work on any windows platform.
 

Greetings,
 
Rinus
 

-----Inline Attachment Follows-----

_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list


The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free!
_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list

Re: Clean versus Haskell

by Isaac Gouy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--- On Mon, 10/12/09, Philippos Apolinarius <phi500ac@...> wrote:

-snip-
> I wonder why the
> Benchmarks Game site does not report such a large difference
> between Haskell and Clean performances.

"The Benchmarks Game site does not report such a large difference between Haskell and Clean performances" because the benchmarks game measurements don't show such a large difference -

http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=clean&lang2=ghc&box=1

(Note there seems to be something wrong with the Clean reverse-complement program, preventing it processing the larger input file.)


> I believe that
> people who wrote Haskell benchmarks for the Benchmarks Game
> site cheated in using foreign pointers to access arrays.
-snip-

I believe the people who wrote Haskell benchmarks for the Benchmarks Game site made use of everything Haskell provides, just as they made use of all the processors on the quad core machine -

http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=clean&lang2=ghc&box=1



     
_______________________________________________
clean-list mailing list
clean-list@...
http://mailman.science.ru.nl/mailman/listinfo/clean-list