lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thursday 11 November 2004 21:37, Matt Hellige wrote:
[...]
> For a much more rigorous (and quite beautiful, although challenging)
> attempt to enforce a purely functional style, take a look at Haskell.
> Be aware, though, that it's designers titled a relatively recent talk
> "Wearing the Hair Shirt: a Haskell Retrospective," so it's not all
> roses in purity-land... ;)

My university was very keen on theory, and they taught us Haskell.

It's a beautiful language. It's simple, and subtle, and very elegant, and 
allows you do all kinds of interesting things with computer programs except, 
unfortunately, writing useful ones in a reasonable amount of time.

For those of you who don't know Haskell: it's a functional language quite 
similar to ML, and its main claim to fame is that no functions have side 
effects. *Ever.* This includes I/O. If you call a function with a particular 
set of parameters, you know that it will return the same result every time. 
*Always.* This provides a number of benefits, including the ability to do 
lazy evaluation: it now no longer matters when functions are actually 
executed, so the interpreter only executes them when it absolutely has to.

When trying to write useful programs in Haskell, the biggest stumbling block 
is I/O. What you actually write is a function that takes as an argument a 
stream of I/O events and returns a new stream of I/O events. Your function 
lazily pulls events off the input stream, and the run-time lazily pull events 
off the output stream. The result works but is, from the imperative 
programmer's point of view, a ghastly mess: you end up having to pass I/O 
streams about all over the place. Adding a simple printf statement in the 
depths of your logic code can require you to rearrange the parameters for a 
hundred different functions. There's syntactic sugar to make this easier, but 
it's still a pain.

If you want more information, look here:

 http://www.haskell.org/tutorial/io.html

-- 
+- David Given --McQ-+ 
|  dg@cowlark.com    | "The further you are from your server, the more
| (dg@tao-group.com) | likely it is to crash." --- Woodhead's law
+- www.cowlark.com --+