开发者

How much time have you invested in order to have a good grasp on Haskell?

I know this question may sound silly, but I am learning (at least trying) Haskell for about 4 days. I've already finished to read http://learnyouahaskell.com/, and now I am investing time in: The Haskell Road to Logic, Math and Programming, and th开发者_如何学编程ings got really complicated for me. I don't have experience in functional programming, just some basic knowledge on Lisp.

Even though I understand the concepts, when I have to write a not so basic piece of code, there's a total darkness and I cannot build a plan in my head. It seems that there are a lot of ways to accomplish a certain task, but I cannot express myself.

After 4 days of python, I could've write complex scripts (not 'pythonic', but they did work). After 4 days in haskell, I am ... almost blank.

Any suggestions on how to improve my functional skills ? How long did it take for you to fully grasp Haskell ?


After about 2 years there are some parts of Haskell I know very well (Ptr stuff, vector libraries), some areas I know just enough to be dangerous (template haskell), and others I haven't touched (web frameworks, generics). Overall, though, I think I understand the language pretty well.

A large difficulty of learning Haskell is the (very steep IMO) learning curve. There are a lot of different inter-connected things you need to learn before you can be productive in the language, and because they're interconnected it's difficult to get a good sense of them without at least a few months of experience. My advice is to keep at it, and if you think you don't understand something, or that something deeper is happening, you're probably right. If you can't figure it out now, just move on and come back to it in a month or so. Eventually you'll make enough progress on multiple fronts that everything should become clear.

Like any language, the best way to make progress is to write code. It will take longer because Haskell is further away from the languages you already know, but it will be worth it.


Well, after 2 years I still don't fully grasp everything about Haskell. I can write "advanced" programs (after ca. 2-3 months of starting to learn Haskell), but people keep coming up with new stuff to learn, which is part of the fun of Haskell :)

As for how best to learn, I always like to learn by doing. Browse through the code of something you're interested in on Hackage (something not to big) and then try to implement something like it yourself (or a subset). Pick a project you can keep adding more difficut layers to over time.


After a 150 hour functional programming course at university, we did

  • Sorting functions
  • Making binary tree's
  • Using/writing functions like map, filter, zip
  • .. might have forgotten something

So just basics I'd say, in about one month full time. Four days is nothing... I think you'll just have to write more code to get used to the functional programming way of thinking. Implementing everything from bottom to top, doing harder stuff as you gain experience.


I studied at a Haskell-heavy university (Utrecht) and I liked Haskell a lot, so I took the following courses which all used Haskell:

  • Introductory FP (semester)
  • Grammars and Parsing with Haskell (semester)
  • Implementation of Programming Languages (semester)
  • Generic Programming (semester)
  • Software Construction (2 months)
  • Advanced Functional Programming (2 months)

I also was a TA (Teacher's Assistant) helping out with the practicals for Introductory and Implementation. And I wrote my M.Sc. on (Generic) Haskell.

So that seems like an awful lot, but I 'got' FP somewhere halfway in the Introductory course. Having a strong math background helped in my case, so I was already used in breaking down problems into simple functions. As for writing real programs, writing a Go program in Haskell was a fun exercise to learn to work with monads (the GUI was in TclHaskell, ugh!)


I think the Haskell learning curve is very strange. At the beginning, you understand almost nothing – more strangely, at most points where you want to apply your imperative knowledge (buffering, etc) you get told that you should simply forget anything about it.

After this phase, there usually comes the chapter in your book where you're taught the special flavours of Haskell. At least at this point, your brain is supposed to burst and nearly anybody thinks:

How crazy can somebody be to develop something like monads???

But as soon, as you also grasped this, nothing stops you from understanding the rest, and you think soon, how difficult and verbose imperative programming was.

BTW, it took my 2 month to understand the basics, I started February 2010. But it took me again 4 month to understand some more difficult thinks like function parameters and resulting effects (specially the State monad was a miracle until I found a nice description on SO how IO works - just the same way ;), but I see quite new think everywhere.


I'm by no means a Haskell expert, but I have two suggestions:

  • Take the time to play around with pure lambda calculus (or even SKI, if you are brave). Basically Haskell allows you to do the same things a little bit more comfortable and type-safe
  • Try to solve common problems, e.g. from Project Euler. But don't stop there, try to compare your code with other people's solutions.

The given estimations of 1~3 months to grok the basics seem realistic to me.


It will be a while before Haskell will start making sense. I am in my second month of learning Haskell and this my second attempt in the last two years. This time around, I started off with The Little Schemer. Then I watched Giesel's videos. Reading the RWH for the first time was a disaster, but now it is making a bit of sense, so hopefully in another 6 months it would be clearer. The code I am able to write in Haskell is much more succinct.

Bottomline keep at it, it will take time, but it's worth it. BTW, IRC #haskell is a great resource to help you get up to speed.

My advice, find a small programming project and gnaw at it in Haskell. Don't worry too much about writing it the Haskelly way. Just start doing it Haskell..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