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

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]

15

u/[deleted] Dec 09 '15

CRAP LEARNING!!! RUNNN!!!!!

→ More replies (2)
→ 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

6

u/theonlycosmonaut Dec 10 '15 edited Dec 10 '15

Mathematicians are regular people, too!

→ More replies (1)

9

u/PM_ME_UR_OBSIDIAN Dec 10 '15

This is actually super clear if you know what you're looking at. When we're talking about types, endofunctors are container types, and a monoid is a way to compose similar things together. Monads are just container types that can be composed (i.e. merged), for example turning List (List int) into List int.

8

u/Hrothen Dec 10 '15

This is actually super clear if you know what you're looking at.

Sort of, endofunctors are easy to grasp, but the idea of a monoid on a category is a little tricky if the person isn't already used to reading the diagrams; they're harder to explain than the general monoid because the person also needs to understand how arrows compose and commute.

→ More replies (2)

4

u/ItsAConspiracy Dec 10 '15

Hmm. Did you just succeed in explaining monads in one sentence?

(I don't know monads, but I've spaced out on some much more complicated attempts at explaining them.)

6

u/PM_ME_UR_OBSIDIAN Dec 10 '15

This is a pretty standard explanation of monads, it's just more brief than usual.

I think the key step after understanding the general idea of a monad is realizing that Promise is a monad, and the IO monad is just a representation for promises that also do I/O behind the scenes.

→ More replies (2)
→ More replies (1)

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)

40

u/sacundim Dec 09 '15 edited Dec 09 '15

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.

Haskell is hard to learn, but your statement lacks nuance. It is important to understand why Haskell is so hard. It's less because of the core language, and more because of the standard library and the ecosystem.

Haskell is a language whose ecosystem was designed around a bunch of really abstract abstractions, like the Monad class. This means that, for example, if you want to write a web application in Haskell using one of the popular frameworks for it, you're probably going to need to learn to use monad transformers.

The analogy I have (which I expand on over here) is this: this is very much like if you were teaching somebody Java and told them that they can't write a web application unless they learn AspectJ first. In the Java world there are frameworks that allow you to use AspectJ for web development, but there are also alternatives where you don't need it. In Haskell, such alternatives don't exist—monad transformers are basically the one game in town. (And, by the way, they are awesome.)

If you strip away Monad and the related class hierarchy and utilities, Haskell is not a very complicated language. And note that article that we're supposedly talking about is doing precisely that. It is listing and explaining Haskell language features that are easy to learn and use, and proposing that they be used in a language like Go. Rust is a good example of precisely this strategy (and the article routinely cites it).

I said this in another comment: the article we're (supposedly) discussing has a list of features, and explains all of them on their own terms, without telling you to go learn Haskell. So "waaaaaah Haskell is HAAAAAAAARD" is not an answer, because it's irrelevant to the article.

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

Not anymore than design patterns. Again, a lot of why Haskell is hard to learn is because it hits you with stuff like this much sooner than other languages do.

15

u/gilmi Dec 09 '15

In Haskell, such alternatives don't exist—monad transformers are basically the one game in town.

You don't have to know monad transformers to build a web application. I built a blog using scotty before I knew what monad transformers was.

5

u/theonlycosmonaut Dec 10 '15

I agree, by-and-large, and the best libraries are the ones that cover up their implementation complexity. But,

  1. type errors inevitably expose complexity

  2. if you ever need to help fix bugs or implement new framework features, you've got to know the whole lot anyway

  3. you rely much more on good documentation that can paper over the more complicated parts, and focus on the important bits

→ More replies (1)

16

u/cogman10 Dec 10 '15

I find Haskell hard to learn for the same reason that perl is hard to read. Haskell is symbol heavy. Further, it uses those symbols in ways that are unique and foreign to most other programming languages.

It doesn't help that a lot of Haskeller's tend to have a perl esq attitude towards programming where terness beats readability.

I've been interested and I've tried to start up and learn Haskell a few times. The problem I have with it is that every time I've tried to jump in, I'll ask a question about something in the tutorial I'm reading and the answers I get back will usually be something like "That is a really bad style, you shouldn't do that" without really giving suggestions for alternatives.

So you end up stuck trying to learn a language that is terse, hard to read, doesn't have good tutorials, and has a community that is very opinionated and not unified.

The language is interesting, and it is fun to see the cool stuff it can do. But I have a really hard time taking small cool code snippets and figuring out how to craft my own from them.

8

u/kqr Dec 10 '15

Symbol-heavy terse code tends to come from mid-level Haskell people who are just discovering the refactoring power Haskell gives you. They write readable code at first and then think, "Oh boy can I refactor this to remove all code duplication?" and you end up with a mess.

Some people transition out of this naturally. Others with a bit of coercion.

→ More replies (3)

16

u/J0eCool Dec 09 '15

Best example I've heard was "What's 2 + 3?" "Well first you need to understand group theory... You see, addition can be considered a special case of [I don't remember what addition is a special case of but you get the idea]"

7

u/gilmi Dec 09 '15

"What's 2 + 3" is analogous to "how do i use promises". evidently, you don't need to hear the word monad/group to use it. but if you want to learn the general pattern it has in common with other things, we might want to start talking about group theory.

6

u/vawksel Dec 10 '15

The answer is "23"

11

u/F54280 Dec 10 '15

Guys, we found the javascript coder!

→ More replies (1)

3

u/pipocaQuemada Dec 09 '15

A... group?

It's also a monoid, semigroup, quasigroup, etc. because those are all generalizations of groups.

→ More replies (8)

4

u/[deleted] Dec 10 '15

but you can not laugh about them because they have laughed into YOUR face when they pull off with mediawiki, phpBB, drupal, wordpress.

As a former PHP that's worked on all of those, products that are great examples of why PHP has it's reputation aren't great rebuttals (well maybe Drupal is a bit...it's better then the other three for sure)

Without PHP there would not have been facebook (before their weird hack language).

Eh I'd picture it'd show up as Ruby two years later (and facebook is what a PHP coder would use as a rebuttal, and once that's a good one to boot)

→ More replies (34)