Live data from Hacker News

Lies we tell ourselves to keep using Golang (2022)

fasterthanli.me

221–230 of 526 posts

Re: Lies we tell ourselves to keep using Golang (2022)

#221

Earlier quoted context omitted.

Bah, no, I hated that you had to wrap basically every code block in a try/catch in Java, because the underlying lib could change and suddenly throw a Runtime-Exception. At the same time Checked Exceptions were a nightmare as well, because suddenly they were part of the contract, even though maybe wrong later.

Checked exceptions are more trouble than they're worth. That doesn't make exceptions in general bad.

What does make exceptions bad in my opinion (and shared by Go developers?) is a few things:

1. Exceptions are expensive (at least in Java / C#), as they generate a stack trace every time. Which is fine for actually exceptional situations, the equivalent of `panic()` in Go, but:

2. Exceptions are thrown for situations that are not exceptional, e.g. files that don't exist, database rows that don't exist, etc. Those are simple business logic cases. The workaround is defensive coding, check if the file exists first, check if the row exists? that kind of thing.

3. The inconsistency between checked and unchecked exceptions.

4. Distance - but this is developer / implementation specific - between calling a function that can throw an error and handling it.

But #2 is the big one I think. Go's error handling is one solution, but if it's about correct code, then more functional languages that use the Either pattern or whatever it's called formally are even better. Go's approach is the more / most pragmatic of the options.

Re: Lies we tell ourselves to keep using Golang (2022)

#222

Earlier quoted context omitted.

Exactly. Every programming language is a tool in your toolbox, and you should choose the appropriate one for the job at hand. For me, that's Go around 95% of the time. I have no need to worry about a 24 byte overhead for a slice allocation, if I did have to worry about that, I'd probably use C or Rust.

And since Go is so readable, theoretically getting the core functionality out and rewriting it in a more specialized language would be fairly straightforward. And while it's an investment in time and effort to rewrite a chunk, at least you know what you're writing already. But that's a point made in the article, that Go is also good for prototyping. But there's a few languages good for that, e.g. Ruby which powered a…

> And since Go is so readable, theoretically getting the core functionality out and rewriting it in a more specialized language would be fairly straightforward.

You'll have to rewrite your whole program (or at least factor out the "core" part you care about into a separate binary and talk to it via IPC or network) because Golang has terrible FFI as pointed out by OP.

Re: Lies we tell ourselves to keep using Golang (2022)

#223
His criticisms include:

- No sum types

- Default zero values

- "Go is an island": Fully integrated toolstack makes it easy to use the same tool top-to-bottom, but makes it difficult to use with any other project

None of those are lies; apart from the first, they all have advantages and disadvantages. Sure, there's an advantage to forcing you to specify every value, but there are disadvantages too. And sure, there are disadvantages from Go being an "island", but he lists some of the advantages right there in his post.

If those are deal-breakers for him, then sure, go use something else. But lots of us like the advantages more than we dislike the disadvantages.

Re: Lies we tell ourselves to keep using Golang (2022)

#224
post #95
post #45

Earlier quoted context omitted.

Without fail, every single person I’ve seen rave about go’s error handling compares it only to exceptions as if that’s the only alternative. On the flip side I have yet to find a person who’s familiar with sum types (e.g., Maybe, Option, Result) that finds the golang approach even remotely acceptable.

That’s to be expected since it is marketed towards beginner and casual programmers.

I don't agree that that's what it's marketed towards, but it was designed with those in mind. That said, experienced developers can enjoy it too, as code is just a means to an end and code complexity or cleverness does not make for good software in the broader sense of the word.

It's a Google solution to Google scale problems, e.g. codebases with millions of lines of code worked on by thousands of developers. Problems that few people that have an Opinion on Go will ever encounter.

Re: Lies we tell ourselves to keep using Golang (2022)

#225
post #54
post #5

This article makes a lot of great points about the shortcomings of Go. I don’t think explicit error handling is one of them however. I’ve previously spoken about my loathing of exception handling because it adds a “magic” layer to things which is way too easy to mess up. From a technical standpoint that isn’t necessarily a good argument, but from a pragmatic standpoint and decades of experience… well I will take expl…

For me, the issue with error handling is that while errors are explicitly stated, they are often poorly handled. Rarely have I seen the handling of multiple reasons for why an error might occur, along with tailored approaches to handle each case. This is something very common in older languages like Python or Java

This is down to developer style and agreements though; Go has typed errors and a set of utilities to match them [0]. Not using those is a choice, just like how in Java you can just `catch (Exception e)` after calling a dozen methods that might each throw a different exception.

[0] https://pkg.go.dev/errors

Re: Lies we tell ourselves to keep using Golang (2022)

#227
post #5

This article makes a lot of great points about the shortcomings of Go. I don’t think explicit error handling is one of them however. I’ve previously spoken about my loathing of exception handling because it adds a “magic” layer to things which is way too easy to mess up. From a technical standpoint that isn’t necessarily a good argument, but from a pragmatic standpoint and decades of experience… well I will take expl…

> Go is seeing adoption that no other “new” language has exactly because of its simplicity

Yes - for me, the simplicity is essential. As a part-time programmer, I don't have months to spend learning C++ or Rust.

If my project needs to compile to small(-ish) standalone binaries for multiple platforms (ruling out Python, Ruby, Java, C#, etc) what simple alternative language is there? Plain C?

Re: Lies we tell ourselves to keep using Golang (2022)

#228

I wonder what makes someone go such a great length to bash a language, any language. I say bashing, because even the few valid points in the post are not written in a constructive style. After all is there a language that can't be criticised? Is the post written to make one feel better having a failed a project the language? (It's not me, it's the language) Or is it the failure to understand that not everyone thinks…

[deleted]

Re: Lies we tell ourselves to keep using Golang (2022)

#229

I wonder what makes someone go such a great length to bash a language, any language. I say bashing, because even the few valid points in the post are not written in a constructive style. After all is there a language that can't be criticised? Is the post written to make one feel better having a failed a project the language? (It's not me, it's the language) Or is it the failure to understand that not everyone thinks…

[deleted]

Re: Lies we tell ourselves to keep using Golang (2022)

#230

Every time I work in a different language I'm always wanting to go back to Go even if it's not the perfect language. I just love the fact that it literally just works. You install Go, you download code, and write code that's it. No figuring out what version, runtimes, configurations, build tools, package managers to use. Just install and Go. I think maybe Rust is the only other programming language that provides the…

This is the power of Go, its integrated toolchain. It makes interop more difficult like the article says, but in my personal and limited experience that's not a frequent use case.
Post reply on HN