
Haskell, and Why It Might Be My New Favourite Language - sambeau
http://unbui.lt/#!/post/haskell-an-introduction
======
cies
TL/DR; a flimsy write-up on why he did not like Go, followed by a good write-
up on what's great about Haskell when you just start to use it.

Again this underlines some ideas I have about both Go and Haskell:

* Go is great from a commercial perspective; easy to learn/understand, but nothing ground-breaking.

* Haskell is great from a technical perspective; ground-breaking all over the place, but takes an investment.

I believe the Haskell investment is one that every serious programmer should
like to make as it should make your both work easier _and_ more fun.

~~~
ixmatus
I'm undoubtedly a Haskell convert (from Erlang / Scheme / Python) with little
experience in Go.

The investment is pretty big, yes, but I also believe it is great from a
commercial perspective because it really improves the result for End-Goal-
Programming (end goal is to serve business needs, not technology for
technology's sake):

    
    
        1. Time to market for a product
        2. Easy / clean refactoring
        3. Massive scale code base management
        4. Program longevity and maintainability
    

1) Time to market is extremely important for businesses and products and
schedule over-flow is a _common_ problem in software engineering that Haskell
_really does help solve_. Since building production software in Haskell I've
become completely frustrated by Python because I spend far more time building
in it due to _debugging my own undisciplined habits out of the end product_.
I'm not a very disciplined dynamic type programmer.

It also produces _cleaner and less buggy_ product for the end-user. Which is
so important!!! Particularly as a startup.

2) If you need to cleanup some technical debt from taking short-cuts or not
accurately pre-planning architecture, Haskell's type system makes it _so
friggin ' easy_ your eyes will bleed when you try to do the same in a Python /
Ruby / Erlang program.

Additionally, it really allows you to respond to the market better too! If you
have to pivot your product it's not "Oh shit, now we're going to have to take
that duct taped sewage monster and turn it into a duct taped ninja turtle."
it's "Hmmm, well, let's think through the new types a little bit and re-shape
some of this code, I know the compiler will tell me when I'm being a silly
human."

3\. Python and Ruby aren't really appropriate for large scale code bases
because dynamic typing means you need an equally massive amount of tests to
ensure no one else in the org fucks shit up. It makes team based programming
on the same codebase far more manageable!!

4\. Once I've built my Haskell programs and wrote a few minor property tests
with QuickCheck, they usually _run forever_. I've rarely ever had a case where
I would get unexpected crashes (usually from my not understanding Haskell's
laziness earlier on in my Haskell career).

Long-term maintainability is massive factor here too; it's so much easier to
figure out what the damn thing and all of its constituent pieces do with the
type system!!! It's like having an index and a table of contents for a book.
Since most programmers forget their own code anyway (comes back to that
fallible human thing), having a neat and correct _abstract description_ of
your program and its parts is invaluable to a commercial enterprise.

So, in short, I actually think Haskell is the _best language_ a commercial
enterprise could choose. All you need too is one really good programmer that
can mentor, then train them as you go; the good news with Haskell is even when
you write shitty Haskell code (un-idiomatic, mostly in the IO monad, and
barring space leaks), it's usually better than even the good Python and Ruby
code those people would be writing.

~~~
eldavido
+1, (1) (2) and (3) are very real problems in industrial software development.

I've been reading a lot how Twitter transitioned from an RoR monolith
("monorail") to SOA when they got big enough, it's a rough journey but I
suspect many companies have to take it once they evolve from iterative
prototyping/experimentation to correctness at scale.

I've also realized writing good, maintainable code can be done in any
language, it's just that some languages (e.g. Go) make it much harder to write
unmaintainable code for many of the reasons you've cited above. "Debugging my
own undisciplined habits" really hit it on the head.

~~~
ixmatus
Yeah, if you ever get a chance to build something for production in Haskell /
Scala / OCaml you'll realize how little even Go (which is better than Python
and Ruby!) does for you.

The funny thing is, I believe (from real-world startup building experience)
that Haskell has allowed me to iterate / prototype my products faster than I
ever would have with Python and Erlang (my old go-to tools).

Also, with Haskell, there's no late-night and weekend fires to put out :)
Which makes me more productive and generally happier.

[EDIT] To whomever is downvoting these legitimate comments, speak up why you
think they are inappropriate for this discussion instead of downvoting.

------
eldavido
Slightly meta, but: has anyone else noticed how much love languages with very
strong type disciplines have been getting on HN recently? Scala, Haskell,
Clojure, Go, Rust jump out.

Maybe language designers/toolmakers are getting better at bringing the
benefits of stronger typing (superior editor support, faster execution times,
less need for unit testing) without as much baggage: highly ceremonial code,
complex compiler setup/tooling, etc? I suspect editor/compiler-level type
inference, where you can do things like "val x = NewVal()" vs. "NewVal x = new
NewVal()" might have something to do with it.

As someone who's swung back and forth across this divide, I get the sense that
modern static language development is much less of a pain in the ass than it
was 10yrs ago.

I'm less interested in static vs. dynamic than I am in why the community seems
to be floating in this direction __recently __, when the past 5-7 years has
been all about RoR, Django, and even Perl.

