Live data from Hacker News

Learn You a Haskell for Great Good (2008)

learnyouahaskell.com

51–60 of 123 posts

Re: Learn You a Haskell for Great Good (2008)

#51

What is a good online reference to learn about "Monads" for beginners? Someone posted a reference here on HN sometime ago but I lost it. Edit: The book was enjoyable and a delight to read, but I started struggling to keep up from Chapter 8. as it went into Monoids and Monads, I feel like I need to read other tutorials before coming back to it.

Both monads and monoids: The only thing you need to learn about them is practice. Screw tutorials and books. Read LYAH's intro chapter once (you won't understand everything, but that's fine) and then write code.

Re: Learn You a Haskell for Great Good (2008)

#52

I always have been interested on haskell.... but it doesn't look to be enough practical. For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript. It is possible to interoperate with the host language? Does it perform well for high performance activities? Is it possible to isolate some kind of events in a thread? Edit: T…

Your fears are not warranted. Haskell is the most practical of the "research languages" out there, it's very mature and has good facilities for interfacing with the "real world".

> For example there is almost no information about how to write a smartphone videogame in haskell

This has been done before but most of the "hard stuff" here is getting your game built and deployed on a smartphone. You can find Haskell for Android articles if you look around.

There are examples of game programming in Haskell too.

> It is possible to interoperate with the host language?

There is no concept of "host" lanugage, Haskell emits native code.

You can call native code from Haskell and Haskell code from C or other native languages.

> Does it perform well for high performance activities?

Haskell is good enough for most "high performance" activities (it's one of the highest performing high level languages according to the debian shootout), but caveats may apply with long running processes and garbage collection, etc.

> Is it possible to isolate some kind of events in a thread?

Yes. Haskell has very nice threading facilities and high-level concurrency primitives, including stuff similar to "channels" from golang.

Re: Learn You a Haskell for Great Good (2008)

#53

I always have been interested on haskell.... but it doesn't look to be enough practical. For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript. It is possible to interoperate with the host language? Does it perform well for high performance activities? Is it possible to isolate some kind of events in a thread? Edit: T…

I enjoyed working through this book. Actually it helped me learn enough Haskell to realize that I wasn't that interested in it. I found that it wasn't as safe as it claimed to be and that the tooling was not very good. There are some refreshing and interesting ideas, but overall I'm not sure it was worth my time.

Re: Learn You a Haskell for Great Good (2008)

#54

I always have been interested on haskell.... but it doesn't look to be enough practical. For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript. It is possible to interoperate with the host language? Does it perform well for high performance activities? Is it possible to isolate some kind of events in a thread? Edit: T…

I would not say that Haskell is currently ideal for writing native smartphone apps. It's possible and people are working on making it easier, but it's rough territory still.

Javascript is easier, ghcjs (while still a bit tricky to install) is 1.0 and lets you compile arbitrary GHC Haskell (including all extensions, lightweight threads and STM) to JS for both Node.js and the browser. Template Haskell support is on the way too.

Calling the C FFI from Haskell is fairly trivial in my experience. If you have structs you want to manipulate from inside haskell it's a bit cumbersome and confusing initially, but if you're just using primitive types and pointers it's easy.

Haskell does very well for high-performance when it comes to IO, as-of GHC 7.8's new IO manager the fastest Software-Defined Networking (SDN) application is written in Haskell [1]. In terms of pure computation bound performance Haskell, does well enough, optimising truly high-performance Haskell is as much arcane art as optimising C (we're talking "I want microsecond inner-loops" level of optimising). In general I would say that you should expect Haskell to be around JIT Java levels of speed for most cases where the code is not blatantly inefficient. So certainly an order of magnitude faster than python/ruby.

Lots of people complain about performance reasoning in Haskell being hard, which is partially true. But mostly, IMO it is simply different from doing so in C, so you need to unlearn/relearn all your performance tweaking skills.

As for Haskell vs Clojure and becoming a better developer. I think Clojure looks like an interesting language, but I would recommend learning Haskell anyway. Why? Because Haskell is one of the "most different" languages in which people are still writing lots of real world code. Which means that it will expose you to the largest number of new concepts while still having decent practical library support. Key features, IMO are: Purity, type system, laziness, and type classes.

Incidentally, I would urge everyone to please stop using this silly "transpile" word. Compile is already source-to-source and introducing a new silly sounding word for it isn't helping anyone.

[1] - http://haskell.cs.yale.edu/wp-content/uploads/2013/08/hask03...

