logoalt Hacker News

dmoyyesterday at 10:09 PM10 repliesview on HN

For a lot of stuff what I really want is golang but with better generics and result/error/enum handling like rust.


Replies

vips7Lyesterday at 11:39 PM

Me too. There’s a huge market for a natively compiled language with GC that has a better type system than Go.

The options I’ve seen so far are: OCaml, D, Swift, Nim, Crystal, but none of them have seen to be able to capture a significant market.

show 1 reply
Yoricyesterday at 10:33 PM

Have you tried OCaml? With the latest versions, it also has an insanely powerful concurrency model. As far as I understand (I haven't looked at the benchmarks myself), it's also performance-competitive with Go.

show 4 replies
Philpaxyesterday at 10:51 PM

You want https://github.com/borgo-lang/borgo, but that project is dead. You might be interested in Gleam?

evanmoranyesterday at 10:19 PM

I thought the recent error proposal was quite interesting even if it didn't go through: https://github.com/golang/go/issues/71528

My hope is they will see these repeated pain points and find something that fits the error/result/enum issues people have. (Generics will be harder, I think)

show 1 reply
qudattoday at 4:08 AM

I think generics ruined the language. Zig doesn’t have them

mixedCaseyesterday at 10:19 PM

OCaml is the closest match I'm aware of.

scythmic_wavesyesterday at 10:58 PM

Borgo [1] is basically that.

Though I think it's more of a hobby language. The last commit was > 1 year ago.

[1] https://news.ycombinator.com/item?id=40211891

hgs3today at 1:15 AM

Are you familiar with Zig's error handling? It's arguably more Go-like than the Rust approach.

throwaway894345yesterday at 10:31 PM

I cautiously agree, with the caveat that while I thought I would really like Rust's error handling, it has been painful in practice. I'm sure I'm holding it wrong, but so far I have tried:

* thiserror: I spend ridiculous and unpredictable amounts of time debugging macro expansions

* manually implementing `Error`, `From`, etc traits: I spend ridiculous though predictable amounts of time implementing traits (maybe LLMs fix this?)

* anyhow: this gets things done, but I'm told not to expose these errors in my public API

Beyond these concerns, I also don't love enums for errors because it means adding any new error type will be a breaking change. I don't love the idea of committing to that, but maybe I'm overthinking?

And when I ask these questions to various Rust people, I often get conflicting answers and no one seems to be able to speak with the authority of canon on the subject. Maybe some of these questions have been answered in the Rust Book since I last read it?

By contrast, I just wrap Go errors with `fmt.Errorf("opening file `%s`: %w", filePath, err)` and handle any special error cases with `errors.As()` and similar and move on with life. It maybe doesn't feel _elegant_, but it lets me get stuff done.

show 7 replies
oncallthrowyesterday at 11:15 PM

vlang