Earlier quoted context omitted.
You would crash the process. But, sometimes it's useful to do a little bookkeeping first.
That's not how recover is used in practice
Borgo is a statically typed language that compiles to Go
521–530 of 559 posts
Re: Borgo is a statically typed language that compiles to Go
#522Earlier quoted context omitted.
It's 2024. We need an effective means for error propagation and the battle-tested solutions are try/catch exceptions or Optional types. Go's error handling would have been great in the 1970's, it's not so great now some 50 years later.
Option types as error handling works but it requires proper syntax. Haskell can do it with do-notation and Rust has its special ? operator. Go has boiler-plate.
Re: Borgo is a statically typed language that compiles to Go
#523Earlier quoted context omitted.
What kind of "freedom", precisely, are you talking about? Freedom to write purely functional programs? Well, then you need Haskell or Clojure at least. Freedom to write small, self sufficient binaries? Well you need C or C++ then. CL is a regular multiparadigm language with a rich macro system, relatively good performance but nonexistent dependency management, too unorthodox OOP, with no obvious benefits compared to…
All of them. You can do imperative, functional, and oop programming in lisp. As for small libraries, it’s because cruft is an actual hindance in lisp. It’s like unix tools, you can do a lot of stuff with them, but a more integrated tool that do one thing better will fare worse in others. A big library brings a rigid way of thinking to lisp flexible model. Dependency management? Think of it like the browser runtime, w…
Re: Borgo is a statically typed language that compiles to Go
#524Earlier quoted context omitted.
> A tag-only union is not the same thing, even if you can find some passing similarities Why not? Seems to function the same way.
Enums produce values. Tag-only unions 'produce' types (without values). Realistically, there isn't a whole lot of practical difference. They were both created to try and solve much the same problem. As before, I posit that there is no need for a language to have both. You can do math on enum values, but that is of dubious benefit. In theory, tag-only unions provide type safety, whereas enums are just values so there…
Source? Is this something that is widely accepted, or just how you think enums should be defined.
My understanding is you are saying (using c++ as an example since it has both types) an `enum` is a "true" enum, while an `enum class` somehow isn't?
Re: Borgo is a statically typed language that compiles to Go
#525In the same vein, Go+ is also interesting, and its being actively developed. https://goplus.org/
Re: Borgo is a statically typed language that compiles to Go
#526Earlier quoted context omitted.
The difference is that all code paths are explicitly spelled out and crucially that the programmer had to consider each path at the time of writing the code. The resulting code is much more reliable than what you end up with exceptions.
I understand your sentiment. The debate of error codes vs exceptions will be debated until the year 3000, and further. One point to consider with exceptions: It is "impossible" to ignore an exception. The function implementation is telling (nay: dictating[!] to) the caller: You cannot ignore this error code. At the very least, you must catch, then discard. Another point this is overlooked in these discussions: Except…
Error returns are no different, assuming a proper implementation like the Result type in Rust. The difference is, unhandled error returns are found at compile time but unhandled exceptions only show up at runtime, when it's too late.
> Another point this is overlooked in these discussions: Exceptions and error codes can, and do, peacefully co-exist.
Both Go and Rust have panics, which are basically exceptions that are generally not supposed to be caught. They are used for unrecoverable cases like running out of memory or programmer mistakes. There's otherwise no reason to mix the two.
> Another thing about exceptions, especially in enterprise programming, you can add a human readable error message. That is not possible when only returning error codes.
I don't really know what you mean, it's equally possible in both cases. If anything, the error return implementation that Go uses is probably the most optimal out there when it comes to error messages. Most look like:
return nil, fmt.Errorf("opening file %s as user %s: %w", file, user, err)
Whereas most exception code will just dump a stacktrace since that's the default.Re: Borgo is a statically typed language that compiles to Go
#527Earlier quoted context omitted.
I would be happy if they would add in compiler some thing that'll allow to ignore error return values and in this case compiler would just throw exception^Wpanic from that point. I think it even makes sense for go purists, like you need to handle errors or get panicked. And I'd just mostly ignore errors and will have my sweet exceptions.
> I think it even makes sense for go purists, like you need to handle errors or get panicked. You think wrong. Go preaches that zero values should be useful, with means in the common (T, error) scenario, T should always be useful even if there is also an error state. Worst case, you will get the zero value in return, which is still useful. This means that the caller should not need to think about the error unless it…
I disagree with this blanket assertion. In a limited set of cases would I ever expect a result to be valid if there was also an error.
Also, when you disagree with what someone thinks, there are different ways to respond and using "You think wrong" is probably one of the most confrontational ways of responding.
Re: Borgo is a statically typed language that compiles to Go
#528Earlier quoted context omitted.
No one wants try/catch/exception in Go.
If it were true, it would be because nobody who wants exceptions uses Go. The use of the language is self-selected based on the match between preferences and available features, so then the preferences aren't surprising. But in fact, there probably exists a minority of developers who somehow had Go foisted upon them, and who would would like it to have basic features like exceptions.
Re: Borgo is a statically typed language that compiles to Go
#529Earlier quoted context omitted.
Objectively wrong.
They didn't mean literally 0 people.
Re: Borgo is a statically typed language that compiles to Go
#530Earlier quoted context omitted.
Enums and sum types seem to be related. In the code you wrote, you could alternatively express the Hot and Cold types as enum values. I would say that enums are a subset of sum types but I don't know if that's quite right. I guess maybe if you view each enum value as having its own distinct type (maybe a subtype of the enum type), then you could say the enum is the sum type of the enum value types?
Enums are exactly sums of unit types (types with only one value).