Re: Learn You a Haskell for Great Good (2008)

#55
post #4

I'm currently working through this book. Overall it seems like a good introduction but I wish it had exercises at the end of each section. I learn best by working through specific problems.

Extensive list of resources including many that have exercises: https://github.com/bitemyapp/learnhaskell

Re: Learn You a Haskell for Great Good (2008)

#56
I like Haskell for the same reasons I like VIM:

- It needs some brain melting to learn but it ultimately makes you a better coder. Time is not wasted on learning it. - A new exciting mindset !

- When you feel you're doing something repetitive, it's nearly sure there is a way to do it effortless.

- Advanced stuff

Re: Learn You a Haskell for Great Good (2008)

#57

I always have been interested on haskell.... but it doesn't look to be enough practical. For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript. It is possible to interoperate with the host language? Does it perform well for high performance activities? Is it possible to isolate some kind of events in a thread? Edit: T…

> For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript.

These guys are doing it pretty seriously: http://keera.co.uk/blog/all-posts/

And frankly a smartphone videogame is a pretty specialized use case; a lot of pretty mainstream languages (perl?) don't have a good story for how to do that. In fact I've never heard of anyone writing a smartphone game in Clojure - I guess you could do one for Android since it's just java bytecode, but does anyone?

"Practical" for most programmers is server-side business apps, and Haskell is very very good at those.

> Does it perform well for high performance activities?

Yes, very much so.

Re: Learn You a Haskell for Great Good (2008)

#58
post #20

What is a good online reference to learn about "Monads" for beginners? Someone posted a reference here on HN sometime ago but I lost it. Edit: The book was enjoyable and a delight to read, but I started struggling to keep up from Chapter 8. as it went into Monoids and Monads, I feel like I need to read other tutorials before coming back to it.

The original monad papers, by Philip Wadler. Accept no substitutes. http://homepages.inf.ed.ac.uk/wadler/topics/monads.html http://homepages.inf.ed.ac.uk/wadler/ Alternatively, if you really are allergic to LaTeX, or beards, the recently Oscared sigfpe’s “You Could Have Invented Monads! (And Maybe You Already Have.)” http://blog.sigfpe.com/2006/08/you-could-have-invented-monad... There are no other monad tutorials. J…

Yes there are. What made monads eventually "click" for me was the incredibly detailed, eight-part Mike Vanier's tutorial on monads in general and in Haskell in particular. First part: http://mvanier.livejournal.com/3917.html

Re: Learn You a Haskell for Great Good (2008)

#59
post #54

I always have been interested on haskell.... but it doesn't look to be enough practical. For example there is almost no information about how to write a smartphone videogame in haskell, even if it possible to trasnpile it to C or to Javascript. It is possible to interoperate with the host language? Does it perform well for high performance activities? Is it possible to isolate some kind of events in a thread? Edit: T…

I would not say that Haskell is currently ideal for writing native smartphone apps. It's possible and people are working on making it easier, but it's rough territory still. Javascript is easier, ghcjs (while still a bit tricky to install) is 1.0 and lets you compile arbitrary GHC Haskell (including all extensions, lightweight threads and STM) to JS for both Node.js and the browser. Template Haskell support is on the…

Lots of people complain about performance reasoning in Haskell being hard, which is partially true. But mostly, IMO it is simply different from doing so in C, so you need to unlearn/relearn all your performance tweaking skills.

I don't agree. First, of all, the naive solution in C is often pretty fast, while the naive solution in Haskell often has obnoxious runtime properties.

Then, most C optimization performance reasoning applies to Haskell as well: keep your data small, in contiguous memory, etc. The first thing that complicates optimization in Haskell is that defacto Haskell data structures are the opposite: pointer/thunk-rich. So, you usually end up with libraries such as 'vector', doing the heavy lifting in the ST monad.

Then, laziness adds even more complications, both in that it adds a new class of bugs (of course, Haskell removes buffer overflows et al.) which tend to be relatively hard to debug (the heap explodes in less expected places).

When you write production code, you usually accumulate some monads. Unfortunately, the relatively obvious way to use multiple monads (monad transformers) is slow. So, you have to roll your own monad stacks:

https://wiki.haskell.org/Performance/Monads

---

In the end, even something as simple as reading a list integers in the IO monad can be an exercise in frustration:

http://www.joachim-breitner.de/blog/620-Constructing_a_list_...

The same can't be claimed for C. Even a newcomer could do it.

Post reply on HN