anyone using haskell?
#1
Posted 17 October 2006 - 11:24 AM
I recently started learning the haskell programming language. It has support for the likes of opengl and win32 and all the necessary basics for developing graphical applicaitons. I was wondering if anyone has used haskell for anything significant over here. How was the experience, what are some obvious advantages (or disadvantages) you realized as opposed to application development in c/c++ or c# or whatever?
I'm loving this language so far. It's so... different then what I'm used to. They should really add this kind of stuff to computer science courses.
I wrote a blog post here with a whole buch of links to how I got started and various tutorials and all if anyone is interested.
So, comments?
- Me blog
#2
Posted 17 October 2006 - 03:52 PM
Regarding your blog and C# 3.0; I'm really looking forward for the lambda expressions (iirc). Seems quite useful to me.
#3
Posted 17 October 2006 - 06:31 PM
bladder said:
I don't know when/where you took computer science, but at my school functional programming has been a major part of the cirriculum (we haven't used Haskell, but LISP and ML for sure).
#4
Posted 17 October 2006 - 06:44 PM
I've been considering trying out Haskell as well. The closest I've come to functional programming has been with Lua, but its too easy to cheat. Haskell gives you no such option!
I still don't have a grasp on monads yet. Maybe then I'll give Haskell a shot.
Also, I never heard of functional languages while getting my electrical engineering degree. :(
#5
Posted 17 October 2006 - 07:16 PM
- Me blog
#6
Posted 17 October 2006 - 07:27 PM
#7
Posted 17 October 2006 - 09:31 PM
#8
Posted 17 October 2006 - 09:53 PM
Sure it can be helpful to have some functional concepts in a programming language, but forcing everything in that paradigm makes some simple things needlessly complicated. If you're a mathematician and you're only writing small applications, it can be great, but for anything really serious it quickly becomes a pain. The claims about needing less code are true, but you need just as long or longer to write it down...
I love C++ because it's multi-paradigm. For nearly every problem there's an elegant solution. This freedom brings its own complexity but once that's mastered I see little reason to look at other languages except for very specific situations. Like my professor used to say: "I'm teaching you Haskell and Prolog to make you better C++ programmers".
#10
Posted 19 October 2006 - 01:02 PM
Quote
Hmm, that's what I'm thinking so far. Though I can't really argue on this because of my lack of experience in the functional domain, but I'm looking into how true this actually is. I've heard a lot about erlang for server side development. There's an article here on devmaster actually: http://www.devmaster...scalable-server
Quote
Indeed, c++ really is a beauty in that regard. Though that's also one of it's biggest "pitfalls" in my opinions - a "full of adventure and surprise" pitfiall
- Me blog
#11
Posted 19 October 2006 - 02:47 PM
You'll be asthonised when you realize that you got a complete functional compiletime language built into your C++ compiler ;)
Doing work in haskell will enhance your ability to create complex template meta programs a great deal.
#12
Posted 19 October 2006 - 05:41 PM
Quote
That's a bit of an exageration
- Me blog
#13
Posted 21 October 2006 - 10:55 AM
bladder said:
Actually they do it just depends on which university and how good that university is.
monjardin said:
One of the most comprehensive resources on monads is All About Monads and Philip Wadler's papers (the guy who brought monads to haskell).
Nick said:
:blink: i have to say your comment is quite odd, this just sounds like an ill-informed and inexperienced opinion. Actually it's common for someone to say this who does not have much experience with recurision or just doesn't naturally think recursively. If you had any idea you would know it's quite the opposite.
if you're not familliar with the concepts of Accumulators, recursive operators (patterns of recursion such as Catamorphisms), and languages which foster writing recursive functions (in which with C++ this is not the case) then you do not really have a place to make such comments.
I suggest you read a book like Structure and Interpretation of Computer Programs to get a better understanding of the subject.
Nick said:
Exactly what are you basing your claims on? quite clearly this cannot be based on any comprehensive (personal) experience because of what you said above.
I can tell you for one thing there are many "serious" and significant applications which have and still are written in a number of functional programming languages so do not make assumptions and come out with rubbish like that.
Nick said:
:blink: Well now that just says it all doesn't it...
#14
Posted 21 October 2006 - 04:07 PM
Quote
I have to agree with snk_kid on this, i've been "learning" haskell for about a week now (spend more or less my entire day on it), and recursion is getting much more natural. At the beginning I was weirded out by the fact that there were no loops as well, but it turns out that it makes more sense without them. You'll have to spend a bit more time in a heskell like environment before things start to click.
- Me blog
#15
Posted 29 October 2006 - 06:17 PM
We use Haskell in university for an automated theorem proover tool, that we produce. For that kind of work functional is the only way to go. I think for things that are less heavy on the algorithmic side and involve more "library calling" I wouldn't want to use Haskell though.
As for the loops... One great thing about functional programming is that you can look at functions as idioms. So if you miss loops, just write a function that imitates a while loop and everything is fine. Of course Lisp with macros is even better that respect.
Comparing fucntional to oop I pondered about what concept is the more general for a while and which could be expressed better in the terms of the other. I think objects could be easily expressed in functional languages. In essence an objekt is a functional closure over the objects members, that can be passed a method name. Of course that wouldn't include inheritance but that's beside the point here.
A book I can reccomond on the topic is The Art Of The Meta Object Protocol, by Kiczales, Gregor, Jim des Rivieres, and Daniel G. Bobrow.
bladder :
from your blog :
"Haskell is a programming language, just like c++ or c# is... however, it is based on completely different concepts that are simply just different then what the average computer science student is used to."
Well... C# is moving into a direction where they integrate functional concepts pretty extensively. C# now has functional closeures and anonymous methods i.e. lambda expressions, which is half the way. C3.0 is going to add type inference and real lambda expressions to that which is really nice. I tend to like this approach, because it's good to make many programming paradigms available.
#16
Posted 30 October 2006 - 12:10 AM
snk_kid said:
Seriously, being limited to recursion is silly. For some really simple things in an imperative language it takes mind bending complexity to do it in a purely functional language. Don't forget that computers are imperative. When I'm writing C++, I already see the assembly code before me. With a functional language, there's absolutely no guarantee that what I see is what will be executed. Writing high performance functional applications, like games, is a nightmare.
Quote
Quote
Quote
Quote
Quote
Realizing the intrinsic limitations of functional languages is fundamental. They did not make a breakthrough on their own, nor will they ever. Multi-paradigm languages are far more popular, for good reason.
In the end, programming languages (and their compilers) are nothing more than tools to write assembly code. A 'perfect' language is worthless if it's not practical. Remember that.
#17
Posted 30 October 2006 - 05:56 PM
Quote
Wings3D
Yaws
For a couple years I thought that Erlang was the only practical FPL.
Lisp:
Yahoo's Online Shopping Cart
(in the late 90's, although I cannot speak to their current state on any given domain)
It's unlikely that these are the only examples, but these are the ones that I have seen the sourcecode for. You can hear of the woes of trying to explain how NASA's software is almost all FP from JPL and NASA engineers, but NASA doesn't want sourcecode released...ever. There are some scattered Erlang voice/data programs from NASA on the web. In the 80's, the British metropolitan phone systems were controlled by Ericsson (Erlang) phone routing software (some still is). I'm afraid I've long since forgotten the obscure names to the Traffic Control Software in Erlang that I've played with or the phone control software.
Quote
Quote
Ex:
I've tried it, and AJAX is silly. AJAX is XMLHttpRequest Object and what you can do with it...but it's not clever enough for PHBs, so they called it AJAX.
Quote
Quote
Hope you try out some FPL again and come back with some real problems that FP can't solve. It's been a long time since I've seen a serious FP challenge. Pwning CODERS with actual examples is a lot more fun than posturing, since you get taken more seriously. More importantly, try a more appropriate forum (like comp.lang.functional) for stating that FP is useless when people use it every day. It's obvious that very few people use it here and a great many don't even use C yet.
#18
Posted 31 October 2006 - 04:01 AM
Jack9 said:
Wings3D
Yaws
By the way, with high-performance I actually meant performance critical. I'd love to see an AAA game or something like a video codec in a functional language...
Quote
I tried a couple times to write a high-performance application in Haskell, but I just didn't get what I expected. It's just far less suited for number crunching. I'm aware that the compiler has a lot to do with it, but that's a worthless excuse in practice. It's also likely that I could have gotten higher performance if I rewrote some things differently, but if it requires a PhD in math to get a language to do exactly what I want then I don't want to bother with it. Sometimes it's even easier to just write the assembly code. At that point using these languages is not worth it.
This is a site about game development, and I just don't think functional languages are very useful there. But don't get me wrong, I still find them very interesting and I know they are useful for certain classes of applications. They just have their limitations. In a multi-paradigm language I get the best of both worlds and I'm not limited.
Quote
Quote
Quote
All I'm saying is that they can be limiting in practice for certain applications.
#19
Posted 31 October 2006 - 05:00 AM
Nick said:
I'd just like to point out that multi-paradigm languages often don't let you use functions as first-class values, like passing a function as parameter to another one, declaring a local function and returning it, and so on. This is one of the main features of functional languages and it can be very handy. In C++ you can emulate some of this with function pointers but it's nasty; as far as I know Java has no support for this sort of thing at all. However, the next version of C# is supposed to have lambda expressions, so we'll see how that goes.
Quote
I find certain algorithms easier to think about in recursive terms. For instance, binary tree operations like searching and inserting, quicksort, recursive descent parsing of grammars, and so forth are easier to think about and more elegant in a recursive framework. Sure, in C++ we can write these recursively if we want to. But we don't want to, because recursion is inefficient, so we rewrite them iteratively and they become harder to understand. In a functional language we can write them recursively, and if we make them tail-recursive they are almost as efficient as an imperative, iterative implementation. (As far as I know, no C++ or Java compiler optimizes tail recursion, but correct me if I'm wrong.)
Additionally, I find recursive reasoning generally easier to follow than iterative reasoning. Both are essentially equivalent, but I find the idea of a base case and then a recursive case that reduces the problem to a simpler one easier to think about than a loop invariant with initialization, maintenance, and termination arguments. If I'm trying to convince myself that something I've written is correct, it's better if it's recursive. This wasn't always the case. When I first encountered functional languages as a first year university student, I would have agreed with you that recursion was more complicated than a loop. It took some time before I learned how to think about recursion, but now it seems just as natural as a loop to me.
Of course, everything I'm saying here just applies to me and not necessarily to anyone else. If you don't like recursion, that's fine; but I hope you can see how people can have different perspectives on the matter.
Quote
Could you give an example? I think it would help the discussion if we had something concrete to point to rather than speaking in generalities all the time.
Quote
Realistically, I'm inclined to agree. But that doesn't mean we can't discuss them.
#20
Posted 31 October 2006 - 01:36 PM
Next, functional programs depend mainly on compiler. Compilers do most of the job. However they STILL rely on us, else we wouldn't have programmers :) This means, he has to "guess" what we wanted to accomplish, thus never really knowing the task at hand. On the other hand, if we use imperative languages, we can easily translate it with our minds directly in an "execution" oriented thing, i.e we know almost anything about the result -- thus we can write better code in this respect.
Math-lovers (this does not mean math-logic, but rather math-language): use functional languages
Logic-lovers (sorry if "logic" is not the correct term, I'm not native english): use imperative languages
ps: by "logic" I mean.. well example:
1) Aha, it computes 5+1
2) then is sees if it's > 5
3) then it jumps somewhere
4) then, based on that new variable, adds 1
5) then....
again sorry if logic is not an appropiate term.
In my opinion (just my opinion, please don't offense), math-language (not logic, just language) sucks! A good example that requires a "special" symbol in math is "Sigma" (for sums, you know).. it represents a loop.. it needs that, because it doesn't want to process it as loops. Math-language sucks. It's too :wacko:
Other funny things in math: if and only if, instead of plain if, etc..
math-logic is same for both imperative and functional languages, however imperative extend this (logic operators, weird tricks, etc). Math is abstract, I know, but the language in my opinion is :wacko:.. too confusing
please do not regard this as an offense. it was only my opinion
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












