Berlin, you have some interesting projects...

0 views
Skip to first unread message

joe

unread,
Jul 27, 2008, 5:27:37 PM7/27/08
to Metro Atlanta Erlang Users Group
I have to admit that I know almost nothing about Haskell. I pained
over what kind of lisp/scheme to spend time learning, but dislike the
fragmented nature of that community. What can you tell me about
Haskell from a development standpoint?

Regards,

-joe

Berlin Brown

unread,
Jul 28, 2008, 12:14:04 PM7/28/08
to Metro Atlanta Erlang Users Group
I spent about 6 months on a personal project that I wanted to use
Haskell for. It was interesting. There are two things that took
getting used to with Haskell; the "strong" static typed nature and the
complexity of the syntax.

On the strong typing; if you have a function that takes an argument
string, that code better pass a string to the function or it won't
compile. If it is a ByteString or similar form of string, no dice.
ByteString arguments need a ByteString value. In Java you can skate
around this with no type safety what so ever not with Haskell.

func(Object abc) { }

There are a billion documents on how this reduces bugs, side effects,
etc, etc. I think that is an accurate statement. You spend a little
bit less time dealing with runtime bugs, but on the other side of the
coin you have to deal with Haskell's rigid compile-time restrictions
so there is an equal trade-off.

E.g. if I come back to some Python code I haven't worked with in a
year, looking at one piece of code I might know what object is being
passed to a function so I don't know if the code will work properly or
not. With haskell's type system, you are guranteed that the proper
types are passed to functions.

Haskell is a functional programming language on steroids; if you have
worked with Lisp for example, you can by pass a lot of the functional
aspects of the language and code like you would a procedural
language. I was commenting to someone that sometimes I can write Lisp
code like I would Python code. With Haskell, that isn't the case; it
makes your code a lot cleaner to use a functional language style
coding.

My only main complaint with the language was with the syntax; there
are many constructs, best practices to remember just to write a simple
application. But, I guess after you have learned all of that, you can
become a powerful Haskell programmer. Take lisp and s-expressions for
example, there isn't really that is simpler than Lisp. Left and Right
parens, lists as code, etc. Erlang is not too much more complicated
than Lisp either. Haskell is way on the other side of the fence.

Here is a one-liner factorial implementation in Haskell. Just looking
at, there are several different tokens and may not come as readable.

fac n = (foldl (.) id [\x -> x*k | k <- [1..n]]) 1

In Summary:

Pros:
1. Static typing, reduces side effects, bugs
2. Good community and set of modern standard libraries
3. Good documentation (see 2).
4. Ability to use advanced programming techniques. Haskell is a
pretty powerful functional programming language and allows you write
code that does more with less. But you have to learn the language.

Cons:
1. Complicated syntax (Lisp/Erlang are simple. Haskell is not).
2.
3. Lazy evaluation - I am not an expert on this issue but it did cause
me heartache. Essentially, your code is not executed until it is
needed as opposed to when it is called. If you are working with
something complicated like networking or database code, you expect a
piece of code to get called whether you need it or not. Haskell lazy
eval makes it harder to debug your application because you don't know
exactly when a block of code is evaluated.
Reply all
Reply to author
Forward
0 new messages