Ask HN: Alternatives to Rust Programming Language
I have been evaluating new low level programming language to learn and for my project.
Rust is deemed good but recent drama/resignation and quite difficult trajectory to master it has made me to search for alternatives.
I don't want to program in C and I don't want to deal with complexity, that is C++
So, what is best alternative to Rust apart from C and C++ ? It would be better if that language has innovative features (like borrow checking to write safe code)
37 comments
[ 3.2 ms ] story [ 76.0 ms ] threadI only see it getting safer from here, with some advances on the horizon, such as memory tagging. The language has a lot of potential.
Sounds like you want Nim.
I thought it was just a C, but a little nicer and then I learned it had all sorts of stuff, like an actor framework built in.
it needs more time to bake, but i'm looking forward to it.
I would like to know advantages as well
see also: https://github.com/ziglang/zig/issues/2301
https://crystal-lang.org/
Other languages may be more ergonomic or have more batteries included, but none of them can offer the holy grail of memory safety without garbage connection.
For example, OCaml is getting multicore and effects, and can serve almost as much HTTP requests as a Rust server based on Hyper. C# is getting performance improvements too, and lots of them.
It isn't discussed as much nowadays, because people more focus on the memory management side of Rust's benefit, but it was the reason Rust was designed in the first place, and it has no competitor in this area: if you need to do any kind of significant multi-threading in you application, then Rust is a game changer.
Do you have a link to a benchmark showing this?
I do feel that this benchmark is incomplete. I'd like it to see the results while using all of the cores of a machine, and I'd like to see different type of loads. I do think that the results are impressive: performance between Go and Rust is great. I do hope that it stays this way with multicore.
The alternative that comes closest to being viable, in my view, is Swift. Swift currently offers memory safety or concurrency, but not both at once. They're working on fixing this, but they haven't yet. Additionally, hopes that it would grow a strong ecosystem for non-Apple platforms (like Linux servers) don't seem to have panned out, largely because Apple owns the language and they don't seem to care very much about this use case.
As for the other low-level languages I'm aware of that aren't C or C++ or assembly and aren't hopelessly obscure:
Ada seems to be interested in adopting Rust-style memory safety, but (as far as I understand) it hasn't yet. It's also not a widely-used language with a strong ecosystem, at least outside of some narrow application domains that probably aren't what you have in mind.
D offers memory safety or precise control over low-level runtime behavior, but not (as far as I understand) both at once. It also doesn't have a strong ecosystem.
Jai doesn't have a publicly available implementation.
Nim offers precise control over low-level runtime behavior or concurrency, but not both at once (because threads can't share memory; there seem to be ways around this with globals but I'm not sure if they let you do everything you can do in C/C++/Rust/Swift). Also, precise control over low-level runtime behavior isn't the default; you have to opt in. And it's not a widely-used language with a strong ecosystem.
Objective-C isn't memory safe, has no plans to fix this, and its ecosystem is likely to decline with time as Apple pushes people to abandon it in favor of Swift.
Verona is a research project without a working implementation yet.
Zig isn't memory safe and has no plans to fix this. It also doesn't have a strong ecosystem. (I don't know anything about its concurrency support.)
If you don't need precise control over your program's low-level runtime behavior, then there are many options available to you. (Go, despite sometimes being marketed as a "systems" language, is in this category; I would also classify Julia, Kotlin/Native, and V here.) More details about your requirements would be needed in order to choose among them.
Ada enjoys a much wider use than Rust. It's been battle-tested in many different safety-critical, and normal programming environments for decades.
Yes, there's lots of Ada code in safety-critical applications that have their own resources and development methodologies isolated from the regular open-source and open-source-adjacent ones. This has very little relevance for someone who is starting a project that they presumably intend to rely heavily on preexisting libraries for, and who presumably doesn't want to pay for a support contract.
[1] https://madnight.github.io/githut/#/pull_requests/2021/3 [2] https://alire.ada.dev/crates.html [3] https://data.stackexchange.com/stackoverflow/query/1520700/r...
And yes I suppose Alire dose not have https://www.npmjs.com/package/isarray equivalent... damn, what a shame, totally disqualifying.
(I wouldn't recommend CoffeeScript for a new project, but these tend to be lagging indicators, and for a long time it was one of the better options for dealing with JavaScript's shortcomings. DM isn't relevant to this analysis because it's not a general-purpose programming language at all; it appears to be a domain-specific language for making multiplayer role-playing games, and for all I know it works perfectly well for that purpose.)
Alire is part of an attempt by the Ada community to make their language suitable for general-purpose open-source-adjacent development of the kind that, e.g., a solo developer or startup building an app might engage in. This attempt appears to be in its infancy, which is why Alire only has 195 packages; it's not because the Ada community looked at the state of their ecosystem and decided that 195 packages plus the standard library covered everything that was needed and so people shouldn't write any more packages. This is orthogonal to the wisdom, or lack thereof, of npm's culture of many small packages; even if you concentrate on a smaller number of well-maintained packages, you need more than 195, because there are more than 195 broadly relevant domains of application development. Alire just isn't ready yet for more than the most basic real-world usage.
Again, lots of people do write Ada code for important applications, but they're not using Alire, but rather alternative, better-established resources that work well enough in huge organizations but aren't really accessible to a solo developer.
Zig, my view is that it is practically a modern take on C, or commonly known as Better C.
There is "Das C" or "D as C", if you are looking for something similar to Better C.
Or if you want something that is extremely well polished, Ada.
But we are all on HN after all. So it is only fair to say nothing can ever be as good as Rust if you want memory safe. You should just ignore the drama and use Rust.
It doesn't affect your usage of it at all.
Just because Rust's drama made it to the HN front page this day doesn't mean that other languages are any better in the drama department -- I think it just means that HN is obsessed with Rust.
I would say your best bet actually is Rust in terms of RoI on self-investment. Rust likely has the brightest future and the most active community, good docs and momentum to build out crates to do the day-to-day things you'll end up tackling.
That being said I gave Rust a hard look a couple years ago, got through most of the book but if I need something to happen on time I still find myself reaching for C nine times out of ten. Personally I rarely deal with things that get too complex so C's ability to just do the thing you want without getting in your way is invaluable to me. If it ever becomes a problem I think that's the time to rewrite in in Rust, but C is a fantastic language.