Live data from Hacker News

Borgo is a statically typed language that compiles to Go

github.com

521–530 of 559 posts

Re: Borgo is a statically typed language that compiles to Go

#521
post #515

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

Right. In practice, people don't even realize that Go has an exception handling system (see rest of thread) to use.

Re: Borgo is a statically typed language that compiles to Go

#522

Earlier 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.

Honest question - do you think there's a better way to do it?

Re: Borgo is a statically typed language that compiles to Go

#523

Earlier 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…

You should probably reread what I wrote, and lay off your patronizing attitutde. "It is just better, you do not get it" won't work here. Yes you can do functional in Lisp, as you can do it in even in C, but why? The support for functional style is laughable, compared to Haskell or even Clojure. CL advocates are fanatically fail to accept bitter truth: CL is dead language with once great set of features which now present in many many other languages.

Re: Borgo is a statically typed language that compiles to Go

#524
post #470

Earlier 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…

> Enums produce values. Tag-only unions 'produce' types (without values).

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

#526
post #258

Earlier 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…

> 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.

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

#527

Earlier 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…

> T should always be useful even if there is also an error state.

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

#528
post #202

Earlier 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.

I like go for the most part, but the error handling drives me bonkers. I'm a big exceptions/errors with try/catch/finally statements person. They do a MUCH better job of forcing you to handle exceptions/errors than return values. I'm sure this will start some argument of why returning an error value is better. I've spent the last 35 years programming in a large number of languages and my _personal_ opinion is that try/catch trumps returning error results.

Re: Borgo is a statically typed language that compiles to Go

#529

Earlier quoted context omitted.

Objectively wrong.

They didn't mean literally 0 people.

Then they shouldn't use absolute statements like "No one", right? Otherwise you have pedants (a group that includes myself from time to time) that, rightfully, point out that your absolute statement is, in fact, not an absolute.

Re: Borgo is a statically typed language that compiles to Go

#530
post #290

Earlier 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).

Regardless of the rest of this thread, I appreciate this comment. It helped crystalize 'enum' in the context of 'sum' for me in a way that had previously been lacking. Thanks.
Post reply on HN