Earlier quoted context omitted.
> Density divorces us from context a lot more than physical distance on a screen. You mean " unreadable code divorces us from context". "Density" doesn't have anything to do with it until you get to the point where your code is so dense as to become unreadable. Moreover, "physical distance on a screen" is a strawman. The options aren't density and distance, they're density and not being able to see the code on the sc…
> You mean "unreadable code divorces us from context". "Density" doesn't have anything to do with it until you get to the point where your code is so dense as to become unreadable. As density increases, the difficulty of parsing also increases. At a certain, relatively early point, that difficulty rapidly exceeds the costs of scroll-and-scanning. > Moreover, "physical distance on a screen" is a strawman. The options…
I want off Mr. Golang’s Wild Ride (2020)
451–460 of 477 posts
Re: I want off Mr. Golang’s Wild Ride (2020)
#452Earlier quoted context omitted.
> It is acceptable for code whose maintainers value readability and simplicity over everything else. Errors-as-return values are less readable than conditions, not more - there's literally more visual noise on the screen. And if you want "simplicity", don't use a computer. Computers are intrinsically complex devices, users desire features with complex implementations, and our job as programmers is to manage complexit…
> Errors-as-return values are less readable than conditions, not more - there's literally more visual noise on the screen. No. When you make a function call, and that call can fail, then the happy-path and the sad-path are both things that you need to manage as a caller. Happy-path and sad-path are two equivalent states that both need to be accommodated by the program logic. Error handling code is not "noise". It is…
Re: I want off Mr. Golang’s Wild Ride (2020)
#453Earlier quoted context omitted.
Yes, but that is definitely not achieved by checking for errors every second line.
The value here is the few seconds of human attention given to the error at hand. The thought is irreplaceable. Like others mention, 90% of the, end up if err != nil { return nil, err } but thinking about it will, in my experience, make the system more robust to failure. At the very Least for your process you will decide on a goal of carrying on in the face of failures and repairing when things work again vs. just bai…
Re: I want off Mr. Golang’s Wild Ride (2020)
#454Earlier quoted context omitted.
Seems too many devs use go for something it is not meant for. Tried doing math calculations in go - not a good a idea. But for backend stuff like rest api, web servers, networking, sysadmin and devops tasks, it shines.
I mean, a lot of developers have or look for a golden hammer, coerce their favorite language in doing a task. And since every programming language is turing complete, it CAN work, but whether it's the most elegant is not guaranteed. I mean for math, similarly, Java and co wouldn't work very well either.
Re: I want off Mr. Golang’s Wild Ride (2020)
#455Earlier quoted context omitted.
Golang gives you freedom. Rust gives you seat belts. It depends on you what you value more.
would highly prefer my car to have seatbelts over "simplicity" and "freedom" if i plan to go over 30mph with it
To avoid the car analogy, let's use construction - an in construction building should be allowed to keep the scaffolding up while it's being built.
But maybe you should still clean the floors? Uh oh, it's getting away from me already.
Re: I want off Mr. Golang’s Wild Ride (2020)
#456Earlier quoted context omitted.
Cognitive complexity is not related to character count. The expression let x = f.a()?.b()?; is exactly as "easy" to parse as the code block of y, err := f.a() if err != nil { return fmt.Errorf("a: %w", err) } x, err := y.b() if err != nil { return fmt.Errorf("b: %w", err) } They are effectively equivalent in terms of cognitive load.
I disagree. These two bits of code cater to different ways of reading. The first caters to a happy-path reading, where the reader has the choice to yadda-yadda the error handling or mentally expand it. The second foregrounds the error handling on an equal footing with the other logic. I like your example, because this is exactly what happened in the application code I had to work with. In an application with complica…
Re: I want off Mr. Golang’s Wild Ride (2020)
#457Earlier quoted context omitted.
Cognitive load is unrelated to SLoC. This expression let a = x.iter().filter(...).apply(...).map(...); is equally or even potentially _more_ cognitively complex than this expression for _, v := range x { if !filter(v) { continue } vv := apply(v, ...) vm := map(vv, ...) ... }
focusing on a pedantic detail that i clearly didn't intend and which doesn't change my point. consider it from a blocks-of-code metric, or some better slightly more abstract metric, that isn't affect by simple things like whitespace transformations, and try assuming that we all understand that we should write code that isn't monstrous to begin with.
I would personally much rather maintain the code in the second example than in the first.
Re: I want off Mr. Golang’s Wild Ride (2020)
#458Earlier quoted context omitted.
> For example, Go error handling is shit What is bad about it?
Errors as return values is only acceptable for code that is so performance-sensitive that you aren't allowed to do dynamic memory allocations. For everything else, conditions+restarts are the correct answer, because errors-as-values restricts you to a single error-handling strategy and couples high-level code to low-level code as a result.
Also, the restart seems to imply that you should "handle" the error, but I think this is really overemphasized cause what are you actually going to do about it? There's nothing to do about a lot of errors except die, but this encourages programmers to just make something up they think might help.
Re: I want off Mr. Golang’s Wild Ride (2020)
#459Yes, the cross-platform stuff sucks on Windows. I’ve seen languages with a few different approaches, I’d like a moment to compare them here. I’m going to talk about some specific aspects of cross-platform compatibility but not attempt to compare one single aspect across many platforms. With C++, you can use the preprocessor to give you a string type which is UTF-8 (nominally) when compiled on Unix and UTF-16 (nominal…
Do you get posix_spawn()? That's a far superior API to the frankly horrifying and slow mandatory use of fork().
Re: I want off Mr. Golang’s Wild Ride (2020)
#460Earlier quoted context omitted.
Go always seems to be to be designed to be simple for the compiler (which, to be fair, has benefits: fast compilation is useful in a compiled language, to keep code-build-test cycles short) more than the programmer.
I never really understood this reasoning. To me the ideal thing would be a fast debug-compile mode that barely optimizes and a don’t care how slow release mode that uses every possible optimization for the end result. Rust is plenty interactive with its similar mode of working. Incremental builds are fast.
If you do have a really long running superoptimizer discovering things, then you'd want a way to write that back into the code so you don't need to discover it again.
Also, most of your program should be at -Os because it's not hot code and the important thing is to stop it from disturbing the fast parts. (Or because the aggressive optimizations actually make it slower. Totally possible with fancy ones like autovectorization.)