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 <[email protected]> wrote:
From: rinus plasmeijer <[email protected]>
Subject: [clean-list] Re: Clean
To: "Henrique" <[email protected]>
Cc: [email protected]
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?
See: http://wiki.clean.cs.ru.nl/Latest_developments
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 [email protected] , asked for
Clean at the site above, but I got no answer.
We did not got your
email.
To download browse to: http://clean.cs.ru.nl/Download/main/main.htm
> Obs: I am using windows platform.
Thats fine, it should work on any windows platform.
Greetings,
Rinus
-----Inline Attachment Follows-----
_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list
__________________________________________________________________
Looking for the perfect gift? Give the gift of Flickr!
http://www.flickr.com/gift/_______________________________________________
clean-list mailing list
[email protected]
http://mailman.science.ru.nl/mailman/listinfo/clean-list