7 ms·
You guys can keep complaining about how go is too verbose, but I love everything about go. I love the error handling, I love the forced formatting, i love all
by b7e7d855b448 2mo ago
You guys can keep complaining about how go is too verbose, but I love everything about go.
I love the error handling, I love the forced formatting, i love all the linting it has including style guides. When you read other source code it's so easy to understand it and make sense of it. Thank you go team
(Ok, maybe I am a bit sceptical with the latest generic additions, but overall it's a great language. I love it.)
- jerf 2mo agoIf generics were going to ruin the language, they would have by now. I think you can rest easy.
- ncruces 2mo agoThe greatest thing about generics is … that they're not used much if at all. Which is a great way to make sure they're not overused, which in my experience is better than underuse.
- wannabe44 2mo agoOh yeah totally agree. I don't understand why someone would want to write `slices.Contains(s, needle)` when you can write this beautiful poem like a Shakespeare in VSCode: found := false for _, v := range s { if v == needle { found = true break } } Oh and I totally want to build a stack trace manually. It's like doing cardio to me. if err != nil { return fmt.Errorf("my function name but in spaces: %w", err); } This is very elegant by the way, so that we need errors.Is now, which has to dynamically check if the error implements Unwrap() error or Unwrap() []error. Because having any language facilities for error handling is harmful.
- logicchains 2mo agoYour handwritten one has a major performance bug: found := false for _, v := range s { if v == needle { found = true break } } Do you see it? It copies the v into a local variable, which could be tremendously wasteful if it's a large struct. You should instead be taking a pointer to s[i] and comparing the value there with `needle`. If you'd used `slices.Contains(s, needle)`, on the other hand, it could have such a performance bug in it and you'd never know.
- mathisfun123 2mo ago> on the other hand, it could have such a performance bug in it and you'd never know. wut...? the debate isn't between closed (incompetent) source and open (competent) source - the debate is between verbose language and expressive language.
- kajman 2mo ago> If you'd used `slices.Contains(s, needle)`, on the other hand, it could have such a performance bug in it and you'd never know. Perhaps you're much better at programming than I am, but I prefer these semantics in a language because I figure they're much more likely to have been optimized empirically, support vectorization, and be less buggy than another rote loop I'm trying to speed through.
- asdf88990 2mo agoThat is just a silly rationalisation by primitivists, and they will never be able to articulate any rational point where abstracts makes sense, in their world, whatever Russ Cox and a bunch of Google employees deem fit is the ideal. Even when Russ Cox and Go team had come to term with reality and stopped pretending like we are in 70s still, these lot will move goalposts. It is a kind of psychosis and sycophancy that is beyond rational discourse.
- pjmlp 2mo agoEven the 70's, that is ignoring what was happening with CLU, Smalltalk, Mesa, Modula-2, PL.8, ML, ...
- boredatoms 2mo agoor contains() could be written by those who can write performant code, ..once
- irq-1 2mo agoYou're right. Just for information, slices.Contains() uses the index, not a copied value. https://cs.opensource.google/go/go/+/refs/tags/go1.26.5:src/slices/slices.go;l=117 https://cs.opensource.google/go/go/+/refs/tags/go1.26.5:src/...
- msie 2mo agoYou forgot to put /s after your post.
- b7e7d855b448 2mo agoI don't say it's perfect, but right in this moment I feel most comfortable with go and I don't mind jumping through a few hoops or writing things multiple times
- TheDong 2mo agoi.e. the blub paradox: https://wiki.c2.com/?BlubParadox https://wiki.c2.com/?BlubParadox
- inigyou 2mo agoSteelman: the extra complexity of languages more powerful than Blub has not been found to be a good tradeoff. Blub is KISS and that's good.
- TheDong 2mo agoThe more common steelman for go is "most programmers are idiots, so a language designed for idiots is a good tradeoffs since it's easier to hire programmers for a codebase in that language" I think that one is true. Like, if you're building something that is able to be successful despite having a poor type system, frequent panics, and difficult to correctly use concurrency primitives, Go is a great language for letting the lowest common denominator programmer be productive. If you're building more serious software, then it can be a very bad tradeoff that destroys your company or product, but you know, that's true of a bunch of languages.
- yoghurtwere 2mo ago> difficult to correctly use concurrency primitives, Rust async has a bad reputation in Rust circles, due to difficulties like deadlocks and poisoning (also regarding the messy panic system Rust has). > Rite of passage for a Rust developer is creating a deadlock through an if-statement.
- inigyou 2mo agoGo is a great language for when you want to just accomplish some server-side business logic with minimal bullshit standing between you and it.
- bayindirh 2mo ago> Because having any language facilities for error handling is harmful. No, making error handling verbose mandatory is meant to make developers do mental cardio and be mindful of what they are doing. You can either keep developers mindful or punish them after they make a mistake by shouting at them and make them waste their time during re-compiling. P.S.: Yes, I love Go's error handling mechanics, which makes handling errors mandatory, not optional, and if you ignore the error, this is a deliberate choice and the burden is on the developer. Go does the former, Rust does the latter.
- sapiogram 2mo agoWhat are you talking about, only Rust actually forces you to handle errors. Go functions merely return a tuple with an error along with the result, with a convention that you must checktror a non-nil error before using the result. Rust bakes this into the type system, a function can truly return a result or an error.
- bayindirh 2mo ago> with a convention that you must checktror a non-nil error before using the result. So, you handle the error in the end, or forcefully and intentionally ignore it. Again, if the code goes boom, it's on the developer, not on Go. > Rust bakes this into the type system, a function can truly return a result or an error. Error being a variable or baked into the type system doesn't change the practical result. You must handle the error or purposefully ignore it. > only Rust actually forces you to handle errors. When you have two programming languages which makes you handle the error, the word only becomes a little invalid. Semantics doesn't change the result. You have to acknowledge and act on the error either way.
- resonious 2mo ago> if the code goes boom, it's on the developer This is the same argument C (and Zig!) people have for manual memory management. You can avoid memory problems by being a good developer.
- akerl_ 2mo agoThis comment could make the same point and be even more effective if wasn't written as a snarky retort in violation of several of the guidelines of the site ( https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html )
- kubb 2mo agoI think the GP deserves the snark. Uncritical praise of everything about a language isn’t intellectual curiosity.
- deleted 2mo ago[deleted]
- TACIXAT 2mo agohttps://pkg.go.dev/slices#Contains https://pkg.go.dev/slices#Contains ? Also, if error wrapping hurts you so much (I don't use it), just implement a project-specific error that works how you want. This could be something that is JSON serializable, that captures a line number at each return site, etc. It will take like 10 minutes to get your project's errors working exactly how you want. My projects usually do - log.SetFlags(log.LstdFlags | log.Lshortfile) // ... if err != nil { log.Println(err) return errors.New("Error doing the thing.") } That essentially logs a stack trace with line numbers up the whole error chain, each return adding the outer context. I only ever use errors.Is for os.ErrNotExist.
- wannabe44 2mo agoI know about slices module. But GP is not happy about generics apparently. I think your error solution is good. But still it's a poor imitation of Exceptions wherein you have to capture the stack trace manually, possibly incuring a perf hit (haven't measured), and write handling code in every layer. Made worse by the fact that people return desperate errors for even precondition violations which should be panics.
- hoppp 2mo ago1. There is nothing stopping you from implementing a Contains function. 2.That error handling is one of the best features. It makes me explicitly acknowledge the errors instead of letting them just happen. No error goes unnoticed! Each if err != nil is an explicit reminder to check, do I need to clean up? Do I need to log this error to a file? "And no more oh an error happened I wonder where" With LLMs verbosity is not an excuse anymore. Just generate it and focus on other things then
- gempir 2mo agoIt doesn't have a lot of style guides or linting though. You have to install and configure quite a lot of tooling for that
- Someone 2mo ago> I love the error handling Even if you prefer manually checking for errors after every call that might fail, I fail to see how one can love go’s verbosity. Compare go’s foo, err := bar() if err != nil { return ERR; } with something like (hypothetical) foo := bar() ||| return ERR; where the compiler, seeing that bar returns an Either<int,err> can enforce the presence of the ||| clause or, alternatively, require later code to check for errors if the ||| clause isn’t present. I think that’s both more robust (prevents one from forgetting to check for errors) and shorter (allowing for showing a lot more code on a screen or page)
- mayama 2mo agoThere are so many proposals for improving errors, even half implemented ones that are dropped. I even stopped checking pros and cons after a few. As ultimately everything got rejected and the message is that you have to live with verbose checking with llms now.
- bborud 2mo agoI think the examples are both bad along different axis. One occupies more lines, the other results in _more_ and uglier syntax. They’re both bad. So the question is which axis is worse. While the first occupies more lines I suspect I’d spend less time spotting it in the code. The physical shape of the expression is something my brain is used to seeing after 40 years of programming. Even when code grows more complex. The second is OK when it stands alone, but I am not so certain it would be as easy to spot in more complex surroundings. Even on a single line, there is something a bit ugly about the code. Even before we get to the desperate triple-pipe. That kind of reminds me of the desperate attempts at repairing JS after they realized its equality semantics were shot. Just heap more characters on it. The thing is: it is actually very hard to judge how ergonomic a language is by just looking at it. You have to use it and you have to use it enough to realize where the paint points really are. I’ve read through a lot of the responses in this discussion and I’ll be honest: I think a lot of people who criticize other languages (be they Rust, C, Go or whatever) aren’t very fluent in them. It takes a couple of years to develop fluency.
- eptcyka 2mo agoI love how during prototyping, the compiler will tell me off for having an unused variable and fail to compile. I totally love the idea of crashing when writing on a closed channel.
- sethammons 2mo agoIf you are prototyping, assign unused to the underscore. foo := thinger() _ = foo # no longer unused
- spockz 2mo agoI do love the batteries included attitude. Having benchmarking included as well as a mechanism to run tests to check (test) for race-conditions right from the language/build tool is amazing. My only wish is that go could become less verbose. There are several frontends to go that are more compact, compile down into golang, and then let you enjoy all the benefits.
- BobbyJo 2mo ago100% with you on every point. It's the only language I've worked in that lets me read other codebases without an hour or two of "wut?" happening, so they did something right!
- asdf88990 2mo agoHave you tried to read the Kubernetes or Docker codebases?
- thiht 2mo agoKubernetes is a behemoth, but the Docker (Moby) source code is actually pretty easy to get into (if you're already a Docker user and understand how containers work)
- asdf88990 2mo agoIf you think Docker code is easy to get into then you haven’t seen clean code.
- thiht 2mo agoThe point is in Go it's pretty hard to write code so ugly that it'll be hard to read. I'm actually quite confident I could quickly onboard on almost any Go codebase (Kubernetes might be an exception). When I used to work with Java, I very rarely even tried to read the source code of my dependencies because it was unreadable.
- BobbyJo 2mo agoYes, I find the K8s codebase pretty easy to read actually, but I am biased since I work with K8s and the codebase makes a lot of sense when you understand what everything does already.
- aaa_aaa 2mo agoWhen I moved from Kotlin to Go because of a job change. it was painful. Apart from its runtime benefits, it is overrated IMO. it lacks basic conveniences. Go is not a simple language, it is a primitive language.
- vander_elst 2mo agoI think that the best feature that go was able to create is a very strong community around the language, where practices are as important as the language itself. Maybe these practices are what makes the community strong?
- b7e7d855b448 2mo agoAlso not adding every single feature that could be nice is a good thing to me. Yes, there is a lot of syntactic sugar you could add, but this just ends up in even more debates and in the end it doesn't matter that much. There is a very clear path how to achieve regular things in go and that works fine for now