Live data from Hacker News

Learn You a Haskell for Great Good

learnyouahaskell.com

21–30 of 67 posts

Re: Learn You a Haskell for Great Good

#21
post #9
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

You don't need it. If you are a Junior developer (or aiming at being one) Haskell is a language you most definitely don't need. Now, once you have your feet wet, it's worth learning. Here's why: - Pure(mostly) functional language. This is in opposition to Java & Ruby, which while having functional aspects are OO (Object Oriented). - It's okay not to know what a functional language is. It's making functions first-clas…

Functional programming is really more than first-class functions. A lot of languages have support for first-class functions (including Ruby's procs) that are not really functional languages. Functional (like all paradigms) is a bit nebulous, but to really be a functional language I would expect to see immutability as a default assumption, and I would expect to see only expressions, no statements. That latter expectation is really what gives functional programming its distinctive style. When everything returns a value, chaining together functions as transformations on data simply becomes the natural way to program.

Re: Learn You a Haskell for Great Good

#22
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

There are two very different types of arguments typically made as to why to learn the more esoteric languages (Haskell, Lisp, Forth, others).

The first is the more common: learning these languages exposes you to other ways of programming, which in turn makes you a better programmer no matter what language you're programming in. This is unquestionably true. Mainstream languages are constantly learning new things from these languages, which means you will be able to apply the techniques you learn from them to your code no matter what language you write in. I have the misfortune[1] of writing a lot of PHP at my day job, but it turns out even PHP has support for filter and map over arrays. If I hadn't learned functional programming, I would never have even looked for them.

The other argument, which is made less often, is that you can actually write great software in these languages. This argument is made less often because we can obviously look at the market and the TIOBE index and see that Haskell is way down at #30 with 0.323% of the market share. However, there are really great programs made in Haskell (xmonad, for one). There are also tons of great programs made in Lisps, especially Clojure of late. So, this second argument is not entirely a dead end either.

Revisiting something I mentioned in the first argument for a moment though, I would actually make a third argument that I rarely see. As I said, other languages are constantly learning new things from these languages. Haskell's community is full of PhDs studying at the intersection of programming and mathematics, and they are discovering the things that will revolutionize programming in the future. Haskell, for example, has been exploring strong static typing with algebraic datatypes[2], Hindley-Milner type inference, and typeclasses to support higher-kinded polymorphism[3]. Those concepts are turning out to be incredibly powerful, and you will inevitably see them in other programming languages in the future. We've seen this before with Lisp (garbage collection, recursion, first-class functions), and there's no reason not to expect the trend to continue.

So, why learn Haskell? It's the easiest way to see what tools you'll have available to you in industry 20 years from now when the other languages catch up.

[1]: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

[2]: https://www.youtube.com/watch?v=YScIPA8RbVE

[3]: http://www.haskell.org/haskellwiki/Typeclassopedia

Re: Learn You a Haskell for Great Good

#23
post #3

This is an amazing book. I highly recommend it as the first Haskell book you read. After it, you can check out Real World Haskell. To elaborate on why you shouldn't read (at least the online version of) Real World Haskell first: It has a lot of important topics that it covers that LYAH does not cover (like how to use cabal their package manager). But, it's not as good of a tutorial on the language and functional prog…

Oddly, I find real world haskell more useful when I'm fussing with Haskell. /me shrug

Re: Learn You a Haskell for Great Good

#24
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

If you want to look at an interesting functional language that has some very solid real world uses, have a look at Erlang, and its own "Learn you ..." here:

http://learnyousomeerlang.com/

Which is a fantastic book, clearly written as a labor of love.

Erlang doesn't have Haskell's type system and doesn't seem to be of much interest for CS research types, but it's awesome for developing certain kinds of system.

I am curious about Haskell myself, and don't tend to need a lot of excuses to learn a language, but I don't perceive a "sweet spot" for it just yet, as in "I could go build X, and Haskell would be a great fit for it". Given how many smart people use it, I'm sure there are a lot of applications for it, but I also get a feeling that there's not one thing that really stands out.

Re: Learn You a Haskell for Great Good

#25
post #17
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

> I always see it mentioned on Reddit but I have yet to come across any notable project written with it. xmonad, one of the best tiling window managers for Linux, is written in Haskell (and is open source).

> xmonad, one of the best tiling window managers for Linux

...and BSD

Re: Learn You a Haskell for Great Good

#27
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

From the perspective of "learn other languages to broaden your horizons": Haskell is worth learning because it has an expressive, strong, static type system. Most other languages do not have that property (Java's type system is static, give or take null, and strong, but not expressive, and Ruby's is strong but neither expressive nor static). The Haskell type system lets you have conversations with the compiler about…

Why makes you say that Ruby's type system is not expressive? I'm not exactly sure what that means. I've heard of a language being called expressive, but not a type system.

By the way, does Haskell's type system have the "value restriction" that you run into in ML?

Re: Learn You a Haskell for Great Good

#29
What I find confusing with Haskell is that the keywords don't seem to be consistent with the concepts they're meant to express. As someone new to Haskell I learnt that the `class` keyword doesn't express the object-oriented concept of class, but the concept of type class, which is different. Fair enough. What about declaring types then? That must be `type`, right? Nope, `type` is for creating type aliases. OK, surely that must be `newtype` then? Wrong again, `newtype` is also for declaring aliases. All right, to declare a new type, you don't use `newtype` nor `type` you use `data`. But be careful, the part that has the `data` keyword is still called a type constructor, whereas the part that does not have the `data` keyword is called a data constructor.

OK so let's recap, you create a new type with `data`, which is formed of a type constructor that starts with the keyword `data` and a data constructor which doesn't start with `data`. To create aliases you use `type` and `newtype` and to create type classes you use `class`.

Now how do you call the type class of things that can be mapped over? Surely that must be something like `mappable`?

Re: Learn You a Haskell for Great Good

#30
post #9
post #5

Haskell looks very interesting but I can't help but ask 'why do I need it?'. Currently I am learning Java since I want to get a jr.developer job later on and Ruby for some scripting and personal projects(maybe even Rails later). So Java is used in industry, Ruby is used in web and metasploit/ronin (something that I like to mess with), but what about Haskell? I am genuinely curious what Haskell can offer. I always see…

You don't need it. If you are a Junior developer (or aiming at being one) Haskell is a language you most definitely don't need. Now, once you have your feet wet, it's worth learning. Here's why: - Pure(mostly) functional language. This is in opposition to Java & Ruby, which while having functional aspects are OO (Object Oriented). - It's okay not to know what a functional language is. It's making functions first-clas…

To amplify what another has said, the emphasis of functional programming is side-effect-free code, where the default assumption is that functions don't have side effects, and so can be treated as components in a pipeline that modifies data step-by-step from its initial input state to its final output state.

Ideally, these components are composable and reusable, both to facilitate reasoning about the code and code reuse. The Haskell Standard Prelude is a fantastic example of this working out well.

Basically, it's based on the idea that the functions which are easiest to reason about are those with one well-defined input and one well-defined output which is completely determined by that input. You can't always have this, but functional languages attempt to get you as close as possible. The simplicity of pipeline-style programming is one of the happy little dividends of this kind of thinking.

Post reply on HN