Live data from Hacker News

Go Developer Survey 2022 Q2 Results

go.dev

141–150 of 186 posts

Re: Go Developer Survey 2022 Q2 Results

#141
post #66

I was glad to see Go get generics. Not because it was super-important but rather so we didn't have to hear about it anymore. I think exceptions are a false economy so I have no real issue with Go's error handling. It could be cleaner. Rust's match expressions are better. Multiple returns are a bit awkward. Something like a result or error union type would be better and could fit in with the type system. Standard erro…

> so we didn't have to hear about it anymore

Generics were a mistake, and this is spot on.

Re: Go Developer Survey 2022 Q2 Results

#142

I am delighted with the error handling in Go. Overall I would prefer to Go with the current features and not add more, maybe even deleting some inconsistencies in Go v2.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable.

The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represents the error? Hidden magic isn't good magic, in my opinion. Just be explicit.

Another issue with the Rust example is discipline. I don't know Rust, but the example you've given implies I can not include "?" in the call and just ignore any errors entirely? (What happens if I do that and there's an error? This isn't explicit enough.) Go, in comparison, does the opposite: it forces you to handle the error or literally ignore it. You cannot forget to deal with an error in Go.

And of course, Go gives you an error object you can work with (something I'm sure Rust does too, but it's not obvious to me as a none Rust developer.)

I prefer my languages to be statically typed, statically linked, and very explicit in their syntax. It results in a bit of extra work up front for compile and run time safeties, and the ability to easily re-read the code at a later date.

Re: Go Developer Survey 2022 Q2 Results

#143
post #66

I was glad to see Go get generics. Not because it was super-important but rather so we didn't have to hear about it anymore. I think exceptions are a false economy so I have no real issue with Go's error handling. It could be cleaner. Rust's match expressions are better. Multiple returns are a bit awkward. Something like a result or error union type would be better and could fit in with the type system. Standard erro…

> so we didn't have to hear about it anymore Generics were a mistake, and this is spot on.

Almost 40% of respondents either use generics or want to use generics, after having been released 6 months ago in 1.18. That's… a pretty incredible adoption rate for something that I've repeatedly heard wasn't necessary or was a mistake.

Re: Go Developer Survey 2022 Q2 Results

#144
post #142

Earlier quoted context omitted.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable. The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represent…

I’m not sure that optimizing readability for someone unfamiliar with the language is the right tradeoff.

Rust code uses a Result type for error handling: it can either be Ok(T) or Err(E), never both.

The question mark operator tries to extract the value wrapped in Ok. If the Result is Err and not Ok, it returns the error. It’s not “hidden magic”, it’s a well-defined operator.

> I don't know Rust, but the example you've given implies I can not include "?" in the call and just ignore any errors entirely?

If you don’t unwrap the value from the result, then you still have a Result instead of a T, and will get a type error.

Re: Go Developer Survey 2022 Q2 Results

#145
post #142

Earlier quoted context omitted.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable. The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represent…

> But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represents the error? Hidden magic isn't good magic, in my opinion. Just be explicit.

the question mark operator simply checks if there was an error, and if there was one, it returns it. Practically, it does the same as the GO Code - and the only reason you don't know is, because you don't know Rust.

> I don't know Rust, but the example you've given implies I can not include "?" in the call and just ignore any errors entirely?

no, omitting the ? will give you a compiler error. You can ignore the error case by writing:

    res1 = canFail().expect("xz didn't work");
or

    res1 = canFail().unwrap();
If there's an error, the program will crash. There are other alternatives, which e.g. allow you to set 'res1' to a default value in the error case.

> Go, in comparison, does the opposite: it forces you to handle the error or literally ignore it. You cannot forget to deal with an error in Go.

As you see, there is no difference to Go... in this regard.

Re: Go Developer Survey 2022 Q2 Results

#146

Earlier quoted context omitted.

Go doesn't have errors, only values. Value handling could be improved, I'm sure, but anything that focuses on values that humans attach error meaning to is fundamentally flawed and will leave broken half-solutions. Each problem people say Go has with error handling is actually a more general problem with value handling and/or interfaces and the right solution would solve for those problems across the board. The probl…

