Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Alternatives to Rust Programming Language
21 points by throwawaydsstr on Nov 22, 2021 | hide | past | favorite | 37 comments
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)




Ignore the drama. The language in its current state is great, and will survive bureaucratic spats.

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.


The holy grail isn't always memory safety without garbage collection, especially in standalone apps. If you have a magic garbge collector that runs instantly while taking no memory, then there's no reason to not use it. That also means that if a GC language gets as performant as Rust, Rust would lose part of it advantage.

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.


No other languages (except Pony, but it unfortunately never became popular) offers compile-time thread safety comparable to Rust, and this is an issue it cannot be solved with a garbage collector.

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.


Fair point, that's why I said that Rust would only lose part of its appeal and not all of it. I mostly do web stuff so my vision is influenced by that. In that context, Rust's strength is that you can get C++ like performance without the footguns. But in those cases, if you have a language that's easier to use and that doesn't use that much more resources than Rust, Rust would lose a part of its appeal.


> can serve almost as much HTTP requests as a Rust server based on Hyper

Do you have a link to a benchmark showing this?


I do. The benchmark results itself is here: https://aws1.discourse-cdn.com/standard11/uploads/ocaml/opti.... This comes from the OCaml multicore monthly news, the october 2021 edition: https://discuss.ocaml.org/t/multicore-ocaml-october-2021/882.... The benchmark's repo is here: https://github.com/ocaml-multicore/retro-httpaf-bench. However that image is not the whole story, and there's a bit more info here: https://watch.ocaml.org/videos/watch/74ece0a8-380f-4e2a-bef5.... In that video, the author says that the result vary depending on the load (sometimes Rust Hyper can end up above OCaml httpaf eio), that OCaml currently uses an io-uring backend while Rust doesn't, and that the results are for single core as previous OCaml implementations are single-core themselves.

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.


Zig and Nim are good bets. Both are pushing the state of the art forward on what is possible with system programming languages. D is probably another good bet.


D seems really neat to me. I didn’t realize just how wide the language was until a few years ago.

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.


That's news to me. I didn't know D had actors but I like it's meta-programming features because it cuts down on all sorts of boilerplate. I haven't used it that much, I just looked into it briefly for some low-level programming projects.


What's the state of safety in zig? does it allow footguns like in C/C++ ? What about borrow checker(it makes program safe. isn't it?)? I would like to know advantages as well


Zig does not have a borrow checker and allows footguns with relative ease. It's a C replacement, after all.

Sounds like you want Nim.


Zig is not memory safe, and is not meaningfully different from C and C++ in this way.


Anyway, not meaningfully different from C.


I believe it has release-safe mode, which protects against most use-after-free. This is sufficient safety for most applications, IMO.

I only see it getting safer from here, with some advances on the horizon, such as memory tagging. The language has a lot of potential.


The best answer I can provide is this document: https://ziglang.org/learn/overview/. It covers the main features of the language and how they compare to other languages like C, C++, and D. I personally think it has enough features like option types instead of null pointers, array bounds checking, generics, compile-time code execution, etc. for writing safe code but others might disagree.


If you need memory safety, precise control over low-level runtime behavior (e.g., no tracing garbage collector), concurrency, and a strong ecosystem, Rust is pretty much your only option.

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.


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

Ada enjoys a much wider use than Rust. It's been battle-tested in many different safety-critical, and normal programming environments for decades.


It's not in the top 50 languages on GitHub[1], its community package repository contains only 195 libraries[2], and it's in 2944th place among Stack Overflow tags[3].

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


Because Github language popularity correlates to relevance/quality... everybody knows that. I see PHP at 8, DM at 19 and CoffeeScript at 23 ... you are damn right Ada is irrelevant!

And yes I suppose Alire dose not have https://www.npmjs.com/package/isarray equivalent... damn, what a shame, totally disqualifying.


Yes, it does correlate, though not perfectly. In any event, I'm not talking about overall language quality, but rather open source ecosystem support, and whatever its other shortcomings, PHP actually does really well on that metric. Lots of people use it and there are libraries for pretty much whatever you want.

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


Ada. Old, but stable, with most of the same safety and speed.


Crystal. Someone wrote an OS out of it, but if you don't like GC then;

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.


Do you really care about the resignation of the moderation team when evaluating a programming language to use?

It doesn't affect your usage of it at all.


Crystal? It recently reached 1.0

https://crystal-lang.org/


It is hard to take seriously any language which didn't view "Windows support outside WSL2" as something to get sorted before 1.0


Is this the requirement of the OP though? I believe this is better than having nothing working on Windows and Crystal isn't difficult to master.


I'm not sure you know what "Windows support with WSL2" means. It means no Windows support, only Linux support, except Microsoft figured out how to put Linux software on Windows so "nothing working on Windows" is no longer a possible baseline.


If you want to work on distributed systems, Web backend, services, command line tools, etc, give Go (golang.com) a look.


Go is indeed a lovely language (and my personal hammer of choice), but wouldn’t call it low level and don’t think it would stack up against the rust/c/cpp bunch. If you are looking for something more high level and are willing to accept the tradeoff of having the safety of a garbage collector vs the performance and access to memory you get with rust/c/cpp then by all means give go a shot.


Yeah, I have worked with Go before and like it. But,i wanted to delve into even more lower language (without GC)


Roughly speaking your options are something like D, Zig, Nim, and Crystal.

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.


Don't forget that other languages also have community drama.

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 see zig as a potentially good alternative, however as of now the learning curve might be steeper than rust - not because of the language itself, but because of the poor state of the documentation. you might need to e.g. read the code of the std lib to figure out how to do certain things.

it needs more time to bake, but i'm looking forward to it.


What's the state of safety in zig? does it allow footguns like in C/C++ ? What about borrow checker(it makes program safe. isn't it?)?

I would like to know advantages as well


zig is not safe. it's more "ergonomic" so theoretically it's harder to write bugs than in c, but out-of-bounds accesses, use-after-frees and such can still happen because of programmer error in well-formed zig programs.

see also: https://github.com/ziglang/zig/issues/2301


Ada or D are the first options that jump to my mind. Maybe Swift as a possibility as well?


If its just for a fun personal project it might be interesting to try out Vala.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: