Live data from Hacker News

Why Go gets criticized so much

npf.io

221–230 of 251 posts

Re: Why Go gets criticized so much

#221
post #185

Earlier quoted context omitted.

"Passing up the stack" is fairly minimalistic in an environment where you could be running thousands of goroutines, some (many?) of which may share memory. If you do it that way, you seem to forego a lot of error encapsulation straight away and quickly find yourself into undefined territory.

doesn't matter whether no goroutines or thousands - you either handle errors or pass upwards. Anyhoo, just pointing out that it has the flexibility to do either.

mononcqc is pointing out that those aren't the only options: other error-handling mechanisms exist. The options are not either "handle the error right now" or "make the caller handle the error".

In fact, in go those aren't even the only options, since you can pass an error object up the stack using panic/recover.

An alternative model could have error handlers registered somewhere and be invoked at the point the error occurs, either choosing to pass control to another part of the program, or resolve the issue and continue processing. That could, of course, be implemented in vanilla Go, but then everything has to agree to do that.

Some systems are able to distinguish the point where you recover from an error from the point where you report an error: e.g. a batch processing system may recover from an error by skipping an item to be processed (and perhaps storing it in a list of failed items to be inspected later) and another "catch" handler further up may decide whether and how to display a diagnostic about the issue. Of course, this logic could be embodied as a "reporting" object which is passed down to the batch processing algorithm, but hooking into the exception handling logic means that you can use the existing error-reporting infrastructure.

Common Lisp has a system of "restarts" where one can configure multiple ways for a handler to respond to errors other than simply passing it up or carrying on. For example, a batch processing system might set up restarts to allow items to be skipped, retried now, or retried after the batch finishes. The batch processor itself might have restarts for retrying the batch or rescheduling it on another node. Above the batch processing algorithm, an exception handler can look at the situation from a high level and decide what to do: e.g. it may determine that the batch has grown too big for the node and reschedule it on another one.

Until the decision is made, the stack is not unwound, so if I decide to restart an item from the batch, I just jump right back into the still-running batch processing function. This design allows the mechanism for how to actually deal with an error condition to be separated from the decision as to which mechanism to use. It's very much like breaking into a debugger, except the program can debug itself.

In Erlang, a program handles errors by keeling over, dead. Because an Erlang system is (meant to be) designed as a swarm of cooperating processes, an individual process can just die when something goes badly wrong and its compadres are expected to have registered an interest in knowing that this has happened. A common design pattern is to have a dedicated monitoring handling process which knows how to orchestrate things so that one broken process doesn't cause a cascading failure through the whole system.

In the running example, a batch processing system might spawn a process for each batch, and a monitor process might check for batches which die and then decide whether and where to restart them.

That said, Erlang still has a fairly traditional try/catch system for when that makes more sense. And errors are objects, so you can return them up the call stack as well.

There are many more mechanisms for error handling which aren't simply "handle here or pass up".

Re: Why Go gets criticized so much

#222
post #208

Earlier quoted context omitted.

In math, answers are made by questions. In life, the quality of your answers is determined by the quality of your questions. So make a concrete question based in reality if you want a specific, real answer that you can confirm against proof.

Wow, you did all that nature analogy to say that the misunderstanding lies in the question and not in the answers?

That's incorrect. I was talking about your useless "What??"

Re: Why Go gets criticized so much

#223

Earlier quoted context omitted.

The reason Google's Java codebase is impossible to understand is not the language, it's mindless application of 'best practices' like dependency injection on an industrial scale. Guice is open source, anyone can go look at it. Just imagine a big complex server in which the "new" keyword wasn't used anywhere because everything was handled by the dependency injector. You get these things: 1. Things that should be compi…

