r/rust • u/rustacean1337 • Nov 17 '22
What are Rust’s biggest weaknesses?
What would you say are Rust’s biggest weaknesses right now? And are they things that can be fixed in future versions do you think or is it something that could only be fixed by introducing a breaking change? Let’s say if you could create a Rust 2.0 and therefore not worry about backwards compatibility what would you do different.
220
Upvotes
303
u/[deleted] Nov 17 '22
There is actually a wishlist for rust 2.0 somewhere on github, it's pretty interesting
35
u/[deleted] Nov 17 '22
Sometimes it's just too verbose
60
u/Sw429 Nov 17 '22
I've noticed a trend for introducing RFCs that attempt to make Cargo's feature system more complicated. Here is the most recent one I've seen, but there have definitely been others, and they all seem to be solving problems with
default-features=false.This may be a hot take, but I think the introduction of default features into Cargo's feature system was a bad idea. It leads to well-known problems like the one described in that PR, and the only benefit I can see is that you can split out functionality into features without having to bump the major version.
IMO, we are too scared of bumping major versions. Rather than having these complicated systems to avoid bumping major versions, I think we should embrace the fact that evolving and API is good, and that there is no shame in releasing a breaking change after you've already hit version 1.0.0.
154
u/mina86ng Nov 17 '22
71
u/haruda_gondi Nov 17 '22
Lack of variadic generics. Pretty hard problem, but I think they'll still retain backwards compatibility.
59
u/CryZe92 Nov 17 '22 edited Nov 17 '22
stride_of != size_of
Atm structs in Rust have padding at the end, just in case someone puts the struct into an array, except the padding is also there when the struct is not in an array, unnecessarily bloating up objects. So (Option<u64>, bool) is 24 bytes instead of 10.
57
u/veryusedrname Nov 17 '22
Luckily we have editions :)
17
u/[deleted] Nov 18 '22
not weakness but a big annoyance, cargo uses too much disk space, one of my project is taking 24gb now.
41
u/jcamiel Nov 17 '22
It's not a big weakness but I would like functions to accept named parameters, for instance:
12
u/zesterer Nov 18 '22
Lack of an effect system. This is becoming clearer and clearer as
asyncpervades everything, often in disjointed and troublesome ways.33
u/Due-Dog-1533 Nov 17 '22
Here is my top 5:
Ranges are a pain to work with (https://kaylynn.gay/blog/post/rust_ranges_and_suffering)
The borrow checker is too dumb (https://github.com/rust-lang/polonius) fixes a lot of this.
Too many synonymous ways (3) to specify trait bounds.
Handling of memory allocation failures. (https://www.crowdstrike.com/blog/dealing-with-out-of-memory-conditions-in-rust/)
Stdlib is too big (mpsc should not be in there)
34
u/watr Nov 17 '22
Orphan rule. When they manage to solve this, it will really be a huge advance (an advance on the scale of like when generics were added to Golang).
14
u/iamalicecarroll Nov 17 '22
there are quite some std design mistakes which can't be fixed since that'd be breaking change
7
u/extensivelyrusted Nov 17 '22
Compile times
19
u/[deleted] Nov 17 '22 edited Nov 17 '22
as a beginner, it's too damn complex and getting even more complex. The abstractions to make the code more succinct which are useful for normal "web" type applications have quite a learning curve.
Async kinda half baked and even more complex and has various limitations. Can't call async code from sync code. Also again async is more useful for "normal" applications and libraries...
The need to pick an async executor and incompatibilities between them.
Maybe there are some improvements to these issues lately that I am not aware of.
5
u/NotFromSkane Nov 18 '22
There is really only one fix I want for rust: Patterns being able to coerce derefs.
This should be allowed:
We don't have it right now because the Deref trait doesn't say that its implementations need to be cheap and it would be more expensive than expected if some deref implementation actually took a bunch of performance, but come on. This is just so painful.
Then if we're just talking about adding a bunch of feature bloat: Give me the
|>operator from the MLs16
u/matklad rust-analyzer Nov 17 '22
Unchecked growth: https://graydon2.dreamwidth.org/263429.html
9
u/sludgefrog Nov 17 '22
In addition to compile times, much lower guarantee Rust will compile for and be accepted on future game consoles by the platform holders than c++.
23
u/razrfalcon resvg Nov 17 '22
Working with shared mutable state is a mess, thanks to infamous
Rc<RefCell<T>>. This could be "fixed" by borrowing class objects from Swift.4
u/[deleted] Nov 18 '22
The RFC community tends to merge proposals for Cargo in Rust's RFCs, linking both projects. This is bad since we should have a clear separation between Rust (both the language and its features) and Cargo (which should only be the package manager and build system it claims to be). This would be fantastic to simplify developers working on non-Cargo tools (basically, everything that is not Rust in the industry). It could also help static analyzing tools or language servers be tool-independent (using
rust-analyzerwithout Cargo is currently a pain, same for IntelliJ-Rust, &c.).This can be easily done with some sort of specification on package management, which is also a problem in C++ on this side).
A clear specification of the Rust programming language is crucial to speed up the adoption of the language. Safety-critical industries would benefit a lot from using Rust instead of C-family languages. Moreover, it would allow other communities to create compliant and robust compilers. This is pretty important since for now, everyone tries to replicate the features of
rustc(or even worse, Cargo) but fails. Some projects simply cannot depend onrustc. For illustration, take this thread. Depending on LLVM's release cycle or always linking against some LIBC implementations is a no for some organizations.I also think that it would help to write awesome language tools, such as LSP servers or static analyzers since we could define the behavior of Rust and not guess what's the current implementation of
rustcis doing.It is up to the language team to try making it, if possible.
I do understand that it allows composability and stuff (some will even argue that it follows the so-called "UNIX philosophy" lmao) but instead it favors dependency hell and single points of failures. The problem here is that we end up with a lot of dependencies and transitive dependencies which we cannot easily control.
The granular control could be fixed with other toolings (requiring a better separation between Rust and Cargo) but the philosophy of "small crates" isn't probably fixable.
So recently I tried C++ after a long time, and I saw the problem of being too verbose. However, I find Rust to be the opposite, with the language adding sugar syntax on top of everything and hiding the real advantages of Rust. I would like to get an in-between.
I do think that it is most likely my opinion and that Rust's language team has other priorities, and it's totally normal!
This is a recurrent problem of
rustcand I won't write that much on the subject. You can simply Google it.But I'm not sure how to fix it and I don't have the knowledge of this. I saw folks saying that it is mainly code generation and LLVM and not compilation (which seems true since compiling procedural macros is loooooooong).
build.rs)I do not use it that much directly (I do not use Cargo that much in fact) but build scripts seem to be more of a hack than anything else. The problem solved by build scripts is to perform tasks that cannot be done by Cargo. Build scripts are not hermetic or safe by default and we do not easily have control over them.
Some projects would benefit from using real polyglot build systems (e.g. Blaze-like, Ninja-based, &c.), but the problem is that it is currently hard (to not say impossible) to program in Rust without Cargo, due to my first point. example
11
u/jpet Nov 17 '22
Lifetime system should be able to handle self-references, e.g.
It should also have a concept like
StableDeref,rentaletc., i.e. understand the idea that a value can own elements which aren't invalidated when the value moves.Noisy syntax.
clone()is just clutter in a lot of code (especially if it's cloning an Arc or Rc to a value without interior mutability--logically that's a trivial copy, even if means a counter gets incremented somewhere. Also in numeric code.)Rust is bad at literals. Lots of stuttering, lots of verbosity, runtime expense with
"some string".to_owned()that could have been avoided. Macros help paper over the worst cases but that has its own problems.Over-reliance on macros in general. It slows down compilation compared to generics (because after expansion there's just 10x as much code to compile), and makes things hard to understand and debug. Half the time "go to definition" in a library I'm trying to understand just leads to
impl_all_the_things!()which is no help at all.Lack of a way to compile generics into dynamic dispatch instead of monomorphizing only, leading to exponential code size blowup and making shared libs harder. (
&dyn Traitis nice, but not quite the same thing--this would still be statically typed, just a different call ABI.) Swift solves this nicely; I think Rust could copy that solution.Deref and indexing shouldn't have to return actual references; they should be able to return reference-like types too.
3
u/idcmp_ Nov 17 '22
Also, cross-compiling (compared to something like Go).
3
u/TheLordOfRussia Nov 18 '22
The human writing the code
3
u/mansplaner Nov 18 '22
Not in any order... Inconsistent quality in the crate ecosystem. Feature creep. Overall language complexity. Learning curve. General requirement to trust that a small number of people make good technical and governance decisions in perpetuity.
6
u/BenFrantzDale Nov 17 '22
As a C++ person, I’m put off by lack of overloading. Is that really right?
6
u/[deleted] Nov 18 '22
just 3 months of experience here, so far:
not being able to overload functions sucks (same function name with different parameters).
async/await is a clusterfuck without patching things by using third party crates.
can get quite nested sometimes.
5
u/78yoni78 Nov 17 '22
This isn’t something I see talked about, but I wish struct fields would have mutability like regular fields. I read it was once part of the language and was removed, and I think it shouldn’t have been
2
u/Scott-Michaud Nov 18 '22
100% tooling. CLion with the Rust IntelliJ-Rust plug-in is the closest to the experience that I get in other languages, but it'll just randomly fail for seemingly no reason. In fact, the reason why I'm here right now is to try to figure out why, over the last few days, both stable and nightly fail to expand certain match statements.
2
u/vtskr Nov 18 '22
Rust to C is same is Scala was to Java 5-7 years ago.
2
u/ericanderton Nov 18 '22
The biggest one for me: Is there a learning path for seasoned developers? Rust may need one.
I'm a self-confessed newbie when it comes to Rust... for at least the last five years.
Every time I carve out time to really learn Rust, it never goes well. My past experience with a multitude of other languages both serve and cut against me here. The borrow checker and the syntax both really want to sweep away bad habits, but in a way that is just difficult for some reason. I think the lifetime abstractions and associated meta-programming is the worst offender here.
For background, my experience with attempting Haskell was far worse, and wrapping my head around Go was a breeze. I think meta-programming is fun. I wrote a 6502 macro assembler for the heck of it. Yet I'm fumbling here.
Honestly, I could simply be missing a key tutorial or introduction somewhere. But some guide that teaches by comparison and contrast against popular compiled and scripting languages (e.g. TypeScript) might help adoption for folks like me. A guide for well-used idioms and how to address common compiler errors might also provide a better on-ramp.
Thanks for reading.
2
u/pjmlp Nov 18 '22
Compile times, this is really just not being the focus, other languages as complex get around it by having interpreters, or debug modes that are really light on compiler optimizations.
An npm-like ecosystem that makes it quite hard to understand what key libraries are mature, unless one is doing Rust as day job.
Many ecosystems currently ruled by C++ still don't have a big presence of Rust alternatives, in libraries and tooling.
Basic stuff like errors and async runtimers are still third party components.
5
u/Cold_Training869 Nov 17 '22
I find it too hard to read. Makes it a lot harder for it to become a common production language
2
u/CisWhiteMaleBee Nov 18 '22 edited Nov 18 '22
Optional kwargs for functions perhaps?
Edit:
Also this is less of a problem with the language itself and perhaps more with the documentation - I feel like there’s a lot of beginner learning material and a lot of advanced learning material but not a lot of the intermediate stuff.
Also also, I find crate documentation to be difficult to understand. But I’m also coming from Python where a lot of popular libraries are pretty well-document and practically spelled out for you
2
u/v_maria Nov 17 '22
it's not very expressive. writing rust is rather mechanical
2
u/Trk-5000 Nov 17 '22
Line noise.
1
u/hardicrust Nov 18 '22
I see less need for Rust 2.0 and more for completing what we have started:
1
u/GeeWengel Nov 18 '22
The one that hits me the most still, is that Iterators are a pain to pass around, return etc.
1
u/[deleted] Nov 18 '22
A more mature ecosystem of libraries/frameworks.
1
u/[deleted] Nov 18 '22
I'd say it's syntax sucks a bit. Definitely doesn't remind you of a systems programming language.
Although once you get used to it, it's actually pretty handy. Problem is, get used to it. Especially from a C/C++ background.
1
u/rafaelement Nov 18 '22
hype; as in, high-profile projects start to introduce Rust, which is somewhat of a risk PR-wise if done too early. Remember Servo? :)
1
u/[deleted] Nov 18 '22
I remember reading this great blogpost exploring contexts and capabilities:
https://tmandry.gitlab.io/blog/posts/2021-12-21-context-capabilities/
Would love to see that in Rust 2.0 tbh!
1
u/troublemaker74 Nov 18 '22
As a newbie with experiences in a lot of other languages, the biggest weakness for me is the extremely large syntax. Coming from languages with simpler syntaxes like Elixir, Go, and Clojure... It's daunting to learn.
I'm enjoying it overall, and think that Rust is exciting for the space that it excels in. It's just not as joyful to learn as some of the other languages I've learned in the past (except for Go. Go's error handling always felt gross to me.).
1
u/dobkeratops rustfind Nov 18 '22 edited Nov 18 '22
I dont like to say "weakness" because the language is a great balance.
What would speed me up using it is tooling around it - autocomplete is evidently hard (2 way inference) - it's still not as good as C++, after 7+ years here :(
7 years ago I was saying we need stopgap approaches for that, like a haskell holes inspired wildcard for searching as part of the compile-edit cycle.
Yes its not part of the compilers job.
But practicality, we can't use complex libraries (like graphics/gui) as fluently as C++/C# without this constant inline help - there's just too much to remember, and moving out to the docs slows you down.
See these comments , its not just me.
https://www.reddit.com/r/rust_gamedev/comments/yuw54u/comment/iwehz3j/?context=3
safety multiplies this problem (you need more intermediate types and wrapper functions), so its a double-whammy.
I'm back to looking for extra assists.. like an assistant window to the side that *automatically* shows docs speculatively based on the current cursor location, to reduce the number of times you must break focus.
1
u/laralovesyou Nov 18 '22
try blocks
1
u/scottmcmrust Nov 18 '22
Using
:instead of=in struct literals.1
u/drninjabatman Nov 18 '22
At this point I think the most common root cause of rust-related headaches at work are directly related to the fact
&mutshould be called&unique. It is very common that someone thought "I am going to mutate this so i better pass it as&mut" and then it's virtually impossible to use the resulting function. It's a big barrier to new users and it even bites more experienced rustaceans sometimes.(that and RPITIT but the latter is being fixed very quickly )
-1
u/VegetableBicycle686 Nov 17 '22
The lack of operations between different sizes of integer is needlessly awkward. It should be possible to add a
usizeto au8(resulting inusize) and even au32to achar(resulting inu32) without casts. This is something which reasonably could be fixed by writing some moreAdd/Sub/etc. implementations, perhaps in an edition.Also the decision to make the
Indexoperation (square brackets) generally panic if out of bounds makes it essentially useless for any application where panics are unacceptable.a[i]should returnNoneif out-of-bounds, instead of requiring a separate method,get().1
u/nagatoism Nov 17 '22
web and curd.
This is really due to most people would have better choice than rust in these areas.
So currently Rust web ecosystem is lacking out of box tools to build a backend for a website with a db and caches.
So currently you still have to fill a lot's of boilerplate code to fire up a backend. In java or go you just have a lot's well-done examples on github.
Also I think diesel is too complicated and not container-friendly.
ME ranting after hours on trying to build a simple website with Rust.
1
u/plutoniator Nov 18 '22
verbosity + complexity you can't opt out of
1
u/OutlandishnessOk4575 Nov 18 '22
ok this isnt a rustlang issue but an issue with the rust environment. There can be better profiling tools.
Maybe a language rant, I really wish for a Integer type or Decimal trait that acts as an umbrella for all primitive types that fit the categories respectively so writing generic functions becomes easier and no need for external crate dependencies.
Finally, a rant for the rust regex crate, no backtracking is painful.