~~~
ixmatus
I do not consider Go to have a strong type system. It's static though.

Strong typing allows you to do a lot and it also solves the problem we
_fallible humans_ bring to the table. Humans are pretty good at being creative
but extremely terrible with details, remembering things, and keeping track of
"hairballs".

Strong type systems solve pretty much all of that.

Now, with some of Haskell's newest features (like Type Holes) it's starting to
make dynamic languages look more like children's toys because you get all the
power and safety of a type system with the same "do what you want, it will
(usually) tell you what you're intending to put there".

Dynamic programming came from a need for rapid iteration of a program because
that's how humans work, we "start" then iterate till we have a more complex
and functioning program. The problem with that model though, is that the
burden of correctness is on us _in the end_.

Programming in Python is like leaving your dishes pile up in the sink for a
week, then spending two hours doing dishes on Sunday.

Programming in Haskell is like taking your dish to your cleaning robot that
will wash it, dry it, and put it away for you. All you have to do is know what
you want to use the plate for and return to where the robot can get it.

~~~
IanCal
> Programming in Haskell is like taking your dish to your cleaning robot that
> will wash it, dry it, and put it away for you. All you have to do is know
> what you want to use the plate for and return to where the robot can get it.

With the occasional smash coming from the kitchen when you find out the robot
has been trying to hold all of your plates at once instead of putting them
away because you haven't gone to get one out of the cupboard yet ;)

~~~
slashnull
A stack of type t things blowing up because of lazyness... How appropriate ; )

------
woah
Haskell syntax just seems pretty crazy. I know nothing about it, but I just
read it and wish that maybe one could use a few more lines and get better
understandability at the expense of terseness.

~~~
ixmatus
It's the difference between Eclipse and Emacs. Haskell actually encourages
"internalization" of abstractions through terser syntax.

Emacs is like that, you internalize the editor which makes you 5x more
productive than you are with an editor that externalizes the abstraction
requiring your brain to use another layer of translation (the visual one).

If you learn Haskell, you'll find it quite enjoyable (I do now). The way I
think in that language is _so much more abstract and precise_ than it ever was
in Python / Scheme / Erlang / Ruby / Javascript.

[EDIT] To whomever is downvoting these legitimate comments, speak up why you
think they are inappropriate for this discussion instead of downvoting.

~~~
thescribe
Your enthusiasm has convinced me to give Haskell another shot, do you have a
favorite resource I should try? I didn't have great luck prior.

~~~
louthy
These should get you started:

Really well presented series of lectures:

[http://www.seas.upenn.edu/~cis194/lectures.html](http://www.seas.upenn.edu/~cis194/lectures.html)

Cheat sheet:

[http://blog.codeslower.com/static/CheatSheet.pdf](http://blog.codeslower.com/static/CheatSheet.pdf)

Books:

[http://learnyouahaskell.com/chapters](http://learnyouahaskell.com/chapters)

[http://book.realworldhaskell.org/read/](http://book.realworldhaskell.org/read/)

"What I Wish I Knew When Learning Haskell":

[http://dev.stephendiehl.com/hask/](http://dev.stephendiehl.com/hask/)

Haskell Tutorial for C Programmers (useful for anyone coming from an
imperative world):

[http://www.haskell.org/haskellwiki/Haskell_Tutorial_for_C_Pr...](http://www.haskell.org/haskellwiki/Haskell_Tutorial_for_C_Programmers)

Hoogle (API search engine):

[http://www.haskell.org/hoogle/](http://www.haskell.org/hoogle/)

~~~
louthy
Oh I forgot the Erik Meijer lectures are awesome:

[http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-
Func...](http://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-
Programming-Fundamentals/Lecture-Series-Erik-Meijer-Functional-Programming-
Fundamentals-Chapter-1)

~~~
platz
One thing you get from his lectures that aren't in other resources is how he
views OOP and FP as two different sides of the same coin.

Fascinating to hear how the same ideas are expressed both ways.

------
shawkinaw
getMultiples is even shorter and clearer written like this:

    
    
        getMultiples = [x | x <- [1..999], x `mod` 3 == 0 || x `mod` 5 == 0]

~~~
ckw
Golf:

    
    
      getMultiples = [3,6..999] `union` [5,10..999]

~~~
gertef
That doesn't sort the output neatly. You need a merge

[http://hackage.haskell.org/package/MissingH-0.18.6/docs/Data...](http://hackage.haskell.org/package/MissingH-0.18.6/docs/Data-
List-Utils.html#1)

------
wirrbel
one thing about Haskell: It is different from other languages, but once you
got the "mindset" it turns out to be surprisingly _easy_* to use.

* especially, the haskell way of type-abstraction is sound and makes for really nice and convenient libraries in a way that one cannot imagine if not experiencing it form oneself.

------
stefantalpalaru
As crazy as it sounds, I can confirm that Go is a gateway drug for Haskell.

~~~
letstryagain
Have you looked at Rust?

~~~
stefantalpalaru
Not yet. It looks like a moving target for now so I'm waiting for a stable
release.

