News for hackers. Stuff that matters.
Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @12:18AM (#36399650)
Could someone explain why is Go so hyped?

In my personal opinion it is just not a good language, and I think many judge it based on some false basis that it is somehow “close to the hardware” because it produces a binary. Like, the amount of time it is put next to Rust when the two have almost nothing in common..

It is very verbose, yet Java is the one that is called that, often by Gophers, which is much more concise. It has terrible expressivity, a managed language which is a perfectly fine design choice, yet seemingly every other language with a GC is somehow living in sin.

And still, it doesn’t fail to show up each day on HN.

Re:Gopher Wrangling. Effective error handling in Go by SmooL on Tuesday June 20, 2023 @12:29AM (#36399727)
1. It's opinionated, so there's often only one way of doings things. Largely, the "one way" is a good way, so people appreciate the forced consistency 2. It's simple. It is very easy to read and write. It is hard to shoot yourself in the foot. 3. It's powerful. They have a few core abstractions that compose well (generic io, http stuff). 4. It's fast. It runs fast because it's compiled, and it compiles fast because it's simple.

Me personally: I appreciate the simplicity of it. It's a great language for working with in a team. I wish it was more functional, and had better ways to handle errors, but the simplicity of it all was a breath of fresh air using it in a working environment.

Re:Gopher Wrangling. Effective error handling in Go by mirekrusin on Tuesday June 20, 2023 @12:52AM (#36399869)
You can shoot yourself in the foot with null pointers.
Re:Gopher Wrangling. Effective error handling in Go by konart on Tuesday June 20, 2023 @12:55AM (#36399885)
You can find a gun to shoot yourself in the foot in any language.
Re:Gopher Wrangling. Effective error handling in Go by mirekrusin on Tuesday June 20, 2023 @01:15AM (#36400009)
Well, it's million dollar one though. It has been solved in many languages. It gives quite uneasy feeling that high percentage of your LoCs can be potentially affected, it doesn't come from some contrived edge case code, it's everywhere.
Re:Gopher Wrangling. Effective error handling in Go by saghm on Tuesday June 20, 2023 @01:07AM (#36399957)
> It is hard to shoot yourself in the foot.

>> You can find a gun to shoot yourself in the foot in any language.

Sure, but finding that one isn't particularly hard, which is what GP was responding to

Re:Gopher Wrangling. Effective error handling in Go by andrewjf on Tuesday June 20, 2023 @12:31AM (#36399738)
I feel like a lot, if not all, has to do with the Google backing. Back when Go was announced, the company had _a lot_ of goodwill, and were envied by anyone doing software engineering. So, pretty much anything they did had an immediate following and base of engineers willing to blindly adopt whatever they did.
Re:Gopher Wrangling. Effective error handling in Go by philosopher1234 on Tuesday June 20, 2023 @12:37AM (#36399774)
I don’t buy it. I can’t think of a single other Google backed programming language with anywhere near to the following of Go.

I think Googles stamp gives it some legitimacy, but I think the much likelier explanation is that the values in Go and its design speak to frustrations a lot of people actually have. This thread is full of people arguing in favor of gos error handling. You can dismiss them all as cranks or sheep if you want, but I think that would be misunderstanding something.

Re:Gopher Wrangling. Effective error handling in Go by andrewjf on Tuesday June 20, 2023 @12:49AM (#36399853)
I mean, maybe - but there's a lot of examples of things being as popular as they are because google did them - gRPC, Protobuf, Kubernetes, Chromium.

None of these things were technically bankrupt (including Go), but their adoption curve would not have been what they have been without Googles name on it.

There's likely other OSS that's technically better, but did not have the network effects google-backed software had from day 1.

Re:Gopher Wrangling. Effective error handling in Go by philosopher1234 on Tuesday June 20, 2023 @12:52AM (#36399867)
Go almost certainly would not have been as successful Without googles brand. But also, without its funding. Google has poured tens of millions of dollars in to go. all of the good qualities of go are due to its incredible funding, whether that’s tooling or the fact that three or four extremely experienced engineers were given years of time to design and implement it.
Re:Gopher Wrangling. Effective error handling in Go by aatd86 on Wednesday June 21, 2023 @06:05AM (#36416583)
Yes but also think about it? In 2012 and even now, which language would you use to replace Go.

Assuredly not C++, nor Rust... No javascript, swift has become more complex apparently, not haskell... Not C... OCaml? No it has a weird syntax, French people and wanting to be different... Etc...

So no, Go has genuinely appreciable qualities that are not found anywhere else :o)

Re:Gopher Wrangling. Effective error handling in Go by mirekrusin on Tuesday June 20, 2023 @12:56AM (#36399896)
It does feel like mostly google backing (other aspects are important as well). Imagine if google would be behind ie. Crystal - you'd see it everywhere.
Re:Gopher Wrangling. Effective error handling in Go by kodah on Tuesday June 20, 2023 @01:12AM (#36399992)
Hard disagree. Go provided a simple answer for asynchronousness in 2012 and was used to build Kubernetes. Because it was used to build Kubernetes a lot of patterns and influence developed very quickly, which made the language very agreeable to anyone writing APIs, systems tooling, or daemons. The portability and cross compilation were also developer favorites as they have downline effects in how simple it is to produce your final product in a CI pipeline.

To me, there were a lot of obvious reasons to choose Go in a corporate environment where my success is graded on my ability to deliver and the quality of what I deliver.

For every popular Google project you read about there are many flops, including ones they appear to develop in spite of.

Re:Gopher Wrangling. Effective error handling in Go by danjac on Tuesday June 20, 2023 @01:58AM (#36400261)
Maybe, but then look at Dart - a Google language whose real-world application so far has been the niche of Flutter app development.

I suspect it's a bit more than the Google stamp of approval - the innate simplicity of the language is attractive, it has almost Python-like simplicity without the performance concerns, and it has a "one true way" approach to formatting that settles any bikeshedding arguments in dev teams.

It's not my personal favourite language - the poor error handling discussed in this thread, the mess of the package management system (I mean, Python has a mess of a package management system, but that's more forgivable in a language from the 1990s, not the 2010s), the lack of decent standard library collections, etc. But I can see the appeal.

Re:Gopher Wrangling. Effective error handling in Go by philosopher1234 on Tuesday June 20, 2023 @12:35AM (#36399758)
I think this claim is too reductionistic to go anywhere. There is no single thing that can explain go’s success. There are hundreds of small differences in the language (and tooling, which arguably is more important).

Most people are not going to care enough (or have the time) to enumerate every single difference between go and Java, and why they prefer the trade off go makes. I use Java professionally, and go where I can, and there is a lot I prefer about go (I won’t pretend it’s uniformly better, though.)

And fwiw, me and you have gone back and forth about this question in many threads previously. I think asking it from such a high level is not going to very effectively get into the details that actually matter to people.

Finally, I also think a lot of what makes go preferable is not in the realm of language design (at least not the algebraic type theory kind) or specific features. It’s much squishier than that, and involves feelings about how teams work and what developers do in practice (and why they fail).

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @12:46AM (#36399833)
Then let me ask instead: why does Go hit the HN front page each day? I would say Rust used to be/is similarly hyped, but it is sort of understandable there, as it is built on a novel idea and fits a previously unoccupied space.

This is not true of Go, and we could just as well see just as many D, Java, C#, Haskell, OCaml posts, yet they combined are not as frequent “visitors”.

Re:Gopher Wrangling. Effective error handling in Go by philosopher1234 on Tuesday June 20, 2023 @01:32AM (#36400111)
I think there is something that advocates/users of Go see in it that they don't feel has been understood by its detractors. And on the flip side, I think the detractors are not very interested in understanding what is good about Go, instead it seems more like a nuisance to be swatted away. I think this creates a great deal of tension between the two, and leads to massive blowup threads. So long as issues (like error handling) persist where these groups cant understand each other, i think the same arguments will repeat.
Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @03:13AM (#36400697)
Thanks, you are likely correct.
Re:Gopher Wrangling. Effective error handling in Go by kinghajj on Tuesday June 20, 2023 @01:24AM (#36400062)
https://en.wikipedia.org/wiki/Worse_is_better

Go is a language made by Googlers, so its design helps with Google problems. And many of Google's problems are ones of scale.

* Go is straightforward to read. Any reasonably-competent college graduate should have little trouble understanding it and be able to become productive quickly. * Go compiles into completely static binaries. You don't have issues like "oops, the build system runs CentOS 7 but we're deploying it to Ubuntu 18.04 and their libc's aren't compatible." With containers, you can copy many Go programs into `FROM scratch` images and they will work fine, greatly reducing the attack surface area.

I used to dislike for Go for similar reasons to you and others, but after using it for a few years at $employer, I've come to appreciate its merits. Sure, it can be a bit annoying to write

    if err != nil {
        return err
    }
again and again at first, but I just type 3yy7jp to yank+paste it as needed. You could also configure some editors to detect when you type `if err` and generate it automatically. It's also not uncommon for editors to fold the lines down into a single line.
Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @01:43AM (#36400181)
Yet, the bulk of code written at Google remains Java and C++. golang's approach to uncolored async was decent, yet in the same manner of the language, overly verbose and error prone. Passing channels everywhere gets tricky quickly, and you have to manually ensure that contexts and deadlines are handled everywhere.

Errors in golang do not have stack traces, and wrapping errors is just an error prone way of manually (and apparently nonperformant way of) generating stack traces.

Re:Gopher Wrangling. Effective error handling in Go by stephen123 on Tuesday June 20, 2023 @03:23AM (#36400766)
"completely static" has a gotcha though. I was getting segfaults yesterday because libc was removed from my docker image.

I had to add `CGO_ENABLED=0`

Re:Gopher Wrangling. Effective error handling in Go by bombolo on Tuesday June 20, 2023 @03:48AM (#36400913)
> Go compiles into completely static binaries

* sometimes.

It can also dynamically link stuff on occasions, depending what options you use.

Re:Gopher Wrangling. Effective error handling in Go by konart on Tuesday June 20, 2023 @01:38AM (#36400143)
In my personal opinion it's a great language to solve problems _I_ have to deal with in course of my work. Can I solve them with Java?

Sure.

Difference is go does not have the complexity you can find in Java and quite opinionated. So you don't have to spend as much time working with the language inself and can focus on getting the job done.

Go is not as expressive and some other languages and does not have the same abstractions that make other languages more suited to be used while developing comlex software.

Thing is - in many cases you simple do not need any of it, but need a fast verbose language with good tooling.

Call it Java Light or something.

Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @01:50AM (#36400226)
Could you elaborate on exactly what complexity in Java you're referring to?

By having an overly simplistic language, you end up pushing more complexity onto the programmer and into the code base. There is no free lunch.

I find it much more sane to solve and express code in Java. You get terser, more to the point code that reflects the underlying logic more clearly, compared to having to read many lines or pages to understand what's going on.

Re:Gopher Wrangling. Effective error handling in Go by konart on Tuesday June 20, 2023 @02:25AM (#36400413)
>By having an overly simplistic language, you end up pushing more complexity onto the programmer and into the code base. There is no free lunch.

Sure, I just don't see this as a problem.

As a result you have

a) a number of third party packages to chose from depending on your needs\opinions

b) you have a more verbose codebase, some people find it harder to deal witih while I find it easier to deal with.

>compared to having to read many lines or pages to understand what's going on.

Different people different ways of thinking I guess.

In my eyes Java code looks to much like a specification in for of a code. Easier to do a code review but harder to actually understand how it works. And I personally need this dive into internals to actually feel confident about the code.

>Could you elaborate on exactly what complexity in Java you're referring to?

I don't have too much experience in Java, but from what I've seen - Java has too many abstractions and OOP for the sake of paradigm and nothing else.

Re:Gopher Wrangling. Effective error handling in Go by adezxc on Tuesday June 20, 2023 @03:33AM (#36400821)
It is frustrating to read Java code. I don't want to understand your abstractions or class definitions like final, static and whatever.

I don't want to learn about Gradle or Maven to understand how a package is working, I'd rather do it in code.

Consider even the current "Hello, world" example in Java (Yes, I know about the proposal about simplifying it), it is tedious, why would I need to understand public/private and classes before launching a simple program?

I fully agree it is a terrific piece of software, especially for industry-grade applications, yet it just isn't attractive.

Main thing IMO, is that you can start out writing pretty good Go code after 24 hours and just improve on your skills as a general programmer. With Java, after a few months you would still need to know about some methods or OOP tips/tricks, design patterns etc. to become proficient.

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @04:50AM (#36401338)
There is no going around abstraction, that’s a necessary part of any non-trivial program as that’s the only method we have to control complexity. Your struct is also an abstraction, you could have defined another one, use it differently, etc.

Many of the design patterns are useless bullshit, that is long superseded by a language feature, so that point doesn’t stand imo.

Go also has public/protected, it is just case-specific. If anything, that makes it harder to understand, how should I knew that Asd is different from asd beforehand?

Re:Gopher Wrangling. Effective error handling in Go by adezxc on Tuesday June 20, 2023 @05:33AM (#36401641)
It is easier to know that lowercase is package-specific, uppercase is exported, than knowing which field is private/public by default.

Go reserved keywords: break, default, func, interface, select, case, defer, go, map, struct, chan, else, goto, package, switch, const, fallthrough, if, range, type, continue, for, import, return, var

Java reserved keywords: abstract, continue, for, new, switch, assert, default, goto*, package, synchronized, boolean, do, if, private, this, break, double, implements, protected, throw, byte, else, import, public, throws, case, enum, instanceof, return, transient, catch, extends, int, short, try, char, final, interface, static, void, class, finally, long, strictfp, volatile, const, float, native, super, while.

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @06:52AM (#36402196)
You have conveniently left out types from go’s list.. with those removed it is hardly longer, and as has been shown (case-sensitive identifiers), not all language complexity lives within keywords.
Re:Gopher Wrangling. Effective error handling in Go by preseinger on Tuesday June 20, 2023 @07:47AM (#36402680)
the parent's point was to compare the set of reserved keywords in the two languages

types do not enter the discussion

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @11:45AM (#36405743)
They do if 1/3 of java’s keywords are there due to types.
Re:Gopher Wrangling. Effective error handling in Go by preseinger on Tuesday June 20, 2023 @12:19PM (#36406370)
some keywords are types, but not all types are keywords, right?

like, it's not as if the go type `float64` is also a go keyword

but i guess the java type `byte` is a java keyword? according to https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_k...

Re:Gopher Wrangling. Effective error handling in Go by adezxc on Tuesday June 20, 2023 @08:13AM (#36402918)
https://go.dev/play/p/71I57QCycTr This works, so how exactly did I leave them out?
Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @01:43PM (#36407653)
This is why you can do

const true = false

in golang

The number of reserved keywords is not a bad thing. For example, I constantly missed `final` when I worked in golang. Just because a keyword doesn't exist does not make its usecase disappear. Same with other features like `enum` (extremely useful) and visibility rules. golang only has package private and public, not nearly as granular as one needs in practice, not to mention generating large CL's when changing the visibility rules of a function, as opposed to simply having a 1 line change. Sure you can ignore those use cases, but it doesn't mean that their usefulness disappears.

Re:Gopher Wrangling. Effective error handling in Go by adezxc on Tuesday June 20, 2023 @02:58PM (#36408826)
> The number of reserved keywords is not a bad thing.

I'm not saying reserved keywords are bad. I'm saying there's much more to learn about Java to learn programming, Go is limited with its' keywords and 'features', which often results in more LoC, but makes it super easy to get going, run into general programming problems like using a variable instead of a reference to it, etc.

In Java, you spend much more time learning the features of the language itself, even simple things like (s)Strings are not easy to understand, then add classes, inheritance, UTF-16, adding other libraries, build tools, JUnit and many, many other things that are given to you with Go.

Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @04:20PM (#36409921)
When I had to learn golang, picking up the syntax was easy, but it has many gotchas that you end up having to spend time to learn them anyway, which don't exist in Java (e.g. the Java compiler requires final or effectively final vars to be passed into lambdas, golang happily complies ending up with race conditions).

I don't see why learning language features is an issue. The language offers features to provide more correct and more expressive code.

golang does not solve the variable vs reference issue at all by the way, and in fact, introduces weird edge cases, such as nil interface not being equal to nil.

Why do you say Strings not easy to understand?

Re:Gopher Wrangling. Effective error handling in Go by erik_seaberg on Tuesday June 20, 2023 @09:00PM (#36412975)
We should optimize for clear and concise code between experts. You’re going to be an expert for most of your career, and that’s when your time has the greatest value. A small learning curve is bad because you quickly run out of ways for tools to help you. I want to use the most powerful language I possibly can; the time investment pays off.
Re:Gopher Wrangling. Effective error handling in Go by adezxc on Wednesday June 21, 2023 @04:57AM (#36416119)
Sure, but it doesn't change the fact that I don't like reading Java code and prefer Go.

I want to learn programming before becoming an expert in the language. I feel like it's easier to do using Go. In Java you have to become a bit of both to be efficient.

Re:Gopher Wrangling. Effective error handling in Go by konart on Tuesday June 20, 2023 @05:01AM (#36401426)
>If anything, that makes it harder to understand, how should I knew that Asd is different from asd beforehand?

By reading docs or some kind of "Go by Example"? The same way you learned the difference between `private` and `protected`.

Re:Gopher Wrangling. Effective error handling in Go by sethammons on Tuesday June 20, 2023 @05:47AM (#36401744)
A number of years ago, I decided to try out this Java monster. Figured I'd add it to the tool belt. Opened the first hello world tutorial Google game me. It started with xml files to define string content. I noped out.
Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @01:44PM (#36407663)
It sounds you're conflating an older framework with Java the language.
Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @03:11AM (#36400675)
Java is absolutely not a complex language. The “enterprise java” style is an unfortunate one that can actually be traced back to C++, but it is not a necessity at all, and due to the sheer size of the java ecosystem you will find plenty of examples of a more barebones approach — also supported by the language developers.

I fail to see why I would go with go over java, besides.. perhaps some CLI app? With Graal even that can be implemented in Java.

Re:Gopher Wrangling. Effective error handling in Go by konart on Tuesday June 20, 2023 @04:01AM (#36400985)
>The “enterprise java” style is an unfortunate one >but it is not a necessity at all

The thing is in real life you have to deal with this kind of code most of the time. Because most of the time you deal with the old code or people who are used to some patterns you have to use too because you are part of the team.

Go enforces (kind of) a more barebones approach by default.

PS: I think it's poinless to compare two languages. We should rather compare real practices and read examples.

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @04:45AM (#36401306)
Ad absurdum than a new language will always be better, because usage patterns change and the new language doesn’t yet have any existing code bases using the old ones.
Re:Gopher Wrangling. Effective error handling in Go by w7 on Tuesday June 20, 2023 @01:51AM (#36400229)
It has:

* Relatively simple syntax.

* "Good enough" expressivity-- nothing that's considered "missing" has been a true blocker for most projects.

* An easily accessible concurrency primitive, with the bonus that the runtime can choose to execute goroutines in parallel (when able)-- this comes with no required function coloring or split in a code base.

* A well opinionated environment packaged with the compiler: default formatter, default method for fetching remote deps, default documentation generator, default race detector, default profiler, default testing system.

* Decent portability-- can cross compile relatively easily from one platform to another, doesn't require a larger runtime pre-installed on the foreign host.

* "Batteries included" standard library.

* Inertia-- enough of an active community to pull what you need from the Internet, whether it's guides or code.

* A "good enough" type system to catch some errors before they become runtime errors.

* A "good enough" abstraction for operating on data with: structs, interfaces, and methods. With composition being preferred over inheritance, and embedding bringing handy sugar.

No language is perfect, everyone has an opinion, but for many people this is "close enough" to what they prefer to work with.

Gophers may just be a bit more vocal about it.

Re:Gopher Wrangling. Effective error handling in Go by za3faran on Tuesday June 20, 2023 @01:53AM (#36400235)
I'm strongly convinced that the google brand name gave it a big push. Its predecessor (Limbo if I recall correctly) went nowhere. It did bring uncolored async to the mainstream, but as in typical golang fashion, it was very verbose and error prone.

Java learned the right lessons and I'm quite excited to see their structured concurrency approach. No need to pass channels and contexts everywhere to manually manage hierarchies from what I gather.

Re:Gopher Wrangling. Effective error handling in Go by throwawaymaths on Tuesday June 20, 2023 @03:23AM (#36400762)
> It did bring uncolored async to the mainstream

I believe that uncolored async (Erlang) precedes colored async (python)

Correction: c# was the first language with colored aaync, still way after Erlang

Re:Gopher Wrangling. Effective error handling in Go by stephen123 on Tuesday June 20, 2023 @03:26AM (#36400778)
Yea, I find go's concurrency very error prone compared to something with futures.

I've even got a library for using futures in Go. https://stephenn.com/2022/05/simplifying-go-concurrency-with...

Re:Gopher Wrangling. Effective error handling in Go by hknmtt on Tuesday June 20, 2023 @02:06AM (#36400314)
Go is hyped because it's amazing to work with. It's clean, simple, readable, very powerful and fast, has goroutines and a ton of libraries which are very easy to get,
Re:Gopher Wrangling. Effective error handling in Go by mtzet on Tuesday June 20, 2023 @02:22AM (#36400399)
I agree that go and rust have different areas, but that was less clear when they were getting started. Back then go was trying to figure out what it meant by 'systems programming language' and rust had a similar threading model.

Another point is that they do share similarities, which might we might now just describe as being 'modern': They're generally procedual -- you organize your code into modules (not classes) with structs and functions, they generally like static linking, type inference for greater ergonomics, the compiler includes the build system and a packager manager, there's a good formatter.

The above are points for both rust and go compared to C/C++, Python, Java, etc.

So why do I like go? I think mostly it's that it makes some strong engineering trade-offs, trying to get 80% for 20% of the price. That manifests itself in a number of ways.

It's not the fastest language, but neither is it slow.

I really dislike exceptions because there's no documentation for how a function can fail. For this reason I prefer go style errors, which are an improvement on the C error story. Yes it has warts, but it's 80% good enough.

It's a simple language with batteries included. You can generally follow the direction set and be happy. It leads itself to simple, getting-things-done kind of code, rather than being over-abstracted. Being simple also makes for great compile times.

Re:Gopher Wrangling. Effective error handling in Go by kaba0 on Tuesday June 20, 2023 @03:06AM (#36400659)
> I agree that go and rust have different areas, but that was less clear when they were getting started

That I agree with.

But Go is anything but modern on a language front. It shares almost nothing with Rust, which actually has a modern type system (from ML/Haskell).

Even if we disagree about exceptions (I do like them as they do the correct thing most of the time, while they don’t mask errors, but include a proper stacktrace), go’s error handling is just catastrophic, being an update from c which is even worse is not a positive.

Re:Gopher Wrangling. Effective error handling in Go by mtzet on Tuesday June 20, 2023 @04:29AM (#36401179)
I'm not arguying that go has modern tech, but rather that it has modern sensibilities. This means not trying to force 90s style OOP, preferring static linking for easier deployment, including a build system and package manager with the compiler and preferring static types with type inference to dynamic types.

This differentiates go, rust, zig, odin etc., from languages like C++, Java, C#, Python etc. I think it makes sense to describe that difference as one of modern sensibilities.

Re:Gopher Wrangling. Effective error handling in Go by preseinger on Tuesday June 20, 2023 @07:48AM (#36402696)
go's error handling is not catastrophic, it is very good
Re:Gopher Wrangling. Effective error handling in Go by hibbelig on Tuesday June 20, 2023 @03:11AM (#36400676)
> I really dislike exceptions because there's no documentation for how a function can fail. For this reason I prefer go style errors, which are an improvement on the C error story. Yes it has warts, but it's 80% good enough.

I’m not a go developer. How does go document how a function can fail?

A Java developer can use checked exceptions so that some information is in the signature. For unchecked exceptions the documentation must explain.

I guess in Go the type of the error return value provides some information but the rest needs to be filled in by the documentation, just like the Java checked exceptions case.

Re:Gopher Wrangling. Effective error handling in Go by mtzet on Tuesday June 20, 2023 @04:38AM (#36401241)
> I’m not a go developer. How does go document how a function can fail?

There's no magic to it. Errors are values, so it's a part of the function signature that there's an error code to check. In C++ any function can throw an exception and there's no way of knowing that it wont.

It's true that go doesn't document what _kinds_ of errors it can throw, but at least I know there's something to check.

Re:Gopher Wrangling. Effective error handling in Go by vips7L on Thursday June 22, 2023 @07:28AM (#36430504)
But that doesn’t document _how_ a function can fail. Just that it _can_ fail.
Re:Gopher Wrangling. Effective error handling in Go by jhoechtl on Tuesday June 20, 2023 @02:26AM (#36400424)
> Could someone explain why is Go so hyped?

You can write huge code bases with it, the tooling is good.

You can use a moderately skilled work force to achieve good results. When some team members leave, you are not left with some wizardry code base behind.

Re:Gopher Wrangling. Effective error handling in Go by bheadmaster on Tuesday June 20, 2023 @02:36AM (#36400481)
> Could someone explain why is Go so hyped?

For me, it's:

1) channels (and goroutines, of course)

2) explicit error handling (panics are actually fatal, in contrast to exceptions which are often even used for flow control)

3) easy (cross-)compilation - just go build

And probably a few more reasons I can't remember at the moment. It's just fun to write Go!

Re:Gopher Wrangling. Effective error handling in Go by nbraxf100 on Tuesday June 20, 2023 @03:50AM (#36400928)
I'm not a fan of the syntax either. My impression is that "close to the hardware" is not the selling point, but "close to Unix" is.

If you view the language as a safer super shell script, it becomes more obvious.

Go was hyped in the beginning, but I get the impression that now it isn't. The most persistently hyped language here is Python. Fortunately, we see more Elixir, Ruby and Go posts lately.