Very recently I have begun to work as programmer, and having to work with PHP I looked at phpunit and unit testing (first time I do it semi-seriously). The guidelines for mocking that I have found are about dependency injection (phpunit has some helpers, but I think that's it). What is the alternative to it?

Python has an alternative: to use a technique called "patching". Basically, in Python, every module is just an object you can access, so in your unit-test, you can easily go into that module, replace a symbol inside a module (or a class) for something else, run unit-test, put thing back. Very nice feature which gives you incredible power to not have to code "with tests in mind".

Re: Why Go gets criticized so much

#224
post #202

Earlier quoted context omitted.

Go has many "special comments" that actually do stuff: * build tags ( https://golang.org/pkg/go/build/ ) * code generation ( https://blog.golang.org/generate ) This is the exact point where you start to see that the Go creators are ok with hackery as long as it works and doesn't make the overall design too complicated.

It looks like we agree Go has "special comments", not "executable comments". I recognise that Go' special comments can be seen as a hack, but honestly they are not so different from Rust's attributes or Haskell's pragmas, which can look clunky too.

No way. Comments are comments, attributes are attributes. Previous discussion: https://news.ycombinator.com/item?id=9522973

Re: Why Go gets criticized so much

#225

Earlier quoted context omitted.

Sometimes, sure. But none of those are our jobs (except if you are a football player, politician, etc). Computer programming languages are our jobs. It's okay to have preferences. I (a full time front-end webdev), think Python is probably the best language out there. But it doesn't define me, because that's just silly.

I agree that a language doesn't define you but what I wonder if a person's favorite language has some correlation to certain personality traits. I would be lieing if I didn't say I get more enjoyment from some languages where other people don't. Perl vs Python for example, pythons core values are to try and make it only one way to achieve something, whereas Perl tries to give you multiple ways to achieve something. I…

That's actually an interesting philosophical question. I find the idea of "more than one way" extremely unappealing, so it's not particularly shocking that Python is my "ideal" language. To me it's either useless (all options have the same efficiency) or it's bad (one option is the most efficient). So it seems senseless.

And artistic is the last word I'd use to describe myself.

Re: Why Go gets criticized so much

#226
post #203

Earlier quoted context omitted.

I believe we are still in majority. Nothing has proven otherwise

The majority in what I said is = [people who treat Go as GoLang first AND Go as the game Go first] = the set of all people reading hacker news minus those who don't know either Go. Writing GoLang removes ambiguity for this majority. My first comment on this subthread has shown that neither you nor any other poster has proven that Go = Go first for most. Nothing you or any other parent comment including my own has pro…

It depends on the context, too. If I read a headline saying something like "Go is awesome for your brain", I'd be 95% sure it refers to Go the board game. When the headline reads "Why everyone hates Go", I'm pretty sure it can't be about the game. I don't think I'm being an exceptional individual - humans in general are very good at taking hints from context.

Re: Why Go gets criticized so much

#227

I don't hate Go. I do strongly dislike posts with clickbaity titles that have an admission the title is wrong in the very first sentence. The rest of the article is little better. It can be summed up in one line: People who dislike Go are upset because they incorporated their favourite programming language into their identity, and the success of Go challenges their own choices . Although I don't hate Go, I also don't…

Yes, that title shouldn't have been posted to HN (see https://news.ycombinator.com/newsguidelines.html) and we've changed it accordingly. If anybody suggests a better title, we can change it again.

Re: Why Go gets criticized so much

#228

Earlier quoted context omitted.

Ultimately, they share a space - compiled, memory safe, and aimed at server-side development. The way they differ is mostly in how they approach memory safety, which gives them different performance characteristics.

Rust isn't solely aimed at server space: E.g. we have servo, a browser engine.

"aimed at" and "used for" are never disjoint sets.

Re: Why Go gets criticized so much

#229
post #204

Earlier quoted context omitted.

Actually the real idiom is not "handle errors where they happen" but rather "errors are values" ( https://go-proverbs.github.io/ ). This means that there is no one true way to handle errors, but rather that it's up to you to build error management with the same tools you have to manage data . Maybe you want to process a list of stuff in parallel and report the first error that ever happens, the same way you'd want to…

That's the thing though. Errors can be data in plenty of other languages. It's just that it's not the only tool you're given, and there's other things you can do without having to reimplement it all from scratch every time. Where a lot of people will say "go is opinionated", I keep feeling that Go is just not providing facilities I feel are part of what you should get out of the box (much like a standard library is o…

I know the feeling. Having moved to Go from the Python community I felt extremely scorned by the lack of a lot of features. Why should I have to write a for loop to traverse this list just to see if an element is present? What I've found is that the features that are missing are actually extremely simple to implement myself - to the point where it's comical that I ever complained about them. The things you gain, however, are much more powerful. There is an elegance to go code that can't be matched by dynamic languages. It has the readability of Python with the type safety of Java, and tooling built in that simply trumps both. I'm obviously a big fan, but it was a long and difficult journey to get there.

Re: Why Go gets criticized so much

#230
post #106

One of Go's selling points is always it's a pragmatic language. But after using it for awhile and implementing a few web apps and APIs in it. I've crossed it off my list for web app or API development. It's great at making standalone CLI tools, however. I've since moved to using Elixir (erlang) for web app stuff (even some scripts) and I am much happier. I'm not in love with Elixirs syntax, but it's nice and includes…

What are the rationales underlying your choice to stop using Go and move to Elixir for web app or API development?

In no particular order:

No sane story for request contexts. I got tired of waiting for net/http support for x/net/context.

Coercing Go structs into JSON and vice versus was just annoying enough. I felt like I was paying the price (being more explicit) for static typing without a lot of the benefits of other static typed languages.

and this: //go:generate stringer -type=Pill [https://blog.golang.org/generate]

Post reply on HN