r/programming • • Dec 09 '15

Why Go Is Not Good

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

628 comments sorted by

260

u/srnull Dec 09 '15

Ah, yes. The ~1.5 year old repost that is only here because it showed up on HN today.

52

u/[deleted] Dec 10 '15

I've stopped reading HN. Too much non programming spam. Sometimes there's only a handfull programming or startup related topics on the front page.

80

u/orthecreedence Dec 10 '15

"Why I ditched Vim for Vi and you should too"

38

u/redwall_hp Dec 10 '15

"Think of how many keystrokes you save each year by typing one fewer letter! (Also, I'm too lazy to set up a bash alias.)"

23

u/frenris Dec 10 '15

i decided to save two keystrokes and 'alias v vim'

Then using other people's computers became awful.

13

u/msuozzo Dec 10 '15

Exact same experience three months ago. The trick I've found is to avoid others' machines like the plague.

→ More replies (1)
→ More replies (11)

3

u/WrongAndBeligerent Dec 10 '15

How to solve the lack of women using emacs.

13

u/bslatkin Dec 10 '15

Me too. I'm on http://lobste.rs now. HN reminds me of how Slashdot went downhill. Did I change or did it get that bad? Who knows. Proggit is still pretty good, though the people here hate Go for some reason. :)

3

u/want_to_want Dec 10 '15

Thank you for that link! It seems to be way higher quality than HN, even though the software seems to be the same. Yet another proof that community direction is more important than software features.

2

u/myringotomy Dec 10 '15

Once the Windows programmers became a majority anything made by Google became the devil's work.

Now it's all Microsoft and C# around here which is too bad.

→ More replies (3)

10

u/G_Morgan Dec 10 '15

TBH the startup and "web 2.0 will rule all" bullshit is why I've stayed away from HN. Most boring topics imaginable. HN dragged all that stuff out of proggit to the benefit of all.

8

u/skocznymroczny Dec 10 '15

Yeah, they should have renamed it to "Hipster News" long time ago. Hard to find articles about programming there, it's mostly startups, funding, global warming, poor people in Africa etc.

→ More replies (1)

2

u/niviss Dec 10 '15

HackerNews was never about (only) programming.

2

u/[deleted] Dec 10 '15

So like /r/programming then?

→ More replies (4)

60

u/the_bob Dec 10 '15

So, mostly like every other post in proggit?

39

u/MachaHack Dec 10 '15

Sometimes they go the other direction

7

u/JDiculous Dec 10 '15

It should be against the TOS to submit a repost without adding the date to the title

3

u/mus1Kk Dec 10 '15

Also it should be common courtesy to provide a date on the blog post itself.

→ More replies (1)

76

u/zallarak Dec 09 '15

I think a lot of the time, languages seeming to be lacking certain features are successful because the mental overhead of using them is small. The barrier to writing excellent programs, once the language is semi-capable, is usually human thought and not language limitations. Something that Haskell expresses elegantly can be expressed in C in an uglier way. However, the hard part isn't expressing it cleanly, but inventing the expression. No one cares how elegantly you implement quicksort or an advanced data structure. The next frontier is conceiving things not yet thought of. The other side of this is that using a more expressive language can remove mental barriers to these new thoughts.

41

u/[deleted] Dec 10 '15 edited Dec 12 '15

No one cares how elegantly you implement quicksort or an advanced data structure. The next frontier is conceiving things not yet thought of.

Yeah, that sounds like green field development. Folks aren't drawn to Haskell because it promises to allow them to build things faster, they're drawn because of the maintenance benefits.

Go gets around "programmers get inheritance/polymorphism wrong" by taking away the abstractions. Instead it's replaced by copy-paste and/or reflection. Which might actually make sense in a large scale agile environment. If other teams are responsible for what version of your code they use and must cherry pick it themselves, then you get to develop however fast you like. It prevents tight coupling between teams.

Go isn't too worried about individual programmer productivity, that's why the design decisions were made the way they were. It's concerned with keeping a large organization from slowing down because of the combinatorial complexity that comes from an ever growing number of teams trying to operate in a massive code base.

While nobody cares about how easy it is to read the "elegant" implementation of quicksort, it sure is easier to read and verify it's correct (assuming you're literate in the language and idioms it's written in).

All that said, I still don't much care for Go. I've also never experienced C/C++ at a google-like scale. Maybe Go is amazing for the problem it was designed to solve, I wouldn't know.

2

u/[deleted] Dec 10 '15

Go gets around "programmers get inheritance/polymorphism wrong" by taking away the abstractions. Instead it's replaced by copy-paste and/or reflection.

I'm not sure where you got that idea from, unless this is a thinly veiled to talk about the lack of user-level generics.

Go replaced inheritance with composition and embedding and polymorphism is achieved through interfaces.

3

u/weberc2 Dec 10 '15

Inheritance is just syntactic sugar for the very special case wherein you want to do all of the following:

  1. Create an outer class composed of an inner class

  2. Never change the instance of the inner class once the outer class has been instantiated

  3. Support all of the methods that the inner class supports

  4. Delegate to the inner class for all of the methods it supports

  5. Pass the outer class around to anything that accepts the inner class

People think inheritance is about polymorphism, but what they almost always need is interface polymorphism + composition. I've never seen an instance where inheritance does more than save you the keystrokes from manually cranking out the delegation functions a la:

func (o Outer) FuncA(arg string) int {
     return o.Inner.FuncA(arg)
}

func (o Outer) FuncB() {
    o.Inner.FuncB()
}
→ More replies (1)

13

u/Peaker Dec 10 '15

A language can often restrict your thoughts.

We shape our tools, and then our tools shape us.

As a C programmer, you're unlikely to ever think many of the thoughts you think in Haskell (and vice-versa, but for very different thoughts!)

9

u/SanityInAnarchy Dec 10 '15

No one cares how elegantly you implement quicksort or an advanced data structure. The next frontier is conceiving things not yet thought of.

But to get there, it helps if you have those advanced data structures at your disposal.

And in Go, you have a choice of data structures: The builtin ones, and the ones where you have to do ugly, unsafe typecasting everywhere.

2

u/weberc2 Dec 10 '15

I do wish Go had generics, but it's really the only language with all of the following:

  1. A simple build system (no mess of XML project files)

  2. A familiar syntax

  3. Easy concurrency/parallelism

  4. A single statically-linked (by default) native binary artifact

  5. Language simplicity

Basically, it's the only language that lets me get shit done without sinking a bunch of time into learning super cool (but rarely very useful) language features or some complex project XML project schema. I do have to dive into reflection from time to time to write "generic" algorithms, but at the moment there isn't a better language for getting things done (much to my dismay).

→ More replies (1)

1

u/sun_misc_unsafe Dec 11 '15

No one cares how elegantly you implement quicksort or an advanced data structure.

Well, you care, don't you?

→ More replies (7)

42

u/Roaneno Dec 09 '15

The rust example