There are always going to be cases where the happy path call tree should be abandoned because no useful value meeting requirements is going to be possible. What’s needed is to persuade Go devs to use panics instead of obscuring every function reinventing them by hand.

The happy path should at least have a value that we oft categorize as error to branch on meaningfully. If the code has no purpose it wouldn’t need to be called.

panic is certainly appropriate if programmer error left the application in an inconsistent state (an exceptional state, or exception for short as it is often referred to). I've never seen a Go developer, or developer in any other language for that matter, try to deal with these cases by hand.

Re: Go Developer Survey 2022 Q2 Results

#147
post #142

Earlier quoted context omitted.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable. The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represent…

> Another issue with the Rust example is discipline. I don't know Rust, but the example you've given implies I can not include "?" in the call and just ignore any errors entirely?

The issue is that you don’t know what you’re talking about.

Re: Go Developer Survey 2022 Q2 Results

#148
post #142

Earlier quoted context omitted.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable. The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represent…

> As someone who's not a day-to-day developer/software engineer: the Go code is more readable.

COBOL is what you get when you optimize for readability by people who don't know how to program.

> The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represents the error? Hidden magic isn't good magic, in my opinion. Just be explicit.

It gets returned to the next level up, exactly like in the analogous Go code above. And that's how it always works, so you don't have to try to figure it out separately for each use of it you see.

> Another issue with the Rust example is discipline. I don't know Rust, but the example you've given implies I can not include "?" in the call and just ignore any errors entirely? (What happens if I do that and there's an error? This isn't explicit enough.) Go, in comparison, does the opposite: it forces you to handle the error or literally ignore it. You cannot forget to deal with an error in Go.

You actually can't do that and will get a compiler error if you try. Rust's type system distinguishes between "a number" and "either a number or an error". On the other hand, Go will let you forget to handle an error, if you do "res1, err1 = canFail()" but then forget to return an error yourself in the "err1" case. Rust's sum types prevent that mistake entirely.

> And of course, Go gives you an error object you can work with (something I'm sure Rust does too, but it's not obvious to me as a none Rust developer.)

Indeed it does. I consider it a good thing that you don't have to deal with language features you're not currently using, though.

> I prefer my languages to be statically typed, statically linked, and very explicit in their syntax. It results in a bit of extra work up front for compile and run time safeties, and the ability to easily re-read the code at a later date.

But Rust fits the bill for all of those things, and if you care about compile time safety, it does so way better than Go.

Re: Go Developer Survey 2022 Q2 Results

#149

Earlier quoted context omitted.

>Surprised to see language satisfaction so high. Who else do you think responds to these surveys? I have a long list of grievances against Go, so I don't use it, and am not qualified to participate in a survey.

To be honest, many other languages have a lot of users that are quite unsatisfied with it, despite using it regularly (Java comes to mind). The fact that most of the people who use Go are happy with it isn't that insignificant.

"There are two types of languages, the ones no one complain about and the ones no one uses"

-- C++ dude

Re: Go Developer Survey 2022 Q2 Results

#150
post #142

Earlier quoted context omitted.

I find that interesting, and like the Rust way of error handling much more. Go error handling blows the code up a lot and makes the code less comprehensible. res1, err1 = canFail() if err1 != nil { return err1 } res2, err2 = canFail() if err2 != nil { return err2 } return res1 + res2, nil becomes res1 = canFail()? res2 = canFail()? return Ok(res1 + res2) guess what is more readable

As someone who's not a day-to-day developer/software engineer: the Go code is more readable. The Rust is interesting, for sure, but I don't know what "?" is doing. I like the use of the question mark as it makes the act of calling the function a question - did it work or not? But what's not obvious is what happens if it did not work? What happens then? Where does the error object go? Is there something that represent…

> The Rust is interesting, for sure, but I don't know what "?" is doing.

But it’s very easy to wrap one’s head around it. If the code under question mark returns an error, the function within which that code sits returns early with that error. If that function returns Result, the question mark essentially provides short, composable code.

I never personally had a problem with Go error handling but having prior experience with scala where I often used Try(…).toEither, I love Rust’s ?.

Post reply on HN