Live data from Hacker News

Ask HN: What's the best “higher level Rust” these days?

news.ycombinator.com

1–10 of 63 posts

Ask HN: What's the best “higher level Rust” these days?

#1
After playing with rust, I really like it. However, I generally don't need to write the low level code that justifies the increased complexity of the borrow checker. I would rather just pay the small price for a garbage collector. What language is most like rust, but at a higher level?

To me, these are the things that I like about rust that I'd want to see:

* Getting nullability right, not making the "billion dollar mistake". An integer shouldn't be able to be "null" unless it's part of the type.

* "Algebraic" (Sum and Product) data types. I love Typescript's "integer | null" syntax, but Option or something like that is fine, too. Typed structs/records or tuples.

* Errors as values. Goes naturally with the ADTs, and it feels very robust having the compiler enforce handling all the "Ok(..) | Err(..)" results.

* Focus on the data, defining structs and functions that work with structs. "Traits" as a means of abstraction. Not much in the way of inheritance.

* A nice development experience with a good package manager or other way of finding and using open source code.

* Vibrant and growing community.

* Can develop comfortably on Mac, deploy to Linux. Windows support a "nice to have".

Rust just nails all these things so well, it makes me want to use it even for things that don't seem like a good fit to me, like command line tools or web servers or scripts.

Here are the languages I can think of that might work, but I think they all have some issues:

* Ocaml - Rust's heritage, so it makes sense. But I feel like it's been around forever and hasn't really taken off. And doesn't it still have some sort of concurrency issue?

* Swift - So close to the ideal language, but does it work well outside of the Mac ecosystem?

* F# - Conversely, another great language, but does it work well outside of Windows?

* Java - The last time I used Java in earnest (many, many years ago) it still had the nullability issue, and was too class/inheritance focused for my tastes. I'm not sure if modern Java has improved on this yet.

* Typescript - Is this it? As a language, it actually ticks all the boxes, I think, which surprises me. But as a runtime it's nonexistent, and so you have to compile to Javascript and run on node and all that. I use it and really like it on the frontend. But how is it on the backend for ordinary non-web applications? How's its performance? It feels fiddly to get all the build stuff running, but maybe Deno or Bun is an option here.

* Nim - Kind of off the wall here, but it looks like it might actually be a contender from perusing its docs. But its community is pretty niche, and I don't have a good sense on if its growing or not.

Re: Ask HN: What's the best “higher level Rust” these days?

#4
post #2

Golang is continuing to grow to serve this use case. Just like explicitly handling errors though- you'd be expected to explicitly handle null values if you want to be safe from them

In many ways Golang is much lower level then Rust. So I wouldn't say it handles this case.

Re: Ask HN: What's the best “higher level Rust” these days?

#6
C#/F# being Windows languages is plain false; they have been cross-platform FOSS for just under a decade. TypeScript has a good number of features you're talking about, but I still wouldn't use it myself, because it is only a static checker on top of a much worse underlying system, and the static checker has plenty of holes big enough to fit serious problems through. Your best option as far as I can tell is Swift. It checks all the boxes, and in fact cribs quite a bit directly from Rust; its package repository is serviceable, if light on more niche use-cases; and it has supported Linux for quite some time, and recently started supporting Windows (though not the package manager, so not really).

But if Windows support is more important than a little bit of cognitive overhead? Just stick with Rust. It works, it's all the good things with few of the bad, it's more maintainable than anything mentioned, and the best language to write anything in is the language you already know.

Re: Ask HN: What's the best “higher level Rust” these days?

#7
post #2

Golang is continuing to grow to serve this use case. Just like explicitly handling errors though- you'd be expected to explicitly handle null values if you want to be safe from them

I like the idea of Go, except I don't think it quite has the type system that I like. I saw it got generics recently, but that actually wasn't very high on my priorities, compared to being able to say "this value is an integer and definitely not nil", OR, saying "this value is an integer OR it could be nil, and I want the compiler to make sure I'm considering the nil case."

And I appreciate that it has the "errors as values" like I was asking about, though, the types don't really force you to handle them, I don't think?

Re: Ask HN: What's the best “higher level Rust” these days?

#8
I can't really directly answer your question as I'm looking for pretty much the same—a language like Rust, just easier to use. I could imagine that being a language that transpiles to Rust so I sometimes head over to https://lib.rs to see what's new in the space.

Other than that I'm these days only mildly interested in languages that do not compile to WASM or transpile to JS because NodeJS and the browser have become my main platforms. IMO browsers offer an unprecedented way to develop GUIs for applications. People are unhappy with the perceived bloat of it but there's a web browser on almost each single consumer-facing (i.e. non-backend / server) machine these days and those things have become very, very capable. I just feel deprived of something when I go back to, say, Python.

I'm not very interested in TypeScript anymore b/c for the troubles and the benefits that typing gives you I want to have a solution that works at run time and ideally at compile time, too—I'd rather forgo the latter but not the first b/c of user input validation. Having to entertain that whole fancy and complex beast that is a good type system only to not be able to use it for run time checks is not what I want.

Just a few thoughts.

Re: Ask HN: What's the best “higher level Rust” these days?

#9

In my dayjob I use Haskell + Rust and in many ways I feel like Haskell is a higher level Rust.

Oh, of course Haskell should be on the list, at least from the language/types perspective! What about packages? Last I looked into Haskell (years ago), there was some light controversy over two competing package ecosystems, I think. Has that settled down?

Re: Ask HN: What's the best “higher level Rust” these days?

#10
I’m not sure that any language meets these criteria yet, but I’m placing my bets on Swift. There’s been a lot of activity in Swift’s various cross-platform working groups recently… whether or not that pans out remains to be seen, but within the community there’s absolutely a desire/will for Swift’s cross platform story to improve.

Personally speaking, if Swift’s Windows/Linux support improved and a cross platform UI framework were built for it, I’d have a hard time imagining using anything else for cross platform desktop development. Swift gets a lot right for that use case and strikes a good balance between ergonomics and safety.

Post reply on HN