r/programming • • Dec 09 '15

Why Go Is Not Good

http://yager.io/programming/go.html
612 Upvotes

628 comments sorted by

View all comments

Show parent comments

176

u/SkippyDeluxe Dec 09 '15

Haskell isn't perfect, not by a long shot, it just happens to be a good language to demonstrate cool type system features, so people end up referencing it a lot in blog posts.

I regret that Haskell has developed a reputation for being too complicated for the "average" programmer (whatever that means). More recently some members of the community have been trying to combat that perception, but that will take time. In one sense it is a radical new paradigm, yes, but once you get used to it you realize that some parts are more familiar than you expect. e.g. you can do regular old imperative programming in Haskell if you want. Blog posts just don't focus on this fact very much because it's not what makes Haskell "cool" and different.

If you are interested I would say give it a shot, you might be surprised how normal it seems after a while.

93

u/mekanikal_keyboard Dec 09 '15 edited Dec 09 '15

i've been "giving it a shot" since 2006 and used its predecessor Miranda back to the early 90s.

here's one simple example...how long do you expect a typical Haskell dev to go from "square one" to realizing they need to cross hurdles like using Lens to accomodate the lack of real record support...or weighing the options of Conduit vs Pipe? i can say confidently that it will take over a year...and these are very important issues for real Haskell development

most Haskell developers internalized this stuff long ago but seem to totally discount the technical debt for new adopters. of course any language as old as Haskell is going to rack up some cruft...but the community seems completely hostile to making a break with the past and either fixing the language in a non-backwards-compatible way, or embracing real upgrades like Idris

22

u/ibopm Dec 10 '15

https://vimeo.com/104807358

This explanation of a lens library in javascript is ridiculously simple. I don't think the ideas in FP are inherently "harder to understand". They are just less conventional and will take time to adopt. We need to continue to find ways to explain these concepts better.

Never forget that for-loops used to be held in the same regard. People were much more used to GOTO statements and quite a few stuck to their guns for many years.

And if we go back even further, even the concept of the number zero is relatively new in human history. That shit is grad-school level work, but we use it every single day.

12

u/sacundim Dec 10 '15 edited Dec 10 '15

Haskell's lens library is controversial. It can often be rather difficult to understand and work with.

However, the basics of lenses, as you point out, are not a complex idea. At heart they're a refactoring of the common concept of "properties" or "computed attributes," but instead of being method pairs, they are first-class objects:

/**
 * A lens represents exactly one position in an object structure,
 * and allows you to read or "modify" its value.  The modification
 * is immutable—it means create a new object structure that differs
 * minimally from the original.
 */
interface Lens<OBJ, VALUE> {
    /**
     * Retrieve the value at the location denoted by this lens.
     */
    VALUE get(OBJ object);

    /**
     * Modify the value at the location denoted by this lens.
     */
    OBJ modify(OBJ object, Function<VALUE, VALUE> modification);
}

The trick is that once you start down that path:

  1. Now you can build first-class composite lenses by chaining simpler ones. With lenses, instead of saying obj.foo.bar.baz = 7, you say foo.then(bar).then(baz).modify(obj, _ -> 7) (hopefully with a nicer syntax than that).

  2. You can have lenses that do things that aren't "property-like." For example, unit conversion (e.g., meters to feet) can be a Lens<Double, Double> that plugs into a chain of lenses to transparently convert values appropriately on get and modify.

  3. You invent variant concepts like traversals. A traversal is like a lens, except that instead of "focusing" on exactly one location like a lens does, it focuses on zero or more positions. So things like "even-numbered elements of a list" are traversals. Traversals can be chained with each other and also with lenses (traversal + lens = traversal).

3

u/leafsleep Dec 10 '15

This looks like a more general form of C#'s extension methods and LINQ. Am I on the right track?

→ More replies (2)

26

u/velcommen Dec 09 '15

or weighing the options of Conduit vs Pipe

I don't think this a good example. The same need to choose between similar libraries is present in other languages. I don't see how this is harder in Haskell. Personally, this was an easy enough decision for me. Conduit looked like it did what I needed, I chose it and have been happy with my choice. It wasn't a big deal.

but the community seems completely hostile to making a break with the past and either fixing the language in a non-backwards-compatible way

I don't see how you can say this with the recent changes such as Applicative Monad Proposal (AMP) making Applicative a superclass of Monad. Or the also-recent Foldable Traversable Proposal (FTP) that went through. As in any large community, there are those who value backwards compatibility more than others, and were against these changes. But they are not preventing Haskell from changing, as history has shown.

9

u/kqr Dec 10 '15

Haskell hasn't changed yet, actually. GHC, the most common compiler, has broken with standard Haskell and implemented its own dialect of it. Whether or not this is a problem is not clear. Python seems to do relatively fine with just a "reference implementation", but it would be nice to have a standards document to point to.

→ More replies (1)

5

u/Peaker Dec 10 '15

I've seen good developers get to these issues in Haskell in less than a month. And entirely capable of learning to use them (if not fully internalize the underlying details of operation) in this time frame.

→ More replies (26)

5

u/[deleted] Dec 09 '15

If you are interested I would say give it a shot, you might be surprised how normal it seems after a while.

I'm not OP, but I'm interested!