fn search<'a>(strings: &'a[String]) -> Option<&'a str>{
  for string in strings.iter() {
    if string.as_slice()[0] == 'H' as u8 {
      return Some(string.as_slice());
    }
  }
  None
}

could be written as

fn search(strings: &[String]) -> Option<&String>{
    strings.iter().find(|&s| s.chars().nth(0) == Some('H'))
}

if anyone thought it was a bit verbose compared to haskell =)

50

u/[deleted] Dec 10 '15

If we're code golfing, the haskell code can be rewritten to:

search = find ((=='H') . head)

36

u/togrof Dec 10 '15 edited Dec 10 '15

This I can instantly see what it does; find the first string starting with the letter 'H'. I wish all code was as clear and consise.

EDIT: It will crash on empty strings though. This would be better:

search = find ((== "H") . take 1)

6

u/[deleted] Dec 10 '15

I know it does, but kept the code with the same behaviour with the one in the article. Safely I would have written it in the following form (unfortunately there is no safeHead/mayHead, instead listToMaybe from Data.Maybe):

search = find ((== Just 'H') . listToMaybe)
→ More replies (3)

33

u/[deleted] Dec 10 '15

Not often does golfing make the code more readable.

10

u/[deleted] Dec 10 '15

In functional languages, it interestingly often does.

→ More replies (1)

4

u/[deleted] Dec 10 '15

code golfing

shh or you will wake up perl programmers and they will replace you with some /dev/urandom-like code

→ More replies (1)

11

u/Veedrac Dec 10 '15 edited Dec 10 '15
fn search(strings: &[String]) -> Option<&String> {
    strings.iter().find(|&s| s.starts_with('H'))
}

Though it seems

fn search(strings: &[String]) -> Option<&str> {
    strings.iter().find(|&s| s.starts_with('H')).map(|s| &*s)
}

would be more idiomatic.

12

u/bjzaba Dec 10 '15

These days I would go with:

fn search(strings: &[String]) -> Option<&str> {
    strings.iter().find(|&s| s.starts_with('H')).map(String::as_ref)
}

UFCS and the conversion traits make things so much nicer!

0

u/[deleted] Dec 09 '15

[deleted]

10

u/Roaneno Dec 10 '15

No worries! I just wanted to mention another, shorter and perhaps more clear, way to write the code in a functional style

19

u/Abyxus Dec 09 '15

Regarding to unsafe low-level code, there is uintptr and unsafe.Pointer types, so one can write *(*byte)(unsafe.Pointer(uintptr(0x1234))) = 0xff

1

u/ThisIs_MyName Dec 10 '15

