Live data from Hacker News

Why Haskell Is Worth Learning

spin.atomicobject.com

51–60 of 114 posts

Re: Why Haskell Is Worth Learning

#51
post #46
post #29

Earlier quoted context omitted.

Haskell is also very simple--not from an implementation standpoint but from a semantics standpoint. Having polymorphism with no sub-typing (and no casting) is conceptually simple and easy to work with. Parametric polymorphism (like Java's generics but simpler and less horrible) is actually an extremely simple concept. The difficulty comes from a) implementing it in a stupid way after the fact ( cough Java) or b) havi…

It is an issue of the language's qualities if it does not really make it easier to reason about code. I find reason to question the simplicity of something which is widely acknowledged to take a lot of time to learn, to be mind-bending, and which seems to be impossible to explain simply - without deep theoretical background, academic citations or oversimplifications acknowledged as misleading. I think it would be mat…

Hrm, I have found the main benefit of Haskell is that it makes it far easier to reason about code. The separation of side effecting operations from non-side effecting is huge.

Also I am very comfortable with monads and have never dug into the theoretical category theory side of it.

I bet you could be writing code in the IO monad within a day with some proper guidance. It really isn't hard at all.

Re: Why Haskell Is Worth Learning

#52
post #42

Earlier quoted context omitted.

You're right that I'm not very fluent on how Cabal works. It worked well enough that I didn't really need to until recently. I'm not claiming either that CPAN is better than Cabal. Could versioning be done better? Probably. I don't even claim to know enough to have a competent suggestion as to how, though. Doesn't mean things don't break, though.

>Doesn't mean things don't break, though. Right. The issue is that cabal has unfairly developed a reputation as being broken. People always say stuff like "every other language has this sorted out, why is haskell so bad at it?". When the reality is that the problems you get with cabal are the same ones you get with cpan or pip or anything else.

They're slightly exacerbated in that Cabal/GHC/Haskell type checks and thus has a higher likelihood of discovering mismatches.

Re: Why Haskell Is Worth Learning

#53
post #35

Earlier quoted context omitted.

Don't want to turn this into Stack Exchange and this may be homebrew's fault on OS X but I just tried installing 'haskell-platform' and got: Error: Building the QuickCheck-2.5.1.1 package failed make: *** [build.stamp] Error 2 Ok I will install the package on haskell.org, which instructs me to 'To upgrade, run: cabal install cabal-install': ... cabal: Error: some packages failed to install: cabal-install-1.16.0.2 fai…

You have to scroll back to see the actual error. That could be anything from missing C libraries to a permission problem.

I'm sure it's fixable, it's just not the best first impression for those new to the ecosystem :) I love trying out new languages (prag pubs 7 languages in 7 days is great) but for production work I want to know that down the line if I need lib x, it won't be hard to find and even more importantly it will just work (or the googles machine will lead me in the right direction).

I actually stayed away from Scala for a while for this reason. SBT would blow up left and right. It's more mature now and with Play you can build performant web apps very quickly.

Re: Why Haskell Is Worth Learning

#54
post #16

I was thinking about this the other day and I think it generalizes beyond any specific language. I'm pretty sure every time I have learned a new programming language I came away a better programmer. Different programming languages (and their standard libraries) suggest that you approach problems in different ways, and that has real cognitive benefits. I was actually trying to think if there was ever a case where I ha…

There's not much value in learning programming languages that are similar. If you learn Ruby, you already know pretty much everything there is to know about Python. If you learn Java, you already know much about C#. The only real value you can get out of learning new mainstream languages is from learning the architecture of popular libraries. Like when I was inspired a few years ago to do database migrations after I…

I agree that there is pedagogical value in forcing yourself to write programs using only immutable data structures, but I don't think it's a restraint we should impose on ourselves for real world day-to-day programming. You aren't "cheating" if you've evaluated several ways of writing a program and you really think mutable local state is the best way to do it.

Also lazy data structures are built into many mainstream programming languages. Python generators are the first example that comes to mind. I think you are probably excited about Haskell because it incorporates lazy evaluation which is a separate concept.

Re: Why Haskell Is Worth Learning

#55
Haskell implements functional programming that's truly pure of side effects, strongly statically typed with inference and overloading, and lazily evaluated. There's really nothing else out there that's like it.

Programming in Haskell is really difficult, but I've learned to appreciate that this is because Haskell programmers are forced to fix more of their bugs at compilation time, rather than later when code is deployed.

Don't make the mistake of conflating Haskell (pure, typed, and lazy) with Lisp (impure, untyped, eager), ML, Scala, or anything else out there. It's truly a unique experience, and it's one that every good programmer must know.

Re: Why Haskell Is Worth Learning

#56
post #7

Earlier quoted context omitted.

At university the very first language we are taught is Haskell. Lots of people had never programmed before, in anything and everyone managed fine. Nothing scary at all, no need for an understanding of category theory or anything. Monads are (fairly) simple things that just have a really bad reputation, partly the fault of the haskell docs which make them seem complex. Firstly: Functors are things we can map over in a…

I'm curious what school you went to, there can't be a lot of universities that teach Haskell?

University of Texas at Austin teaches Haskell to 2nd year students in a required course: CS 337 - Theory in Programming Practice.

Programming Languages is also taught in Haskell, but it's an optional course and languages varies by professor.

Re: Why Haskell Is Worth Learning

#57
post #53

Earlier quoted context omitted.

You have to scroll back to see the actual error. That could be anything from missing C libraries to a permission problem.

I'm sure it's fixable, it's just not the best first impression for those new to the ecosystem :) I love trying out new languages (prag pubs 7 languages in 7 days is great) but for production work I want to know that down the line if I need lib x, it won't be hard to find and even more importantly it will just work (or the googles machine will lead me in the right direction). I actually stayed away from Scala for a wh…

My point is not "it is fixable". My point is you didn't look at the error and just decided "shit's broken". Your problem is with 99.999999% certainty a simple problem that is unrelated to cabal. The fact that it is possible to see an error does not indicate that there is some uncertainty about whether or not you will be able to install lib x.

Re: Why Haskell Is Worth Learning

#58
post #54

Earlier quoted context omitted.

There's not much value in learning programming languages that are similar. If you learn Ruby, you already know pretty much everything there is to know about Python. If you learn Java, you already know much about C#. The only real value you can get out of learning new mainstream languages is from learning the architecture of popular libraries. Like when I was inspired a few years ago to do database migrations after I…

I agree that there is pedagogical value in forcing yourself to write programs using only immutable data structures, but I don't think it's a restraint we should impose on ourselves for real world day-to-day programming. You aren't "cheating" if you've evaluated several ways of writing a program and you really think mutable local state is the best way to do it. Also lazy data structures are built into many mainstream…

Not only is that not cheating, it's actually completely reasonable in Haskell too! You can use ST to have as much mutable state as you like; the awesome thing is that the state is guaranteed not to leak--from the outside, the function is just as deterministic as one that doesn't use mutable references and data structures.

The big idea about Haskell isn't to avoid all state. Not at all. The big idea is to control state. Haskell expects you to use state if it makes the logic clearer or the code much faster.

What you do not do in Haskell is use state for program organization. You avoid global state as much as possible. This means that communication between disparate parts of your program are explicit--you don't have implicit dependencies everywhere. This is definitely a good thing.

I think one of the problems is that people without much experience in Haskell interpreter "purely functional" too strictly. It just means you do not have state by default; you can still use it where it makes sense.

The good thing about not having it by default is that it forces your program to be simpler and more decoupled and it lets the compiler and libraries make many more assumptions about your code. All sorts of awesome features like STM and data parallel Haskell depend on having this sort of control over side-effects. But that's all it is--control. You can still have state and side effects; however, unlike most other languages, you can also not have them.

Re: Why Haskell Is Worth Learning

#59
post #25

I have to admit that I'm really on the fence about Haskell. My major gripe with this point I think is point (3). Haskell has (IMHO) gone down a similar road to Scala. Scala has literally tied itself into knots to make statically typesafe collections (amongst other things). I see parallels with Haskell (maintaining functionality purity but dealing with the "outside world" through monads). I'm not saying this is wrong.…

Also, this sentiment is popularized as worse-is-better: http://www.jwz.org/doc/worse-is-better.html

Re: Why Haskell Is Worth Learning

#60
post #16

I was thinking about this the other day and I think it generalizes beyond any specific language. I'm pretty sure every time I have learned a new programming language I came away a better programmer. Different programming languages (and their standard libraries) suggest that you approach problems in different ways, and that has real cognitive benefits. I was actually trying to think if there was ever a case where I ha…

The point about learning Haskell in particular is that it's a way different different language. It's a single language that gives you exposure to a lot of new ideas: purity, laziness, modern type systems, functors, monads, monoids, etc.

The massive difference though gives people like me, who've never done anything like Haskell before and do not properly comprehend it some real trouble though. It's similar to assembler. At first, you don't understand how the code works, how the logic is implemented, and everything just seems strange. Then you start looking at it as seperate commands to the processor and suddenly you understand. Sudenlly MOV r1,0x90 start: MOV A,#0x04 INC A DJNZ r1,start makes sense to you.

Sorry, I started fantasizing about Assembly again, my actual question was: "If you could find a metaphor that describes how Haskell works with Data, what'd be that metaphor?"

Post reply on HN