News for hackers. Stuff that matters.
Re:Conc: Better Structured Concurrency for Go by ikiris on Wednesday January 11, 2023 @08:56PM (#34348042)
Why the heck are you writing web apps that panic?
Re:Conc: Better Structured Concurrency for Go by aetherane on Wednesday January 11, 2023 @09:36PM (#34348439)
It is pretty easy to have accidental panics in Go, for instance due to a runtime assertion that unexpectedly failed
Re:Conc: Better Structured Concurrency for Go by preseinger on Thursday January 12, 2023 @06:27PM (#34361737)
Runtime assertions without defensive checks are programmer errors that are not difficult to spot in code review and should not be expected to make it to deployed code.

    // RED FLAG
    x := y.(type)

    // good
    x, ok := y.(type)
    if !ok { return an error }
Re:Conc: Better Structured Concurrency for Go by jasonhansel on Wednesday January 11, 2023 @09:00PM (#34348092)
Because people make mistakes?
Re:Conc: Better Structured Concurrency for Go by philosopher1234 on Thursday January 12, 2023 @01:00AM (#34349762)
Classic Go programmer. This is why I use rust B)

(joke)

Re:Conc: Better Structured Concurrency for Go by unscaled on Thursday January 12, 2023 @04:04AM (#34350934)
Joking aside, you could clearly plot the probability of running into a runtime error by programming language.

Of course, a language with less runtime errors is a far cry from being a panacea. Avoiding runtime errors is not the same as avoiding all categories of bugs. And while I personally prefer stronger type systems - they definitely come with increasing levels of cognitive cost.

But I still feel that the type-safety vs. runtime trade-off is more often ignored, underestimated or undersold than it is being hyped. Yes, certain languages (cough Rust cough) are being hyped, but not the conscious choice of balancing programmer learning curve with runtime type-safety.

And while on the topic of Rust, it's probably not the best choice for a language that sees less runtime panics. Especially since unwrapping an error is always the easiest way to handle an error, and thus quite common. But lazy error unwrapping aside, Rust does avoid null dereference exceptions, type casting exceptions and most types of race conditions that can be quite prevalent with go[1].

[1]: https://songlh.github.io/paper/go-study.pdf

Re:Conc: Better Structured Concurrency for Go by unscaled on Thursday January 12, 2023 @03:45AM (#34350798)
This is equivalent to asking "Why the heck are you writing code with bugs?"

Sure, if we could write code without bugs, we wouldn't need to suppress panics. But since we do tend to write code bugs and some of them are bugs that can be detected by the runtime - we get panics.

If you hate panics, you can do better than Go and go for a language with a stronger type system, where you won't get nil pointer panics or interface conversion panics, but even an almost onerously-tyepesafe language like Haskell still panics on some bogus operations such as division by zero or trying to read the head of an empty list. Perhaps Idris really have no runtime errors but they are quite niche.