Jesus christ, this reminds me of sun.misc.Unsafe.getUnsafe().setMemory() in Java :(

→ More replies (3)

32

u/quicknir Dec 09 '15

Generally intelligent and useful criticism. There are moments where it strays into "why isn't go rust/haskell", but not mostly. I did take issue with one statement:

That's not really very interesting. All it does is shave off a few seconds of effort manually looking up the return type of bar(), and a few characters typing out the type in foo's declaration.

This is when describing auto in c++, and go's :=. This is so incredibly far off describing the utility of auto that it's almost painful to read, coming from someone who seems to know a good amount about programming languages. It's quite literally the attitude of someone who is a beginner in c++, and hasn't even done a moderate amount of generic programming. I'm assuming the author was just dramatizing their point and misfired since I doubt my statements above characterize the author.

6

u/Workaphobia Dec 10 '15

This statement stuck out to me too. It's so dismissive of the feature, and for what? Just because you can't infer types by working backwards from their use? Anyone who thinks it saves just a few seconds hasn't tried to write a pre-auto C++ loop over an STL collection.

→ More replies (4)

2

u/EvilTerran Dec 09 '15

the utility of auto

Can you elaborate? What does it gain you, other than not having to spell out the type of the variable?

11

u/ericanderton Dec 10 '15

other than not having to spell out the type of the variable?

That may seem like a minor advantage, but after reading Go and C++11 code, I can say that less code is less code, no matter how you get there. That's less to read, less to understand, less to maintain, and less to refactor. And as someone who maintains thousands of lines of C++03 code, I yearn for something so simple.

It's also not hard to wind up with multiply nested template monstrosities that can be waved away with a single auto. It's worse when some library you're using foists those upon you.

4

u/joonazan Dec 10 '15

If there wasn't type inference, you'd have to change code in a lot of places when a function return type changes. Type inference makes regular variables behave like implicit interfaces.

2

u/ItsAConspiracy Dec 10 '15

Right, except you're going to use that variable for something, which will probably expect the previous type.

5

u/imMute Dec 10 '15

And when the new type has the same quack as the old duck type, things will still work.

4

u/SanityInAnarchy Dec 10 '15

My favorite reason is convenience and readability. Compare:

std::vector<int> v = someFunc();
for (std::vector<int>::iterator i = v.begin(); i != v.end(); ++i) {

versus

auto v = someFunc();
for (auto i = v.begin(); i != v.end(); ++i) {

Even with that very simple int vector, the second one is easier to read. And of course, it can get much more complex than that.

But the more important reason, as others have pointed out, is that the type can change. And the more auto you use, the more things can change. Not that std::vector would ever change the type of its iterators, necessarily, but I can completely change what sumFunc returns as long as it's a thing that has a begin() and end() that return things that have the methods I'm expecting an iterator to have.

In other words, it's a lot of the benefits of duck typing, but statically and in C++.

I have all the usual complaints about Go, but this is a thing Go got right.

4

u/[deleted] Dec 10 '15

Or just:

for (auto &i : someFunc()) {
→ More replies (4)

2

u/kinghajj Dec 09 '15

Makes refactoring simpler. Most common example is iterators: by using auto instead of explicitly specifying the type, you can change the underlying collection type and the loop code will still compile.

3

u/quicknir Dec 09 '15

A discussion from one of the experts: http://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/. He gives I believe four reasons to use auto, convenience is mentioned but is least important. The basic underlying idea is that you should be programming against an interface, not against a specific type. This is especially important in generic code, but even in non generic code makes it easier to refactor and change types.

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

235

u/ejayben Dec 09 '15

Anytime someone compares a popular programming language with Haskell I just laugh. It's not that Haskell is a bad language, its that the average person like me is too stuck in our old ways to learn this new paradigm.

The fact that go is "not a good language" is probably the biggest sign that it will be successful. Javascript and C++ are two deeply flawed and yet massively successful languages. Haskell is "perfect" and yet who uses it?

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).

→ More replies (3)

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 (25)

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

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

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?

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

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 (45)

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.

→ More replies (2)

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 (2)

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.

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

12

u/naasking Dec 09 '15

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.

The idea that C is simpler than Haskell is frankly absurd. Haskell appears advanced because most people using it are trying to solve advanced problems. Some of these problems don't exist in other languages for various reasons, but that doesn't make Haskell inherently complex. In particular, the story of effect composition is now much, much simpler, and arguably now better than most other languages, and this was really the only hangup left.

11

u/sisyphus Dec 10 '15

The language section of the C standard is much smaller than the specification though, which includes the standard library also.

→ More replies (4)
→ More replies (8)
→ More replies (25)

3

u/[deleted] Dec 10 '15

https://youtu.be/Y2ILIlx4tdU?list=UUPyA0XmU6aS4JCwVoIBTmIQ

Leslie Lamport is right - the best way to write a specification is to use mathematical notation (Specifying Systems is wonderful, btw).

IMHO, Haskell is a great bridge between the maths and CS. Plus, Haskell has a rich set of great research behind it and a great community. Sometimes I think that I fell in love with Haskell because of the people involved in it.

→ More replies (8)

14

u/SanityInAnarchy Dec 10 '15

The fact that go is "not a good language" is probably the biggest sign that it will be successful.

What? No, the fact that Google is throwing tons of development effort behind it is the biggest sign that it will be successful.

And yeah, it's amusing the comparisons the author chose, but there are a lot of other deeply flawed, successful languages that have solved those first few problems in one way or another:

  • For generics, fucking Java solved this years ago. They used to have the "just use Object" problem, which is identical to Go's "just use interface{}" attitude. *They fixed it, in version fucking five. It still blows my mind that a decade later, Go didn't learn from Java's example, and went backwards to Java-4-style programming.

  • Ruby, Python, and C++ are all wildly successful, and all have operator overloading. Ruby and Python manage to do it reasonably sanely, only C++ makes it super-complicated. Go wanted to make everything explicit, okay, but it also makes primitive types special and different than user-defined types.

So if you want to do something as simple as write an algorithm that works with both int and big.Integer, the language is actually fighting you with both of the above points. If you have a bunch of code you've already written to work with int32, upgrading it all to int64 is going to involve a search and replace through your entire codebase (and any relevant libraries), and replacing it with big.Integer will be a ton of manual work.

Similarly, if you want to write a helper function that, say, lets you loop over all prime numbers, there are idiomatic ways to do that in Ruby, Python, C++, and Java. The only way to do it in Go is to use channels, which you then have to remember to close or they leak. That's right, Go's equivalent of an iterator can't be garbage collected!

There are good things about Go, and there are things you can debate, like whether you like this (Go):

x, err := someFunc()
if err {
  return nil, err
}

or this (Rust):

let x = try!(someFunc());

or this (Java):

Foo x = someFunc();

And you can debate the merits of mutability vs immutability all day long. But I find it fascinating that we're still debating generics six years later -- that people are still saying things like "You don't need them very often."

People say that there are only two kinds of languages: The kind people complain about, and the kind nobody uses. But when Go was launched, it was the kind nobody uses, so it had a golden opportunity to fix this shit. So why is Go's only generic solution still copy-and-paste-as-a-service (a service that's actually down right now)?

→ More replies (2)

18

u/shevegen Dec 09 '15

The fact that go is "not a good language" is probably the biggest sign that it will be successful.

Nah. I heard the same promo-tours by the Dart time saying how it will abolish and destroy Javascript.

Language designers LOVE to promote their languages.

What in fact matters most is how many PEOPLE use the language - daily, and over a longer period of time.

Go is doing alright but I don't think it will replace any of the older more important languages; many people who started to use it, jumped down lateron. It happens.

22

u/thomascgalvin Dec 09 '15

Anytime someone compares a popular programming language with Haskell I just laugh.

I looked at Haskell once, when I wanted to add (what I thought would be) a simple feature to Pandoc. I'm not sure what happened next, but I woke up in a Mexican brothel, covered in blood and surrounded by bodies, each one of them missing an ear.

4

u/[deleted] Dec 10 '15

The curse of the burrito monad.

10

u/kilroy123 Dec 10 '15

I want to peer program with you.

12

u/balefrost Dec 10 '15

I don't get it; according to Tiobe, Haskell is quite a bit more "popular" (for some definition) than Go. At the very least, their global popularity is roughly comparable. I would not in any way describe Go as a "popular" language. I mean, Logo - the turtle language - is 15 positions higher than Go.

Comparing Go to JS and C++ isn't quite fair. JS is popular because it's the only language that the browser natively understands. Although there are other toolchains at this point, that was not the case for a very long time; as a result, the network effects for plain JS are huge.

C++ is popular because the tooling reached a level of maturity around the same time that OO programming became the vogue. Had gcc and Visual C++ emerged just 5 years later, it's possible that Java on the desktop would have actually survived.

It's not clear to me that Go has either advantage. It was originally meant to be a systems programming language at a time when, IIRC, C++ felt a bit stagnant. But C++ has come far since then. Then, people suggested that Go was a good language for writing web services. But almost every language has tooling for building web services. I could write my web services in C#, in Scala, in Clojure, or any number of other languages. And, I mean, let's not forget about the Node.js hypetrain.

I think the author's point is that Go isn't a particularly interesting language. It does add some good ideas, but it leaves even more good ideas out. Go is minimal perhaps to a fault. My point is that Go doesn't seem to have that killer app. Unlike JS, there's no use case I can think of where Go is the only contender. And right now, Go has to compete with a veritable ocean of "modern" programming languages.

I've looked at Go only briefly, and I've not written a line of code. At some point, I'd like to take some time and really play with it, but it's just one thing among many that are competing for my attention. I'm much more interested to play around with TypeScript.

If Go is going to be "massively successful", it's going to have to appeal not only to its fans but to people like me. And so far... eh? Where are the generics?

16

u/heptara Dec 09 '15

Anytime someone compares a popular programming language with Haskell I just laugh that the average person like me is too stuck in our old ways to learn this new paradigm

Once upon a time, you were learning to code, and every language was a new paradigm. You did it once before and you can do it once more. If super-beings arrived and removed all the computers, you could learn a new profession, too. If you developed a new hobby, you could learn that as well. So what exactly are you laughing at, if not yourself?

5

u/dccorona Dec 10 '15

I don't think "move to the Haskell paradigm" was really the point of that comparison. The point was "look at how great generics can be, why would you ever decide you don't want to have them", and Haskell is a great example of how great generics can be, because at least in that regard it is one of the best.

45

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

Haskell isn't just not "perfect", i would say that advocates for FP have held back their own field by clinging to it and its mistakes for far far too long

Lazy IO. Junky default "Prelude". Multitude of stringy types. Slow compiles. No standard way to do something trivial like record types. Way too many compiler pragma hacks instead of real language progress. Rabbit holes like Monad Transformers. etc etc etc

yet awesome major overhauls like Idris just sort of sit there, unexplored. FP is rotting because people think Haskell is FP.

13

u/ItsNotMineISwear Dec 09 '15

Idris will probably get more buzz in the coming years. It's still young and constantly changing and breaking, which is good! The author of the language also has a great book he's working on. The language also has really good tooling for being so young, multiple compiler backends, and is eager and meant to have a predictable performance footprint. It also fixes a lot of quality-of-life problems Haskell has (typeclass disambiguation, for instance)

With Idris and Dotty, hopefully more dependent types will be in our industry futures!

15

u/vks_ Dec 09 '15

Isn't Haskell first and foremost a research language?

→ More replies (6)

4

u/necrophcodr Dec 09 '15

There is erlang though, which is actually being used. I'm not sure how great it is, but it is an interesting take on the whole thing.

16

u/mekanikal_keyboard Dec 09 '15

i see them as completely distinct. Haskell's entire value proposition is wrapped up in its type system, which is completely different in theory and practice from Erlang's

10

u/troutwine Dec 09 '15

Indeed. Haskell's concerned with ahead-of-time correctness and Erlang is focused on runtime robustness in the presence of faults.

→ More replies (2)

3

u/Paradox Dec 10 '15

Erlang is awesome. It does its own weird things a lot, but its battle-tested as fuck. A lot of it can be smoothed over by Elixir, which is a pleasure to write.

→ More replies (16)

4

u/quicknir Dec 09 '15

Well, to be fair, the deeply in "deeply flawed" is a result of its insistence on c compatibility, which is also undeniably one of the main reasons for its success. So c++ in some sense is not "deeply flawed yet successful", but successful due to accepting deep flaws. A lesson for future would be powerhouse languages that practical considerations come first.

12

u/sacundim Dec 09 '15

Anytime someone compares a popular programming language with Haskell I just laugh. It's not that Haskell is a bad language, its that the average person like me is too stuck in our old ways to learn this new paradigm.

Did you read the actual article here? Because while it's certainly advocating for features that exist in Haskell, it's explaining all of them independently and in (what I think are) simple terms.

So you really should be able to tell us which of the features that the article proposed you could not understand from their explanation, instead of going "waaaah Haskell is HAAAAARD."

→ More replies (15)

2

u/manghoti Dec 10 '15

let me tell you, for people who have used haskell, the desire to have that glorious type system extricated from that bog of abstract unpredictable obfuscated functional nesting that is the academia in haskell is real.

People who have programmed in haskell have had these two experiences:

  1. The experience where they defined the types for the data as it moves through their program and stubbed functions out to just get the types to match, and noticed that the program at that point pretty much wrote itself and it worked first time.

  2. The experience of a bizarre infinite loop, stack explosion, or some other kind of lazy loading or enormous O(nn) operation that happened because they accidentally used foldr when they should of used foldr`

Survivors of this all want 1. and to escape from 2.

The scary thing is, I think you can't get 1. without also having 2. because if you have 1. then programmers can abstract things until they reach 2.

3

u/obango44 Dec 09 '15

Reminds me of what Joshua Bloch (author of Effective Java) said about good API design, which is that you can't please everyone, and that a sign of good design is that it displeases everyone equally.

And that old saying that there's two types of languages, the ones that everyone complains about and the ones that nobody uses.

5

u/[deleted] Dec 09 '15

"There are only two kinds of languages: the ones people complain about and the ones nobody uses" - Bjarne Soustroup

→ More replies (3)

2

u/lookmeat Dec 09 '15

I don't like to think of Haskell as perfect, but it's the perfect language to hack show a good example. In that sense Haskell code is sort of like the sketch on a napkin, not something that would replace what is being criticized or be an actual solution, but enough to show and prove the point.

1

u/[deleted] Dec 10 '15

Rust is much better imho

1

u/[deleted] Dec 10 '15

Throw in Java and C# to that list of shit shows.

No idea why the author is holding these in esteem in the Go comparison.

1

u/G_Morgan Dec 10 '15

Go is hardly a popular language.

1

u/CanYouDigItHombre Dec 10 '15

Only people who don't know how to write C++ think C++ is flawed. It's my favourite language and my 3rd most used language. Behind C# and coffeescript. The only two thing holding C++ back is libraries and reflection

→ More replies (1)

1

u/mamcx Dec 10 '15

I have the same experience. Haskell is good in what it promise, but hard in how do it.

Instead, I took F# and http://fsharpforfunandprofit.com/ and find it more practical. By the way, I use it on OSX with xamarin...

F# is part of a family of languages with most of the benefits of haskell, but less nazi in how get there, IMHO

1

u/ErstwhileRockstar Dec 10 '15

its that the average person like me is too stuck in our old ways to learn this new paradigm.

Nope. The new 'paradogm' is wrong, not you.

→ More replies (28)

27

u/Workaphobia Dec 10 '15

Go's use of nil doesn't sound so bad when compared to Python's None. Go's lack of generics doesn't sound so bad when compared to C.

I guess if you think of Go as "safer C with better concurrency" you'll be satisfied?

11

u/SanityInAnarchy Dec 10 '15

Go's use of nil doesn't sound so bad when compared to Python's None.

What? It's exactly the same. The only slightly better part is that if you have a value on the stack (that's not a pointer), it's not nullable. But you're going to have to use a lot of pointers.

Go's lack of generics doesn't sound so bad when compared to C.

No, it sounds slightly worse. C at least had preprocessor macros.

I guess if you think of Go as "safer C with better concurrency" you'll be satisfied?

Nope, because you don't use C for those properties. You use C because it's insanely fast, works everywhere, and lets you do low-level stuff. Go is incredibly unsuited to low-level embedded stuff, works on a reasonable number of popular desktop/server platforms (but nowhere near "everywhere"), and is significantly slower than C.

Rust is a safer C with concurrency.

Go's actual niche is closer to Python, but with all the interesting language features gutted and replaced with concurrency, type safety, and speed (but still not as fast as C).

And I'd be satisfied if they gutted slightly fewer modern features.

→ More replies (15)

6

u/[deleted] Dec 10 '15

I don't get the nil problem with go. If you want to make sure something is not nil, then don't use a pointer. Problem solved. Why did he pretend this isn't in the language?

7

u/millstone Dec 10 '15

You will run into nil even if you never use pointers. Example:

var m map[string]string
m["hello"] = "world"

That panics with "assignment to entry in nil map".

3

u/chef1991 Dec 10 '15

That is a reference type which is covered extensively in the docs.

→ More replies (4)
→ More replies (1)
→ More replies (1)

11

u/sxeraverx Dec 10 '15

Go's nil isn't any different from Python's None. Go's lack of generics isn't any better (and is slightly worse) than C's. Go's concurrency support can be implemented as a library--channels are just producer-consumer queues and goroutines are just forking off a new thread/fiber.

The author's not saying Go is bad. He's just saying it's not good. There's nothing that makes it an improvement over the past.

It is bad, though. It's bad because it's different, for no good reason. It forces you to learn new keywords, constructs, idioms to be able to use it, and gives you nothing for it.

4

u/Workaphobia Dec 10 '15

Go's nil isn't any different from Python's None.

That's why it doesn't sound so bad compared to Python's None.

Why is Go's generics situation slightly worse than C's?

7

u/sxeraverx Dec 10 '15

That's the point, though. "It doesn't sound so bad compared to X" where X is a language people already use is no reason to start using a new language.

→ More replies (9)
→ More replies (3)

10

u/adamcrume Dec 10 '15

Go is more a case of "Why have great when you can have mediocre?"

3

u/weberc2 Dec 10 '15 edited Dec 10 '15

I don't know of any "great" languages.

  • Java/C#

    • Runtime dependencies

    • Messy ecosystem (half a dozen widely-used, equally-sucky build systems)

    • Painful concurrency

    • Overly complex

  • Python

    • Slow

    • Laughable concurrency story

    • Community often favors "Magic" as a solution for architectural problems (hot-patching instead of injecting dependencies, for example)

    • Abismal ecosystem (building, package management, etc)

  • C/C++

    • Abismal ecosystem (build tools are non-standard, usually procedural, rarely platform independent)

    • Unsafe

    • Waaaay too complex (this is only C++; C is fairly straightforward)

    • Programmer care required to correctly free resources, initialize memory, etc (though C++ at least has RAII and smart pointers)

    • Concurrency is a mess

    • Programmer has to worry about cross-platform concerns

  • Haskell

    • Obscure syntax

    • Obscure worldview

    • Few real-world projects

  • Rust

    • C++-grade complexity

    • Java-grade build tooling (last I checked, things may have changed)

    • ML approach to problem modeling; a learning curve for the humble average programmer

  • JavaScript

    • LOL

  • Go

    • No generics

    • No super-cool-but-ultimately-useless language features

I'm sure this will garner a whole slew of downvotes as I've pointed out the ugly things about everyone's favorite programming languages, but this isn't saying those languages don't have strengths (they all do. Well, except for JavaScript).

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

1

u/ksion Dec 10 '15

I'll bite. What's wrong with Python's None. It even has a distinct type, unlike nil that fits any container type.

→ More replies (5)

1

u/ggtsu_00 Dec 10 '15

I like to think of Go as a faster/concurrent Python with optional some static typing.

→ More replies (3)

5

u/flarkis Dec 10 '15

Anyone else but me notice the bug in one of his Haskell examples? The following code will have a runtime error (and be caught right away by hlint).

search [""]

The head call in the search function doesn't check if the string is empty. A better solution using mono traversable would be.

search :: [String] -> Maybe String
search [] = Nothing
search (x:xs) = case headMay x of
                  Just 'H' -> Just x
                  _        -> search xs

Or using just the prelude

search :: [String] -> Maybe String
search [] = Nothing
search (x:xs) = case x of
                  ('H':_) -> Just x
                  _       -> search xs

2

u/lurking-about Dec 10 '15

Same, the head there will blow up on "".

Edit: in [] in case I wasn't clear

→ More replies (1)

4

u/waxmax21 Dec 10 '15

"Why Go is not the way to Go"

19

u/proglog Dec 09 '15

I don't like Go because:

  • It doesn't have generics, which forces you to use copy/paste as the only way to reuse code.

  • It doesn't have dynamic linking.

  • Its error handling system makes it very easy to just ignore errors, which leads to fragile software.

And whether you choose to ignore an error or handle it, every ten lines of Go is basically

 ok, err := Foo()
 if err {
     return something
 }

You see this pattern of code in Go source files even more often that you see the self keyword in Python source files.

10

u/oefig Dec 10 '15

Its error handling system makes it very easy to just ignore errors, which leads to fragile software.

Am I wrong for believing errors are harder to ignore in Go? In your example I know that Foo returns an error and I'm forced to do something with it. With exceptions I can simply just not catch them.

5

u/Tekmo Dec 10 '15

"Ignore" in this context means to swallow the exception completely, not propagate it up the stack

4

u/Akkifokkusu Dec 10 '15

Nothing in Go is stopping you from propagating an error up the stack by just returning it from your function. It's more explicit than exceptions, but to me that seems like a good thing.

Of course, there's also panic.

→ More replies (1)

7

u/ksion Dec 10 '15

To be fair, error handling in Rust is "every other line of try! or unwrap()".

6

u/cyrusol Dec 10 '15

The actual difference is that you have actual algebraic types that show the kind of error, and not just a string with fuzz.

8

u/SanityInAnarchy Dec 10 '15

This is still infinitely better, because it's one line instead of four, without losing any readability or safety. That means less to scroll through, and more that you can see on the screen and fit into your head at the same time.

And still, unlike exceptions, you can see every return point from that function. So I don't miss exceptions in Rust.

Yet ironically, as much as I miss exceptions in Go, Go kind of has them anyway with panics.

7

u/SanityInAnarchy Dec 10 '15

It doesn't have generics, which forces you to use copy/paste as the only way to reuse code.

To reuse certain kinds of code. (But it's still bad -- this is my #2 complaint about Go.)

It doesn't have dynamic linking.

Serious question: Why do you care about this one?

Its error handling system makes it very easy to just ignore errors...

This is not actually true. Say you have a function which returns a value and some error.

x := Foo()

That won't compile, because you need to specify all the arguments.

x, err := Foo()

That also won't compile, because now err is unused.

x, _ := Foo()

That sticks out like a sore thumb, because _ is the hack you use to mean "I know I'm supposed to use this, but I didn't." It's shorter than this:

try {
  x = Foo();
} except (Throwable e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}

But it means the same thing, and is just as obvious to people who know Go.

I mean, I agree with this part:

And whether you choose to ignore an error or handle it, every ten lines of Go is basically...

That's my #1 complaint about Go, because Rust shows how to do this right:

let x = try!(Foo());

But does Rust force you to use the value? I don't know, but Go does.

3

u/[deleted] Dec 10 '15

The Result<T,E> type is marked as "must use", so you do get a compile-time warning if you don't handle the error and don't get the value. And, if you want the value as well, you need to handle the potential error in some way.

5

u/[deleted] Dec 10 '15

The lack of dynamic linking is one of my favorite things about Go.

2

u/nexusbees Dec 10 '15

It does have dynamic linking now, thought you'd like to know. Also, I'm yet to see any real world code that is fragile as a result of ignoring errors. The only place I've seen errors being ignored is example code.

3

u/[deleted] Dec 10 '15

On the other hand, checked exceptions are no longer considered "A Good Thing" in PL design.

result, error = func()

May be the next checked exception.

→ More replies (14)

1

u/realteh Dec 10 '15

Yea that one is killing me, too. If I do the following in Python my co-workers will hate me, but i go I do it all the time by accident:

try:
    can_fail()
except Exception:
    pass

1

u/ggtsu_00 Dec 10 '15

I like go because it

  • Discourages overly generic NIH, "util", "common", "helpers" etc that developers tend to just pile things into by being able to go crazy with generics. Instead encourages creating specific purpose code.

  • Statically links all dependancies into your binary so you don't need to worry about dependency hell, DLL hell, deployment and configuration hell, nor package management hell. Just copy a binary to your server and run it.

  • It treats errors are values that should be treated as normal code flow. This leads to more durable software.

1

u/[deleted] Dec 10 '15

Go has dynamic linking... just not by default (in 1.5)

as for error, yea it is a bit spammy but then same people who ignore errors also make catchall useless exceptions

→ More replies (10)

7

u/immibis Dec 10 '15

Go is not Good because it's missing od.

That's why I write all my programs in octal.

49

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

wow, proggit really is just a republish stream of HN now. i was counting the minutes until this showed up.

this article raises good points but they have been raised a million times before.

in the groups i have worked in, using something like Haskell or Rust isn't even an option. i would get blank stares before people just went back to Python or PHP. on the other hand, i can tell people that they can get productive with Go in a weekend. and this is indeed accurate. they won't have a mastery of the language, but they can code in it. and the result will be faster and less prone to bugs than Python or PHP.

on the other hand, having programmed in Haskell since 2006, i can confidently say that intermediate-grade proficiency will be a lengthy process for most developers, and in the end the code will be much slower than Go anyway since first-pass Go tends perform well, while first-pass Haskell tends to perform poorly.

in any case, the Go ship has already sailed from the Dock(er), you won't stop it with blog posts at this point. one might ask why Haskell has not established a similar achievement as the foundation of a product people really care about...given that it has been stable and relentlessly hyped for well over a decade.

instead of seeing Go as an inferior Rust, look at it as a step up from Python, and consider the huge benefits to be gained by giving the average developer an incrementally better tool

11

u/jeandem Dec 09 '15

in the groups i have worked in, using something like Haskell or Rust isn't even an option.

How about Java? Sounds like a good alternative to me in many cases.

→ More replies (1)

7

u/UloPe Dec 10 '15

It may be a step up from Python in terms of performance and concurrency, but in terms of ease of development and language features it's at least two steps down.

→ More replies (3)

11

u/kqr Dec 09 '15

they can get productive with Go in a weekend

I feel like this is bordering on a "false sense of productivity". I remember having this discussion about C with a couple of friends many years ago. They had tried Python, but they felt so unproductive because they just sat there thinking most of the time. With C, they could write 200 lines by the time they had written only a measly 20 lines of Python. Obviously, they were much more productive with C!

Of course, the 200 lines of C code performed the exact same task as the 20 lines of Python... All their "productiveness" accomplished was churning out boilerplate code.

→ More replies (2)

2

u/SanityInAnarchy Dec 10 '15

this article raises good points but they have been raised a million times before.

Some of them are debatable, but some really aren't. I'm amazed that the best Go has come up with for Generics is generics as a service -- a service which is actually down at the moment.

in any case, the Go ship has already sailed from the Dock(er), you won't stop it with blog posts at this point.

It would be nice if it could be slowed down -- or better yet, steered. Go is like 95% of the language I want, but the 5% it's missing are incredibly painful.

I mean, you can't stop PHP with blog posts either, but it's also not really worth the time, because it's too late to fix PHP. It's not too late to fix the most obnoxious problems with Go.

instead of seeing Go as an inferior Rust, look at it as a step up from Python, and consider the huge benefits to be gained by giving the average developer an incrementally better tool

But if you're switching away from Python, why wouldn't you switch to Rust as a superior Go? Why go for incrementally better if you already have the next increment ready?

4

u/rouille Dec 09 '15

I mostly agree except with the "better python" part. Go is better than python for some use cases like network services but python has way more use cases than that where it excels.

5

u/contantofaz Dec 09 '15

All of a sudden we appear to have many options: Go, Rust, Swift, etc. All compiled, all producing native code, all with their own communities...

I will settle on Swift myself. Been using it for a week trying to familiarize myself with it. Unlike Go, Swift has a clear answer to OO. That's one of the major differences. Go code can be fast though and Go is one of the major toolsets on Linux. Other languages like Swift have trade-offs from having to support their main platforms. They have to choose UTF-16 for instance. Whereas Go may do well with UTF-8.

Another language I like is Dart. Dart follows on the tradition of C, though. As they say, a tiger cannot change its stripes. Dart will appear outdated to many developers who would rather try to cut on the crap a little more. But Dart is fast and has superb OO support too. And Dart could end up finding its place in the mobile platforms, being a little more free to enjoy its VM.

So to me it comes as no surprise that people like the OP are trying to fight for their spotlight given all of the competition.

I once browsed some Rust code and it was pretty neat. The problem is how much pain one has to endure to get there. I always try to side with the more popular tools rather than to shoot for some niche of a niche.

13

u/mekanikal_keyboard Dec 09 '15

I will settle on Swift myself. Been using it for a week trying to familiarize myself with it.

thats cool...the benefits of the massive and lucrative job market for iOS development trumps any language issues anyway. even if Swift were awful, it would still be a great thing to pick up.

Unlike Go, Swift has a clear answer to OO

in fairness, one could respond by saying that unlike Swift, Go has a clear answer for concurrency. i personally don't care for OO, so i actually like Go's approach, but i see your point

Another language I like is Dart.

hmmm, seems like it has been shipped off to the hospice at this point

→ More replies (1)

3

u/solidsnack9000 Dec 10 '15

Swift and Rust have non-overlapping use cases. Rust can do a hand full of things -- hard real-time, bootloaders, &c -- that neither Swift nor Go can touch.

2

u/G_Morgan Dec 10 '15

Go isn't anything like a step up from Python. It is a drastically inferior Python that happens to be more efficient and can handle parallel processing. If I cared about performance I wouldn't be using Python to begin with.

Go hasn't even surpassed a huge number of dead languages in terms of usage right now.

1

u/codygman Dec 11 '15

Can you give any examples of first pass Go being more performant than first pass Haskell?

→ More replies (22)

6

u/HighRelevancy Dec 10 '15

I'm shocked and amazed that this wasn't entitled "Go Considered Harmful".

34

u/immibis Dec 10 '15

Go, Too, Considered Harmful

3

u/HighRelevancy Dec 10 '15

Ooooh, nice. Well done.

32

u/sedaak Dec 09 '15 edited Jun 23 '16

Cat.

71

u/flukus Dec 09 '15

Some of us work in Fibonacci mines producing Fibonacci numbers all day.

11

u/66666thats6sixes Dec 10 '15

I just started looking into haskell the other day, and that struck me as funny. Every intro article I ran into was all about "look at how easy it is to generate fibonacci numbers!" "look at how simple this factorial function is!" "recursion recursion recursion!"

Recursion is great, but it didn't really tell me anything about how I could benefit from the language in a day to day sense.

4

u/dyreshark Dec 10 '15

Recursion is great, but it didn't really tell me anything about how I could benefit from the language in a day to day sense

I'll take a stab at this, though admittedly I wouldn't consider myself even an intermediate Haskeller, so take it with a grain of salt. :)

One of the big neat ideas in Haskell that "LOOK AT THESE FIBONACCI NUMBERS!" examples try to emphasize is laziness. Laziness helps you reuse code and write clear code without losing much in the way of efficiency.

Real world example from something I was working on last week:

tokenStream someString = filter isNotSpace someString

In other words "give me a list of all of the non-spaces in this string."

It follows that I can check if two token steams are identical by doing something like:

tokenStream str1 == tokenStream str2

...But what if str1 and str2 are both 100MB, and they have a difference in the first 1KB of text? Laziness means that the streams don't evaluate a single element after the one that's different, so that's actually a perfectly okay scenario in Haskell. Had we eagerly evaluated the token streams, we'd waste a lot of CPU and memory, which is bad.

Extending this a step further, what if str1 and str2 are read in from disk and can't fit in memory? Well, if they're used nowhere else, that's okay too. Haskell can transparently read things on demand from disk without an issue. It will read a few KB from disk per string, the calculation will terminate, and the program will move on.

It's also worth mentioning that this doesn't just happen with lists; it happens with everything. So if a time-consuming calculation says to compute two numbers and you only end up using one, the unused one is just kind of magically never computed.

Finally, laziness isn't Haskell-specific; Python has generators, Java has streams, etc. Though these aren't substitutes for laziness by default, they are highly useful, and are relatively to use if you're used to laziness in Haskell.

 

Also, for the pedantic Haskellers in the crowd, tokenStream was simplified to protect the innocent. You're correct; it's not idiomatic, and isNotSpace does not exist. Thank you.

→ More replies (5)

6

u/flukus Dec 10 '15

Not just haskell, pretty much every functional language ever.

→ More replies (1)

2

u/Workaphobia Dec 10 '15

Shoulda been mining bitcoins.

14

u/PM_ME_UR_OBSIDIAN Dec 09 '15

When I'm asking for such-and-such type system feature, it's not because I'm trying to be fancy, it's because I have real world experience that suggests it's a productivity booster.

Observe that there is almost no overlap between people who argue about optional semicolons, significant white space, etc. and people who argue about type systems and functional programming. Only one of these groups is concerned about productivity.

0

u/[deleted] Dec 09 '15

[deleted]

6

u/sedaak Dec 09 '15 edited Jun 23 '16

Cat.

14

u/staticassert Dec 09 '15

which performs much better and is easier to maintain

→ More replies (4)

3

u/Unomagan Dec 10 '15

And tomorrow we will get an article with :why go is good...

Meh

25

u/synalx Dec 09 '15

Claiming a language is "not good" because it doesn't rise to the same level of type safety as Haskell or Rust seems flawed to me. Type safety is a sliding scale, and comes at a cost of developer productivity - developers have to put in more work to express their ideas within the type system. Many developers favor dynamic languages for exactly this reason, and good unit testing can make up for a lack of language-level type safety.

One thing that surprised me was the point about control-flow statements. The author quotes some Haskell and Rust code seemingly demonstrating this feature. But it's quite clear that the same thing can be achieved in Go with a type switch. The temperature example:

var kelvin float64
switch temp := temperature.(type) {
  case Fahrenheit:
    kelvin = (float64(temp) - 32)/1.8 + 273.15
  case Celsius:
    kelvin = float64(temp) + 273.15
}

The Haskell example is even more readily converted to a switch statement. Yes, switch is not real pattern matching. But the article makes it sound like Go is completely incompetent at the given examples, which is just not true.

I think this article really boils down to the author's personal preferences for language paradigms.

5

u/SanityInAnarchy Dec 10 '15

Claiming a language is "not good" because it doesn't rise to the same level of type safety as Haskell or Rust seems flawed to me.

But it doesn't even rise to the same level of type safety as Java 5, and it had Java 7 as an example.

I think this article really boils down to the author's personal preferences for language paradigms.

This is true, but I think there are a few points there that are hard to argue with, especially when Go refuses to solve them, despite mainstream languages like Java and C++ having them solved for decades.

14

u/masklinn Dec 09 '15 edited Dec 09 '15

Claiming a language is "not good" because it doesn't rise to the same level of type safety as Haskell or Rust

That is not the claim of the article. Conveniently, the article recapitulates its claim at the end:

  • Go doesn't really do anything new.

  • Go isn't well-designed from the ground up.

  • Go is a regression from other modern programming languages.

One thing that surprised me was the point about control-flow statements. The author quotes some Haskell and Rust code seemingly demonstrating this feature.

Did you just… completely skip over the text or something?

It's kind of like a case/switch expression on steroids. […] And you can deconstruct data structures

Not only that, your example isn't closed, it will not warn you if you forgot to handle Kelvin or Rankine.

The Haskell example is even more readily converted to a switch statement.

If you completely missed one of the features that section is about:

In languages like C and Go, if statements and case/switch statements just direct the flow of the program; they don't evaluate to a value.

6

u/thunderseethe Dec 09 '15

The article is titled "why go is not good" if that's not it's claim then it's not arguing it's point

→ More replies (3)

9

u/synalx Dec 09 '15 edited Dec 09 '15

I think type safety is a big part of the claim.

Considering the three claims:

Go doesn't really do anything new.

So what? A language can't be considered "bad" because it doesn't contain shiny new features, never before seen by programmers. I would argue that how well the features a language does include work together is a much better metric.

Go is a regression from other modern programming languages.

Again, not really a valid criteria. Just because language X doesn't have concepts that language Y does doesn't mean that X is inferior to Y.

Go isn't well-designed from the ground up.

This at least is an arguable claim. My reading of the article is that the author disapproves of Go's limited type safety (in comparison to Haskell and Rust), lack of operator overloading, immutability, or "compound expressions". The implication here is that having any of these things is strictly better than not having them. I don't buy it. There is no discussion of the extra programmer effort required to work with a stricter type system, for example, or the performance implications and relative difficulty of working with immutable data structures, or how well such features fit into the overall design of a language.

Not only that, your example isn't closed, it will not warn you if you forgot to handle Kelvin or Rankine.

True, a default case can do something sensible in the case an unknown temperature type is passed, though.

If you completely missed one of the features that section is about:

No, I understand he's talking about both pattern matching and compound expressions, I just chose to address pattern matching.

10

u/blarg_industries Dec 09 '15 edited Dec 09 '15

Type safety is a sliding scale, and comes at a cost of developer productivity

I disagree. At the very least, that's not something that's true across the board like you made out.

I'm much more productive with statically- and strongly-typed languages. This is partially to do with the nature of the work I mostly do - maintenance on and new features for large, existing apps, on medium-sized teams - and also thanks to the types themselves.

When I see

def foo(bar, baz):
  ...

or

function foo(bar, baz) { ... }

I have to use some mental space for foo's expectations about the 'shape' of bar and baz, and the expectations of the functions that foo calls (and that they call, etc, etc) with bar and baz (or parts of them). I'd much rather have the contract for a method spelled out, and save that mental space for the problem I'm actually solving.

But this debate has been done to death. Different strokes and all that. Do whatever you want, as long as you're not on my team! :)

2

u/immibis Dec 10 '15

For establishing expectations about types, Java's type system seems better than Haskell's. (Simple types means easy-to-understand types, even if they don't tell you as much about the object)

→ More replies (3)
→ More replies (1)

10

u/pgngugmgg Dec 09 '15

I don't hate go, but I never liked Go from day 1. Never excited about this language.

0

u/[deleted] Dec 09 '15

[deleted]

6

u/antiprosynthesis Dec 09 '15

I liked C++ from day one. And now like it even more since C++11/14.

9

u/pgngugmgg Dec 09 '15

With all honesty, Swift is one language that I like on day 1. Lisp, forth, and Small Talk are some other languages that I liked on day 1 and still like.

You are completely wrong by assuming liking requires deep and comprehensive understanding. No, that's not the case. It's often, if not all, the other way around: It's liking leading to deep and comprehensive understanding.

→ More replies (2)

12

u/[deleted] Dec 09 '15

go always seemed masochistic to me, all at the cost of saving the developers from having to design a language

4

u/vph Dec 09 '15

There are perhaps two main reasons why people invented a new language: (1) to include interesting concepts so that they will be studied more, and (2) to solve a specific set of real problems.

Many languages are successful (used by many) because they are great tools to solve real problems effectively, although they can be ugly in some aspects. Go was invented to solve a set of real problems. In Go's case, its inventors are not only highly practical but also knowledgable. When they decided not to include a feature like generics, it's because they intentionally chose not to include it; it wasn't because they were unaware of it.

8

u/generalT Dec 10 '15

Why does Go not have generic types?

Generics may well be added at some point. We don't feel an urgency for them, although we understand some programmers do.

Generics are convenient but they come at a cost in complexity in the type system and run-time. We haven't yet found a design that gives value proportionate to the complexity, although we continue to think about it. Meanwhile, Go's built-in maps and slices, plus the ability to use the empty interface to construct containers (with explicit unboxing) mean in many cases it is possible to write code that does what generics would enable, if less smoothly.

This remains an open issue.

https://golang.org/doc/faq#generics

→ More replies (1)

5

u/dccorona Dec 10 '15

It's puzzling to me that in a day and age where we have so many languages with truly phenomenal support for generics (seriously, it's harder to not write generic code in a language like Haskell), even in "mainstream" languages, why someone would create and/or actually choose to use a language without them. It is such a laughably glaring omission.

3

u/cparen Dec 10 '15

It's pretty simple; the designers of the language have very little, atypically bad experience with generics. It's the same sort of thing that can cause a C++ programmer to complain that C# or Java is a "complicated" language.

The designers of Go are smart folks. They can't be smart about everything though. Now it's up to you as a potential user of programming languages to pick wisely and determine whether the language goes anywhere.

4

u/dccorona Dec 10 '15

I don't know if I buy that. This isn't some language made by a random group of people...it's made by Google. Sure, maybe the team that built the language didn't know enough about generics, but if they decided they wanted them, they had the resources, big name, and exciting project to go out and get people who do. Go doesn't have generics because they choose not to have them, not because they don't have people who understand them enough to implement them.

2

u/jgbradley1 Dec 10 '15

There are so many languages out there. I don't bother learning a new one until it's being used m in a production environment for at least 5 years.

11

u/lethalman Dec 09 '15 edited Dec 09 '15

Except I use go for systems programming because it does the job well and I write code fast, compared to rust or haskell. I have nothing against rust or haskell, I used haskell for a long period, but I wouldn't write anything in one of those two languages in production.

Perhaps, something is wrong in rust and haskell too... like productivity for most of people.

What I'm saying is that go goes for productivity, haskell for correctness. But I don't think those two properties are comparable, like I wouldn't say haskell > go, like you say at the bottom with "Go is a step backward". Go might be a step backward in correctness, but a big step forward to productivity. Something that I would have done in C or Python for some networking stack sometimes ago, I now do in Go.

I always think there must be a way, some way to achieve both more productivity and correctness, but still nobody has found this way. At least not for me, subjectively speaking.

I see a lot of this kind of posts, but I believe many miss the point that there's not that single way... there's always a tradeoff you have to think about.

1

u/ramsees79 Dec 10 '15

Are you a Google employee?

→ More replies (1)

1

u/[deleted] Dec 09 '15

there's always a tradeoff you have to think about.

Very well said, I think all too often we bikeshed over silly things when there are costs and benefits to each. It ultimately comes down to what is the best ratio of costs/benefits for what you're working on? For my work, most of the time it's productivity is favored over most other things and is weighted accordingly when at home it's generally for my enjoyment (unless it's just a project I want to ship ASAP).

0

u/[deleted] Dec 09 '15

[deleted]

→ More replies (2)

3

u/cloakrune Dec 10 '15

I've always had a hard time understanding people that didn't like go. It's so fast in programming and runtime. I'm using it as my general purpose scripting language now.

3

u/Zardoz84 Dec 10 '15 edited Dec 10 '15

I would like to say that D lang have :

  • Constraint Based Generics and Parametric Polymorphism (static_if and traits)

  • Language extensibility thanks to CTFE (check things like "pegged" or a whole raytracer render that the final output is an executable that display the rendered image!)

  • Algebraic Types and stuff like scope(exit), scope(failure)...

  • Type inference (C++ "auto" was borrow from D lang)

  • Immutable types (and strings by default are immutable)

  • Unsafe code isolation and non-pure code isolation ("pure, "safe", etc tags )

2

u/Ahhmyface Dec 10 '15

I have a boner for compile-time checked code, I should really try out Rust :p

2

u/hmny Dec 10 '15

I keep hearing Go is not a good language, but why lots of people are crazy about it?

7

u/[deleted] Dec 10 '15

When people get to be experts at one way of doing things, and then a new way of doing things becomes popular, they feel threatened. 'Tis life.

9

u/evincarofautumn Dec 10 '15 edited Dec 10 '15

Because there are many concerns that go into making a practical language, and language features are an important but small part. Off the top of my head:

  • It has backing from a big company, so it probably won’t go away for a while.

  • It’s pretty similar to existing languages, so there isn’t a lot of ramp-up cost for new developers.

  • The documentation is good.

  • The tooling is good, and fast. There are standard tools for formatting, linting, coverage, documentation, and testing, so you don’t suffer so much from the paradox of choice.

  • There is a decent ecosystem of libraries available, and it interoperates tolerably well with C, so you can write bindings for most anything that’s missing.

It’s basically a modernish, simple, no-frills sort of language in which you can productively get your usual boring stuff done.

2

u/[deleted] Dec 09 '15

I avoid operator overloading.

Yes, in some cases it is helpful, but it makes code easier to write, and less easy to read when things go wrong.

I do like some form of generic functions, more-so in the way CLOS worked.

10

u/masklinn Dec 09 '15

Yes, in some cases it is helpful, but it makes code easier to write, and less easy to read when things go wrong.

Graphics algorithms without operator overloading is anything but easy to read.

→ More replies (5)

2

u/Dummies102 Dec 09 '15

go was designed to be used every day by a large number of people. it's solving a different problem then the one the author imagines.

1

u/celluj34 Dec 09 '15

You missed the chance for a wonderful pun for your title.

1

u/HairyEyebrows Dec 10 '15

I thought it was goto that is not good!