Hacker News new | ask | show | jobs
by chadaustin 4015 days ago
You should probably still learn Haskell, because it will help you get better at separating concepts in other programs you write. Ideas you will learn in Haskell that you won't necessarily in the languages you listed:

- type classes and their associated laws (e.g. generalize mapping: it's obvious that you can map across a list. it's less obvious that you can also map across a Maybe. it's even less obvious that you can map across a function...)

- sum types

- functions as a distilled programming concept without ancillary implementation details such as C's or C++'s "unique address" rules

- restricted effects - subsetting IO for stronger static guarantees (like c++'s const but way more powerful). STM was built this way. BufferBuilder too. http://chadaustin.me/2015/02/buffer-builder/ It's a powerful technique in Haskell that you don't get in other languages.

- the realization that monomorphization is a generics implementation detail

- the feeling that you get from generic, terse, dynamic-looking code that you can still rapidly iterate on in a repl

Haskell is not some pure ivory tower - there is plenty of imperative stateful code written in Haskell. The value of Haskell is that it introduces a pile of powerful ideas that you will carry through the rest of your career, even if you don't write Haskell on a day-to-day basis.

2 comments

> there is plenty of imperative stateful code written in Haskell.

Yep. For instance here's a program that logs into paypal to check your balance in Haskell using screen scraping:

https://github.com/codygman/hs-scrape-paypal-login/blob/mast...

OK, that's funny. I don't know Chad, but I did some work for IMVU a couple years ago, and yes, their backend services spit out a LOT of JSON.

Some of the other things I do have in other languages: JavaScript, Go, and Lua give me first class functions, including the ability to curry.

Sum types looks nice, but also looks functionally equivalent to enum type in C++; pattern matching is a nice feature if you ever need it, but in the kinds of programs I usually write, I don't.

The value of type classes is less clear to me. Duck typing gets you a lot of reuse leverage without the mental masturbation of the quick reference I found online to the concept.

Monomorphization is a generics implementation detail. Yes. What of it? If you're in C++ and using templates, then they're useful. I'm guessing its use in Haskell is related to the Haskell pattern matching feature, which again I don't end up needing very often (I'm not saying it wouldn't be convenient, just that it doesn't make a compelling argument to change languages)?

Terse and actually dynamic code is pretty awesome as well. Right now I'm restricted to code that can run in the browser, so I'm stuck with JavaScript for the most part, but when I get to use Lua and Go, I get a lot of the power (the parts relevant to my typical code) along with a lot of speed.