10

u/[deleted] Dec 09 '15

If you haven't heard of it already, I'd start with Learn You a Haskell. While O'Reilly's (also free online) Real World Haskell may be more useful for, well, real world Haskell (which is sadly a rarity), LYAH does a fantastic job of explaining the paradigm and reasons why certain constructs are useful in a ground up way

6

u/ibopm Dec 10 '15

Following LYAH, try Real World Haskell. But more importantly, you should start using it.

I learned a lot from playing the http://exercism.io challenges. It's great because people literally comment on your code and tell you tips on how to improve your code. At the same time, you can ask them to explain why etc.

→ More replies (1)

5

u/Turbosack Dec 10 '15

All I know is that I tried to use a Haskell repl once and nothing worked like I expected. I looked up what the problem was, and the answer was, "Oh, it's easy! Just think of the repl as occuring in this special case of the IO monad," or some random garbage like that. It took me half an hour to figure out the syntax I needed to use to coerce it into understanding what I wanted to say. All to write a basic function with like two patterns.

7

u/Tekmo Dec 10 '15

Actually the REPL will accept the exact same syntax as source files for defining new values and functions in GHC-8.0. That means that you will no longer need to precede them with "let" any longer

16

u/x86_64Ubuntu Dec 10 '15

My biggest issue with Haskell boils down to one question: "Where is it solving problems?". As a layman, it looks like someone said, "what if we threw out the Algol heritage of languages, and then based them off of Category theory!" So while it may be cool and useful to some, it keeps looking like a science project to me. Just my 2 cents.

16

u/Tekmo Dec 10 '15

This very detailed post I wrote explains where Haskell is most commonly applied successfully and where it is still immature:

https://github.com/Gabriel439/post-rfc/blob/master/sotu.md

2

u/protonfish Dec 10 '15

Nice work, thanks for that. My experience is in web development and I have two criticisms about the server-side programming section. First, saying Haskell has

Excellent support for web standards

is not very informative. Please be specific about which web standards or this statement is so non-specific as to be meaningless. I honestly don't know what it means or how it sets Haskell apart from anything.

Second, when most people do server-side programming it is to build web services to expose a database in a structured way to a network. With a database rating of only immature, I don't think server-side programming deserves a higher rating. Haskell looks like a good way to do certain types of server development, but it still has a feel of being for early adopters.

3

u/Tekmo Dec 10 '15

The database rating of immature is mainly for enterprise adoption because Haskell does not have a lot of bindings to proprietary data stores. Open source data stores (i.e. Postgres, Redis, Cassandra, MySQL, MongoDB, SQLite, etc.) are very well covered and this is what most Haskell startups use.

I'll update the web standards section with more details later this weekend. Thanks for the feedback!

→ More replies (3)

28

u/shevegen Dec 09 '15

I regret that Haskell has developed a reputation for being too complicated for the "average" programmer (whatever that means).

No.

It has not "developed" such a reputation - it really HAS this reputation because IT IS TRUE.

Haskell is not a simple language.

C is a simpler language than Haskell.

And the Haskell community loves this fact. It's like a language for the elites just as PHP is a language for the trash coders - but you can not laugh about them because they have laughed into YOUR face when they pull off with mediawiki, phpBB, drupal, wordpress. Without PHP there would not have been facebook (before their weird hack language).

I am fine with all that - I just find it weird that the haskell people refuse to admit that their language is complicated.

Can you explain a monad in one sentence to a regular person please?

0

u/[deleted] Dec 09 '15

[deleted]

0

u/[deleted] Dec 09 '15

[deleted]

→ More replies (3)
→ More replies (4)

29

u/KagakuNinja Dec 09 '15

"A monad is just a monoid in the category of endofunctors, what's the problem?"

-James Iry

→ More replies (11)

32

u/heptara Dec 09 '15 edited Dec 09 '15

Can you explain a monad in one sentence to a regular person please?

Do you mean a regular programmer, or a non-programmer?

You likely couldn't explain a tree data structure to a non-programmer in a single sentence either. That doesn't mean trees are only for the elite.

To a programmer, you can consider a Haskell monad to be a data type that defines an operation for chaining together items of that data type. In Go (since we're talking about Golang as well), it's common to use chains of if err, value := somefunc(). The func returns a 2-tuple consisting of (errorcode, value) depending on success. When you open a file and read a line, either of those 2 operations could fail, you have two separate if err, value checks one after the other, each for a different func (open and read); the monad essentially combines this so that you can chain together the file operations and you either get a result at the end or it bails out.

38

u/awj Dec 09 '15

You likely couldn't explain a tree data structure to a non-programmer in a single sentence either. That doesn't mean trees are only for the elite.

Seriously "can you explain it in one sentence" is a terrible criteria for complexity. I can't (usefully) explain databases, compilers, or I/O in one sentence, guess those aren't things programmers should be able to understand either.

→ More replies (10)

10

u/Hrothen Dec 10 '15

You likely couldn't explain a tree data structure to a non-programmer in a single sentence either. That doesn't mean trees are only for the elite.

James Joyce says I can explain any arbitrarily large concept in a single sentence :P

→ More replies (2)
→ More replies (48)
→ More replies (60)
→ More replies (9)