6 ms·
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)
- holonomically 5y agoZig 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.
- throwawaydsstr 5y agoWhat'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
- holonomically 5y agoThe best answer I can provide is this document: https://ziglang.org/learn/overview/ 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.
- pcwalton 5y agoZig is not memory safe, and is not meaningfully different from C and C++ in this way.
- ncmncm 5y agoAnyway, not meaningfully different from C.
- verdagon 5y agoI 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.
- dleslie 5y agoZig does not have a borrow checker and allows footguns with relative ease. It's a C replacement, after all. Sounds like you want Nim.
- the_only_law 5y agoD 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.
- holonomically 5y agoThat'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.
- DLA 5y agoIf you want to work on distributed systems, Web backend, services, command line tools, etc, give Go (golang.com) a look.
- throwawaydsstr 5y agoYeah, I have worked with Go before and like it. But,i wanted to delve into even more lower language (without GC)
- geoah 5y agoGo 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.
- nice_byte 5y agoi 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.
- throwawaydsstr 5y agoWhat'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
- nice_byte 5y agozig 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 https://github.com/ziglang/zig/issues/2301
- _iziv 5y agoAda. Old, but stable, with most of the same safety and speed.
- kgraves 5y agoCrystal? It recently reached 1.0 https://crystal-lang.org/ https://crystal-lang.org/
- pie_flavor 5y agoIt is hard to take seriously any language which didn't view "Windows support outside WSL2" as something to get sorted before 1.0
- kgraves 5y agoIs 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.
- pie_flavor 5y agoI'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.
- fleventynine 5y agoIgnore 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.
- Zababa 5y agoThe 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.
- littlestymaar 5y agoNo 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.
- Zababa 5y agoFair 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.
- ibraheemdev 5y ago> can serve almost as much HTTP requests as a Rust server based on Hyper Do you have a link to a benchmark showing this?
- ameliaquining 5y agoIf 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.
- ajxs 5y ago> 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.
- tengbretson 5y agoIf its just for a fun personal project it might be interesting to try out Vala.
- ksec 5y agoCrystal. 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.
- OJFord 5y agoDo 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.
- ynik 5y agoDon'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.
- mindcrime 5y agoAda or D are the first options that jump to my mind. Maybe Swift as a possibility as well?
- errantspark 5y agoRoughly 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.