r/rust • • 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

390 comments sorted by

303

u/[deleted] Nov 17 '22
  • compile times. Fixable: no, only improvable.
  • learning curve. Fixable: no, only improvable.

There is actually a wishlist for rust 2.0 somewhere on github, it's pretty interesting

4

u/rustacean1337 Nov 17 '22

That sounds interesting, I’m going to try and find it!

99

u/pluots0 Nov 17 '22

Are you familiar with the WIP cranelift backend? It is supposed to improve compile times to the point that I would consider them “fixed”

I think the general idea is that rust will start having the cranelift backend be the default debug choice, since it’s going to be much faster but can’t do heavy optimizations. Then use the standard LLVM backend (or new GCC backend) for release mode

127

u/[deleted] Nov 17 '22

I'm actually going to work on cranelift for my bachelor thesis next semester and I'm super stoked 😃

That being said, rustc will still be doing the same amount of work to product CLIF instead of LLVM IR. rustc does a lot and that's why we love it. Many techniques considered idiomatic in Rust put a lot of pressure on the compiler - compile time generics with monomorphization, deeply nested generic type signatures to tickle as many compile time guarantees out of the type system as possible... I think many of these things cannot be "solved" but represent a tradeoff and value judgement the Rust community has made and continues to make. I personally love those values, so I don't complain about the compile times!

19

u/pluots0 Nov 17 '22

That’s awesome! Hopefully you can figure out some great and speedy optimizations for the project.

Yeah, it can’t solve everything, but it still seems like build times generally are improved by 20-30% which is still massive.

6

u/robin-m Nov 18 '22

Awesome!

I think that looking on the other side of the zig fence is valuable. They plan to be able to recompile a single function and hotpatch it into a binary, allowing sub-1s of incremental rebuild, even when working with codebase with milions lines of code.

3

u/WrongJudgment6 Nov 17 '22

CLIF? Cranelift Intermediate?

→ More replies (5)

10

u/nikivi Nov 17 '22

Anything you lose from using Cranelift for debug builds already or its not yet ready?

14

u/pluots0 Nov 17 '22

To my understanding it works and isn’t far from primetime, but may still be quite buggy just because it’s new.

If you’re up for it, trying it out isn’t all that bad. You need to clone & build the repo or get the artifacts from the repo’s GitHub actions, then you can use it directly like cargo. Link to the instructions: https://github.com/bjorn3/rustc_codegen_cranelift#usage

3

u/Zettinator Nov 18 '22

But cranelift only appears to improve the codegen, no? And codegen isn't really the biggest problem, the compiler frontend is.

→ More replies (1)

28

u/azure_i Nov 17 '22

the learning curve is the real headache, because it makes it much more difficult to convince other people to try it. So even if you want to use Rust, you are stuck trying to get other people in your team and org to go along with it too and a lot of people dont want to or dont care to invest so much time learning it

19

u/mindmaster064 Nov 18 '22

The learning curve isn't bad if you were doing secure/bug free programming in the first place. Rust just forces you to do what you were supposed to be doing. Many things are actually easier or better in Rust - like the zero-cost abstractions, iterators, and so on. They just work totally better than other languages, and I mean 100% better. The thing is if you're a shitty programmer then Rust will wreck you mercilessly at the compiler and torment you for days before you really get anything up and working. You'll probably figure it out in a few days of grinding through the documents, but few people lack the patience and just want to be able to slap anything they code into the compiler and let it run. Your worst colleagues will be the ones constantly struggling with the compiler and Rust will automatically remind them of their position on the food chain.

If your team is not using OOP at all then moving to Rust is just an insurance policy not a paradigm shift. The payday will be when you can jettison garbage collectors and get half your memory back. (God, the GC in so many languages is so terribly bloating...) If you need it fast, safe, and correct then Rust is still the best language on the planet. Nothing will do what it will do, nothing... Other languages are not even close. The only language that is even SLIGHTLY close is C and you take pain with that. Once you use C then you have a lot of other problems like: "How do I implement collections?", "How are we handling errors?", "What is thread safe?", etc... You are going to spend just as more time figuring that out than you would have replacing your knowledge of C with Rust. C does this all with a 'hidden cost', but still requires the same standards to be held as Rust applies to your code intrinsically. It's not a savings to use the other language, it's just a potential error because it relies on the programmers understanding of these concepts rather than applying some sort of consistent paradigm. Many might look at that as more work (using Rust), but I look at as, "I do not have to wonder if the other people working on my project are doing things in the same secure way as I am." That is a constant problem in other languages. More time is spent enforcing the security and stability of C code than programming it.

The caveat being some ideas are just not implemented in Rust yet and may or not be ever because they can't. C doesn't care if you want to abuse it and make it do bad things. In Rust, you have to put things in unsafe blocks or access the low level parts of the std library to get to break anything. You have to be intentionally trying to break them, and it's obvious that when you are doing something glitchy the 'unsafe' blocks all over the place tell other people you are breaking the envelope and to apply extra scrutiny these sections of code. Just because Rust does this a lot of problems are immediately averted. In other languages, there is nothing flagging the code inside the code itself that you are doing something like this and unless someone is familiar with what you're doing they probably don't even understand that you're in this territory. Write that code in C or C++, come back in a year, and hand it to someone else to read. Do they still know you are doing the glitchy/low-level thing? Not a problem in Rust, it's in the unsafe block and everyone knows you are doing something special.

Most of the savings of the Rust is not your time as a programmer it will probably take more time to code anything in Rust. But, that time you've spent won't be spent on bug fixing crap that works. That's the trade, and it's a big one. The most prolific developers probably spend only 10-20% of their time writing new code. That is the real problem Rust is trying to fix - it allows you to get back the bulk of that 80% and make it more like 20% bugs, 80% new development... That's why you use Rust. There is no other real reason. (C can do everything Rust does, but without that advantage.)

12

u/anengineerandacat Nov 18 '22

The thing is if you're a shitty programmer then Rust will wreck you mercilessly at the compiler and torment you for days before you really get anything up and working.

Or you are literally coming from a language where lifetime management is automated and isn't your problem.

Has nothing to do with being a shitty programmer and more about willing to learn and gain mastery over the subject.

I can somewhat understand if someone who spent 13-14 years on C/C++ or C# went "Fuck that" to Rust; lifetime management is pretty massive overhead when you need to constantly think about it.

It's like grabbing someone who has been driving an automatic vehicle all their life and suddenly putting them into a manual; they are going to struggle and some may even hate the experience because the pro's don't outweigh the con's. This doesn't make them a bad driver.

→ More replies (1)

7

u/aikii Nov 18 '22

I mean you're right but the length of the answer is meme material

→ More replies (2)

5

u/buyIdris666 Nov 20 '22

Meh this is a bit too rosy. Rust is the best language in the world for low-level work. If performance is not top priority Java is usually a better choice.

All the memory guarantees Rust gives you with zero of the lifetime management, runtime code generation, fast reflection, amazing runtime monitoring, and far faster compile times.

And the new Java GC's can do 300 microsecond collection so pause times usually don't matter.

→ More replies (3)

18

u/mindmaster064 Nov 18 '22

The two most important things to do in Rust:

  1. Make sure you are linking with lld (edit ~/.cargo/config)
  2. use the 'cargo build --jobs $(nproc)' to use all your cores.

Those two things alone will make your build time go about 20x faster. By default, Rust does the linking with whatever the 'cc' compiler is on your machine and probably will only use a single thread/core.

You can also put this same content either in #1 or your Cargo.toml file:

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.x86_64-pc-windows-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]

[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "linker=clang", "-C", "link-arg=-fuse-ld=lld"]

You only need the relevant line and some iteration of lld installed (a clang complete install would have it, but some distros like Ubuntu let you install it by itself.) You only need the relevant targets here that match your architecture on the machine you're building on/for. You can ignore the rest. Personally, I just use the config file setup rather than doing it for every single project.

13

u/rvdomburg cpal Nov 18 '22

use the 'cargo build --jobs $(nproc)' to use all your cores.

Doesn't cargo do that by default? https://doc.rust-lang.org/cargo/reference/config.html seems to say so.

→ More replies (1)

2

u/LadulianIsle Nov 18 '22

This does impact final executable runtime speed, right? (Specifically for the number of jobs)

Something about optimizing code being compiled across threads?

4

u/mindmaster064 Nov 18 '22

This is functionally equivalent to doing something like: 'make all -j $(nproc)' using a C type build system with make/configure. It has all of the same caveats/advantages. It has nothing to do with the runtime which would use whatever idea of the cores/threads your program is aware of. Remember 'cargo run' after the build is not in the compiler space anymore it's just running whatever is in the target directory for debug or release. The '--jobs' only speeds up what would happen if you run 'cargo build' or 'cargo build --release', essentially... If that is clear enough.

11

u/armchair-progamer Nov 18 '22

verboseness. Fixable: no, only improvable.

Most people think of Rust as the opposite of verbose, and it's true that Rust is very terse for what it tries to accomplish: a safe, efficient language. But the fact that you need to explicitly specify lifetimes and trait objects and cloning, there is no GC and not everything is a dynamic pointer, means you will never be able to write code as terse and easily as you could in say, C# or Python

6

u/[deleted] Nov 18 '22

Personally I think the quest to save a few characters here or there when writing code has ruined the readability as well as the ease of building parsers/tooling (due to optional syntax) for so many languages it really isn't worth trying to go that way.

2

u/[deleted] Nov 18 '22

Tbh it's great that there is no garbage collector. The lifetime system is so much better and safer.

2

u/aikii Nov 18 '22

I got that impression about verbosity at the very beginning - and it's worth mentioning because that idea sticks ... but which language really beats it, and is it that much an obstacle in being more widespread ?

In practice : even compared to python, it's not that obvious if you consider fully type-annotated and production-ready python code. Also, on that regard one should mention the elephant in the room: Go is incredibly more verbose and yet is way more frequently used in companies than Rust. And I say that having been python developer for 10 years and now go developer for 1 year.

45

u/pickyaxe Nov 17 '22

I personally think the Rust learning curve is highly exaggerated, at least for the features most people would have a use for.

60

u/kukiric Nov 17 '22 edited Nov 17 '22

Lifetimes are a pretty big hump for newcomers and IMO not exaggerated at all. One of my friends almost dropped a project after several days of hitting his head against the wall trying to use mutable state in an async callback, which is trivial in garbage collected languages.

6

u/not_a_weirdoo Nov 17 '22

I tried to use an async callback with an internal state without having to put it in a box and pin it, finally gave up and use a struct with an associated async function instead 😄

9

u/[deleted] Nov 17 '22

Most usecases do not involve async callbacks though

5

u/martin_n_hamel Nov 18 '22

My first rust project was a web server with actix, Everything was async and coming from node a lot of things were non trivial. Async blocks in closure are really not as simple as they should be.

I'm still happy I did it. The result is fast and secure. But async closures are an incoming feature and I can't wait for them to be released.

→ More replies (3)

9

u/JarWarren1 Nov 17 '22

I think the learning curve varies greatly depending on which languages you already know.

If I hadn’t already been very comfortable in C I think I would’ve really struggled with rust

14

u/slashgrin rangemap Nov 17 '22

I'm convinced that there are things that could be done about compile times that would radically improve the situation for many real world use cases, even if "straight line cold build" can't be improved much.

I'm mostly thinking of things like first class sccache integration, or something like it, with support for an active mode for sending compilation jobs to a build farm. This could help enormously for teams working on the same code bases.

For my own use, I have some shell scripts that let me work on my crappy old laptop as a thin-ish client and use my powerful desktop PC as a builder, and then end up with the final binary ready to run on my laptop. (Kinda like cargo-remote.)

I also wonder, as rustc moves to a more query-based compilation model, whether the problem of feature flags making it hard to share pre-compiled artifacts might be mitigated. E.g. if the compiler could emit a shareable blob of compilation "answers" that another instance of the compiler could use, maybe it could just ignore the bits that are irrelevant because they were affected by the active features. Or you could even run it in a mode that produces an "answers" blob containing code for several different combinations of features.

I guess to summarise what I'd be most excited about, it's solutions that let me bypass compiling things locally at all in many cases rather than just speeding up rustc.

4

u/[deleted] Nov 17 '22

I see this a lot, I'm working on my first Rust project, it uses a couple of crates, and it compiles (debug, unoptimized) in no time at all.

Is my project just not big enough, is my 5800X fast, or am I missing something?

9

u/[deleted] Nov 17 '22

Small project probably. Also, not many dependencies I assume. Once you're using a bunch of producedural macros which in turn use syn and quote, do a clean release build and you'll probably wait a little while.

You can also get a taste of the compile times by installing some applications from crates.io. Nushell and "just" are gems I recently added to my cli toolbelt :-)

→ More replies (5)

1

u/jkoudys Nov 18 '22

Strong agree on the compile times, but more skeptical on the learning curve. I find devs often project what's unfamiliar to them as being challenging for new devs. But concepts like lifetimes and borrowing in rust don't seem unusually arcane to a completely new dev. It's more to keep track of vs a GC'd language, but someone starting in rust vs C might have an easier time learning rust's consistent rules vs manually tracking and freeing allocations in C.

Even vs a GC'd lang, sometimes rust is simply frontloading the mental effort. eg I built an lru cache on top of some high cpu + blocking library. The experience had a gentler learning curve, because the compiler was offering me good suggestions the whole time, and made sure I put the cache in the appropriate scope and spawned a separate thread with messaging correctly. I would've had to do all that stuff with python too, but could've had something working poorly for a bit while I inevitably added those things.

2

u/[deleted] Nov 18 '22

Totally agree! I think it depends on what is meant by learning curve.

The learning curve to make something that kinda, mostly works, doesn't need to be maintained and runs sufficiently fast... Rust is the worst imo, worse than C/C++. Those languages are full of inconsistencies, but they often just run the terrible mess you wrote. On the other hand, the borrow checker really likes to kick you while you're on the ground if you don't play by its rules. Completely different languages like Python and Go take the first place here, Rust is simply not a top contender.

The learning curve to create a robust, correct, perfomant and non-trivial program... Rust takes the cake, best in class, no competition in sight.

I personally do not care about the first definition, I'm not interested in writing software like that. But I've come to learn that others do. I don't think Rust should strive to compete in that space, but we need to be aware that some people care about that use case.

I've litterally had discussions with my boss about Go where he was like, it's not that bad to crash on a nil pointer dereferences in production. You get a bug report, fix it and redeploy.

1

u/ItalianFurry Nov 18 '22

Do you have the link to the 2.0 wishlist? O.O

→ More replies (1)
→ More replies (14)

35

u/[deleted] Nov 17 '22

Sometimes it's just too verbose

16

u/rustacean1337 Nov 17 '22

That for me is actually on of Rust’s strengths.

20

u/[deleted] Nov 17 '22

Same, I worked in C ( embedded ) and it's a pain handling all the conditions, error codes, returns etc.

But sometimes Rust gets soo nested, and it's hard and ugly to read ( say, get an option, map it, iterate over stuff and the function you apply can fail, then do collect results, transpose stuff, map the error if needed etc. ). It's fine but sometimes it just gets me :D

1

u/[deleted] Nov 17 '22

Example?

→ More replies (1)

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.

33

u/[deleted] Nov 17 '22

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.

Yes I was really hoping that was the direction Rust would go in. I don't mind staying on an old version. It might be annoying to upgrade the whole project with breaking changes, but that's the projects problem, not the language's.

9

u/StyMaar Nov 17 '22

About breaking changes, there's (at least) three independent “things” that have their own versioning and breaking changes issues:

  • the language itself: that is, the syntax but also how the syntax is desugared. This is mostly solved with the edition mechanism.
  • the standard library: at the moment, there's one and only one standard library, and there's no plan to introduce breaking changes in the stdlib. I'm pretty sure that could be done though, if we accepted the idea of linking with several version of the stdlib in a single program (like it's done with major version of crates), but there must be a significant motivation before we end up there.
  • cargo: the mechanism around features you're talking about is mostly related to cargo, and we could definitely imagine having breaking changes in cargo itself, as long as it supports the older way of doing things when processing dependencies.

From what I understand, the worst part is actually “how can we change implementation details that were never specified and are exploited/abused in unsafe code”, and on that front Rust developers don't look like too afraid to be too scared to break existing code (they know they're breaking code, but they do it anyway because “it was UB all along”)

6

u/NeuroXc Nov 18 '22

As someone who uses features a lot (but also doesn't love that default-features=false is the only way to turn off a default feature), my use case generally has nothing to do with semver but is about keeping compile times down for users who don't need extra features. That being said, I really wish I could specify something like "-serde" if I wanted to disable a crate's serde feature.

154

u/mina86ng Nov 17 '22
  • Rust is move-heavy which is not something compilers were optimised for. This results in some unoptimised code. This is fixable by improving the compilers.
  • Lack of specialisation. This is fixable without introducing breaking changes.
  • std::ops is a mess when trying to work with generic numeric types. Writing code in a way where you don’t relay on the type being Copy or without doing unnecessary clones is unreasonably verbose. I don’t know if this can be fixed without a breaking change.
  • Unsafeophobia by which I mean that some programmers are zealously avoiding unsafe even if it can be shown that the code is safe and noticeably improves performance. Can this be fixed? Maybe if Rust gets wider spread into areas where people care about performance more.

36

u/Sw429 Nov 18 '22

Unsafeophobia by which I mean that some programmers are zealously avoiding unsafe even if it can be shown that the code is safe and noticeably improves performance. Can this be fixed? Maybe if Rust gets wider spread into areas where people care about performance more.

100% this. I've had people criticize my own libraries for using unsafe code in a few places, despite the fact that I clearly document exactly why and how what I am doing is sound. For some reason, some people don't understand that unsafe does not necessarily mean unsound.

26

u/Nilstrieb Nov 18 '22

Unsafe code is okay sometimes and I agree that people are against it too much, but it must be said that a lot of unsafe code out there is buggy, so the fear does not come from nowhere. If you can reasonably avoid unsafe, you should.

5

u/[deleted] Nov 18 '22

It depends on the balance. For example, a 3D game needs to squeeze out every last drop of performance. Using unsafe largely improves runtime performance during unwrapping (If you've already unwrapped the value successfully), using std::mem for lower-level memory control etc. A web server should be avoiding these practices, of course.

I try to avoid using unsafe as much as possible in Rust, but coming from a C background, I've got used to dealing with memory bugs so it also matters whether you're ready to actually risk crashing something due to segfaults.

16

u/zesterer Nov 18 '22

With respect, we've almost never felt the need to reach for unsafe when writing r/Veloren, despite the game having pretty intense performance requirements nowadays.

The only occurrences of unsafe we have are related to the plugin API, something that needs to be unsafe because the compiler doesn't have the ability to understand the necessary invariants.

The idea that "unsafe = performance" is a myth. It's much more useful when building up abstractions or getting around limits in the compiler's ability to reason about invariants.

→ More replies (2)

5

u/Nilstrieb Nov 18 '22

Your unwrapping example can often be written in a better safe way that's just as fast.

But yes, sometimes unsafe is necessary. But you'll have to make sure that it's correct, run it through Miri if possible, also test it with ASAN and document it accordingly and then it's okay.

→ More replies (3)

3

u/quick_dudley Nov 18 '22

Most of the times I've used unsafe blocks it's just been to call C code. But my second most frequent use so far is getting mutable references to more than one element in a Vec at the same time.

4

u/[deleted] Nov 18 '22

Most of the times I've used unsafe blocks it's just been to call C code

The way I go about this is declare the functions and wrap them nicely in Rust afterwards. I believe that's what gtk-rs does too.

3

u/robin-m Nov 18 '22

getting mutable references to more than one element in a Vec at the same time

If you still have a mutable reference to the whole Vec, then your code is absolutely UB.

Btw, do you know about split_at_mut? But I admit that if you try to access to more than one elements in the array with at least one of them mutable, it’s annoying to do

→ More replies (3)

3

u/[deleted] Nov 18 '22

despite the fact that I clearly document exactly why and how what I am doing is sound.

Why you think it is sound. Part of the issue is that the rules around unsafe Rust code are still not really known, and also it's really hard to know if unsafe Rust code is sound. Even harder than C.

So I think it's reasonable to avoid it as much as possible.

32

u/SV-97 Nov 17 '22

std::ops is a mess when trying to work with generic numeric types. Writing code in a way where you don’t relay on the type being Copy or without doing unnecessary clones is unreasonably verbose. I don’t know if this can be fixed without a breaking change.

imo it's not really std::ops in particular. Generic numerics in Rust are just generally... painful and frustrating. And num doesn't exactly help here.

And given that a lot of core functionality is still implemented in C / Fortran you often times gotta resort to just using f32 / f64 even if the complete rest of your code is perfectly capable of working with "arbitrary" numeric types.

→ More replies (2)

3

u/Jomy10 Nov 18 '22

The last one is definitely true. Some people really dislike unsafe no matter what

18

u/[deleted] Nov 17 '22

Not trying to start a fight; but if I’m using unsafe rust blocks because they’ve been tested, why wouldn’t I just use 40ish years of tested C or C++ code?

85

u/fiedzia Nov 17 '22

Because tiny amount of unsafe is better than 100%, better error messages, saner language, better tooling. Also a chance to find other people willing to work with you (and agreeing on a language features/tooling).

27

u/rusty_macroford Nov 17 '22

Personally, I don't see any reason to rewrite perfectly good C or C++ code in rust, but I would prefer writing new code rust over C++ for several reasons:

  1. templates can't be independently typechecked
  2. macro_rules is way more powerful than #define
  3. the borrow checker prevents use after free as long as your unsafe code base actually works.

I wouldn't underestimate the third point, because you can do a lot with a small number of tiny unsafe blocks.

3

u/zesterer Nov 18 '22

perfectly good C or C++ code

See, this is the problem.

How do you evaluate whether code is 'perfectly good'?

The C compiler isn't going to warn you if it's not 'perfectly good'. The only thing you've got to go on is whether it appears to be working fine, today, on the current hardware you're using, with the specific inputs you're giving it.

Rust gives us the tools to make stronger promises about whether software is 'good' based on criteria enforced by the compiler. Most of these criteria still apply in unsafe blocks (although they aren't transitive due to the nature of UB).

5

u/rusty_macroford Nov 18 '22

I don't think you are right. Let's take Linux as a specific example of a C code base. It's been around for 30 years, and for almost as long, people have been running elaborate whole program static checkers against it. Among other things (such as deadlocks) these checkers detect exactly the kind of errors that rust's borrow type system does. These checkers don't promise to detect all errors, but rust's promise to detect all errors is only as good as the trusted code inside rustc. If rustc contains more than 0 bugs, it doesn't provide an absolute guarantee either.

So, if a Unix kernel where written entirely in safe rust, would I trust it not to panic on a SEGV more than I trust Linux. Yes, I would have a tiny bit more trust. But would I trust the rust OS to correctly implement POSIX and all the relevant BSD and SysV APIs that go into Linux? Not until another 30 years have gone by, and even then only if the hypothetical kernel gets a user base comparable to Linux's.

I feel like you may be severely underestimating how easy it is to tell whether safe rust code is "perfectly good."

22

u/kukiric Nov 17 '22 edited Nov 17 '22

It's easier to maintain soundness in a Rust project with unsafe sprinkled in some locations than a C/C++ project which is unsafe everywhere.

The ecosystem is also largely built on safe code, so you're much less likely to get a raw pointer that needs to be babysitted from a Rust library than a C/C++ one.

33

u/mina86ng Nov 17 '22

Because you in Rust you limit and explicitly mark where unsafe code goes.

But yes, Rewrite in Rust is another cultural weakness of Rust. There are times where using 40ish years old C or C++ code is better than trying to rewrite it in Rust.

4

u/VegetableBicycle686 Nov 17 '22

Because you still get the benefits of lifetimes and the borrow checker for everything other than the unsafe operations, even within the unsafe blocks.

4

u/nacaclanga Nov 17 '22

Because you keep the unsafe to the parts where it is really needed and explicitly marking the issues. If you have a code that was successfully employed for 10 years, with virtually no changes and small external API, things might look different, but if you are constantly updating it, changes are high, that some future upgrade might ignore some unspecified invariant and mess things up.

2

u/Sw429 Nov 18 '22

Unsafe code means that the potential for UB is confined to the unsafe code blocks. No one is using unsafe code in every line if their Rust. This is different from C++, where every line could result in UB.

→ More replies (3)

6

u/[deleted] Nov 17 '22

Unsafeophobia is probably the number one problem.

4

u/VanaTallinn Nov 17 '22

Unless it's rewriteophilia.

→ More replies (4)

1

u/ydieb Nov 18 '22

Unsafeophobia by which I mean that some programmers are zealously avoiding unsafe even if it can be shown that the code is safe and noticeably improves performance. Can this be fixed? Maybe if Rust gets wider spread into areas where people care about performance more.

I just feel like (from my impression from reddit), that usage of unsafe in libraries have been pushed to not use unsafe, and get a performance lift at the same time. This is highly anecdotal though.

1

u/ritchie46 Nov 18 '22

I definitely agree with Unsafeophobia statement. I think the zero unsafe goals go against logic when we can uphold invariants and get performance benefits in return.

→ More replies (12)

71

u/haruda_gondi Nov 17 '22

Lack of variadic generics. Pretty hard problem, but I think they'll still retain backwards compatibility.

14

u/Sw429 Nov 17 '22

You can always use nested tuples to make heterogeneous lists! A simple declarative macro can make the API look nice, too.

→ More replies (1)

9

u/MissunderstoodOrc Nov 17 '22

Could you give me a few examples where it will be significantly helpful to have them?

15

u/haruda_gondi Nov 18 '22 edited Nov 18 '22

bevy (an ECS game engine written in Rust that i sometimes work on) is using proc macros to implement a IntoSystem like trait that is implemented for every function that accepts a SystemParam with up to 16 parameters. If variadic generics is made, any arbitrary system-like functions can be converted to a system without the 16-parameter limit.

Also, we like to implement traits for tuples that implement that trait. Something like:

trait ArchetypeFilter {}

impl<...T: ArchetypeFilter> ArchetypeFilter for (...T) {}

Other traits (Reflect in bevy_reflect, etc.) could vastly benefit from this.

3

u/CouteauBleu Nov 18 '22

Every single derive macro. Period.

Derive macros almost always rely on saying "assume that every field of this type implements MyTrait, and call this MyTrait method on them", with some small variants.

Having variadic generics would allow macro writers to factor out the trait logic out of the proc macro, and only have the macro provide the type's fields to a variadic function. The resulting code would have a lot fewer generated tokens and compile better.

3

u/[deleted] Nov 17 '22

A generic "list" of types is useful for open sum types, i.e. instead of Either<A, B> which can only be A or B you would be able to define an AnyOf<T...> which could be any of the types listed (e.g. AnyOf<i8, i16, i32, i64, i128> could contain any signed integral type.

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.

34

u/matthieum [he/him] Nov 17 '22

Unfortunately, I doubt this one will be fixed.

When Swift demonstrated it could be done, the debate occurred, but the problem was that the amount of unsafe code (and C-code linked to Rust) which relied on size_of was judged too great, even back then, for the change not to cause a massive wave of bugs throughout the ecosystem.

5

u/JarWarren1 Nov 17 '22

Not sure I understand. What’s the Swift behavior?

→ More replies (1)

3

u/BigPeteB Nov 18 '22

Also, not having a repr for structs that says "I don't care what layout Rust or C would normally use, this struct is for accessing something in a specific format (e.g. network packet or hardware registers) and you need to lay it out exactly like I say". Bonus points if it also lets you specify endianness of fields and does the conversion to and from native endianness implicitly.

2

u/rosefromthedead_ Nov 18 '22

Isn't that what #[repr(packed)] does? It doesn't have the endianness thing, but I think that should be doable with a wrapper type.

→ More replies (3)

57

u/veryusedrname Nov 17 '22

Luckily we have editions :)

24

u/reinis-mazeiks Nov 17 '22

editions are great, but aren't they only for syntactic changes?

surely there's lots of backward incompatible changes that can't be addressed with editions. for example, the removal of a deprecated standard library function, or a change in its semantics.

also, how many editions is too many editions? if we have 1 every 3 years, we'll have 10 more in 30 years.. how does one maintain that?

24

u/SkiFire13 Nov 17 '22

also, how many editions is too many editions? if we have 1 every 3 years, we'll have 10 more in 30 years.. how does one maintain that?

I don't think the number of editions is a problem but rather the amount of breaking changes they bring, because that's what actually needs to be supported.

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.

→ More replies (2)

41

u/jcamiel Nov 17 '22

It's not a big weakness but I would like functions to accept named parameters, for instance:

foo.move(x: 0, y: 10);

21

u/calcopiritus Nov 18 '22

I don't mind this, since rust-analyzer's inlay hints do it for me.

10

u/kuikuilla Nov 18 '22

Though named arguments work in any order and don't depend on the ordering of the parameters in the function declaration.

22

u/cesarcypherobyluzvou Nov 17 '22

Yeah, keyword-only and optional arguments is what I miss most coming from Python.

11

u/dudpixel Nov 18 '22

I liked these in python but since moving to rust I don't miss them. For keyword args, I used them in python to make the code self-documenting, but in rust my ide shows type hints anyway so I don't need them. Yes in python you can specify args out of order but I dislike that.

Optional arguments actually feel like a footgun to me, and violate the "explicit is better than implicit" principle. There are probably some cases where it's ok but there are also workarounds in rust anyway (macros, structs with default impl etc)

→ More replies (1)
→ More replies (1)

2

u/tavaren42 Nov 18 '22

I think we can really improve many APIs with optional and named arguments. Take for example unwrap vs expect.

I'd really like Rust to have Python style optional/named arguments.

2

u/[deleted] Nov 18 '22

Better if =

→ More replies (1)

12

u/zesterer Nov 18 '22

Lack of an effect system. This is becoming clearer and clearer as async pervades everything, often in disjointed and troublesome ways.

4

u/rosefromthedead_ Nov 18 '22

A little bird told me that someone has been experimenting with this :). On an unrelated note, the bird also told me to work on my side projects more. Strange...

5

u/zesterer Nov 18 '22

Ah, I took a look at effing_mad a little while back. Some very nice work! I think it's a very valuable step.

One thing I'm a little nervous about in effing_mad is the fact that effects are properties of functions and not of return values (i.e: async-ness is property of the returned future, not the function itself, in Rust).

I've personally found through my experiments working on my language Tao that having effects be a property of the return value and not the function itself is very useful and opens up a lot of doors, like iterators that generate effectful values and more precise control over when side effects occur and in what context.

Still, I'm really excited to see effing_mad grow! I'm really hopeful that it inspires more of the core dev team that effects really are the 'missing link' that Rust needs right now.

3

u/rosefromthedead_ Nov 18 '22

I remember a similar comment on my original announcement post, but I never got my head around what it means. In effing-mad, functions marked with #[effectful] return a generator that can be driven with effect handlers to completion. Similarly, async fns return a future that can be driven by an executor to completion. What's the difference? They're both a regular fn(stuff) -> things, if that's what you mean.

Perhaps the documentation is misleading? It seems to me that effing-mad is already how you want it to be.

In general, I want to understand these things! My goal is to design the ideal API so that we can say with certainty whether such a system can cleanly bring benefits to Rust. So, if there are any more ideas out there of what people want from it that hasn't been considered yet, I'm all ears :)

6

u/zesterer Nov 19 '22

Oh, interesting! So the macro annotations on the function apply just to the return value and not to the calling of the function itself? That's good to know.

It would be nice if this were made clearer syntactically. Given that procedural macros can entirely transform token streams, may I suggest something like this?

#[effectful]
fn foo() -> Io + Yield<String> ~ i32 {
    ...
}

Obviously, one complication is that it doesn't mesh too nicely with regular type annotations, and I'm not sure how you'd work around that while being confined to working Rust.

→ More replies (1)

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)

13

u/IAm_A_Complete_Idiot Nov 18 '22

stdlib being too big is gonna be a controversial one. :)

5

u/[deleted] Nov 18 '22

Yeah, first I've heard anyone say that!

1

u/Potential-Adagio-512 Nov 21 '22

i feel like std::collections::LinkedList isnt necessary either, i personally love mpsc

2

u/Due-Dog-1533 Nov 21 '22

I love channels also, the problem is that crossbeam-channels is much better than std::sync::mpsc but because it is part of the standard library doesn't get used nearly as much as it should.

→ More replies (2)

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

10

u/alexschrod Nov 18 '22

That's how we make sure two crates can't have conflicting trait implementations. I feel like removing it would only lead to crates becoming mutually exclusive.

7

u/DidiBear Nov 17 '22

Is it the fact that we cannot impl external traits for external types ? If so, what would be the big advantage of that ? 🤔

2

u/robin-m Nov 18 '22

Some kind of delegation would totally solve the issue.

struct WrapFoo(Foo);
impl WrapFoo {
    delegate * to self.0;
    // new methods here
}

Delegation is also extremely useful to have a sane way to emulate inheritance without it’s issue. You can create a new type that encapsulate your "base class", and delegate all the function you want to it.

It’s just not as easy to design as it looks like because any use of Self need to be disambiguated. Should a function foo, when delegated, if Foo::foo was returning Self, should WrapFoo::foo return Foo or WrappedFoo?

2

u/watr Nov 18 '22

Not that simple... hence why Orphan rule is still in-place. The struct wrapper was implemented in Rust as a temporary safe work-around. However, they are making progress on a solution: https://github.com/Ixrec/rust-orphan-rules/issues/1

→ More replies (5)

14

u/iamalicecarroll Nov 17 '22

there are quite some std design mistakes which can't be fixed since that'd be breaking change

4

u/[deleted] Nov 17 '22

And the implicit prelude makes it difficult to use a non-std library.

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.

3

u/KnorrFG Nov 18 '22

It's nice if a language is easy to pick up for beginners, but I think that should be the last priority. You are a beginner only during a small percentage of the time you use the language, and if you sacrifice anything for being beginner friendly, you will suffer from the disadvantages way longer then you profit from the advantages. I think to help beginners, it's more important to have good (and free) teaching materials that are kept up to date. Then again, I think the rust book qualifies as such.

0

u/[deleted] Nov 17 '22

[deleted] — view deleted comment

3

u/cthutu Nov 17 '22

Also pollster::block_on.

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:

enum A {
	B(Box<C>)
}

struct C {
	d: Vec<i32>
}

match A::B(Box::new(C {d: vec![1, 2, 3]})) {
	A::B(C {d: [1, 2, 3]}) => ...
	_ => ...
}

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 MLs

2

u/robin-m Nov 19 '22

In which context do you need |> that isn’t a map applied to an Iterator? I’m genuinely curious.

→ More replies (2)

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

→ More replies (6)

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.

34

u/InfamousAgency6784 Nov 17 '22

Working with shared mutable state is a mess

Amen

10

u/alexschrod Nov 18 '22

I've been writing Rust for about three years now, and every time I thought I needed to resort to Rc<RefCell<...>> I found a better approach after some thinking and planning. I'm not saying that it's always possible to avoid, since I obviously haven't found myself in every possible scenario, but it's certainly often possible.

6

u/ondrejdanek Nov 18 '22

This. Haven’t used Rc<RefCell<>> a single time in like two years of doing Rust.

→ More replies (1)

40

u/ondono Nov 17 '22

Working with shared mutable state is a mess

That’s not a bug, it’s a feature

32

u/scook0 Nov 17 '22

That’s not a bug, it’s a feature

This is wrong.

The fact that Rust gives you good ways to write code without shared mutable state? That’s a feature.

The fact that Rust won’t let you use shared mutable state without some kind of opt-in? That’s a tradeoff, but it’s pretty easy to argue that it’s a net positive.

The fact that Rust makes it disproportionately awkward to use shared mutable state, even after opting in? That’s a weakness, not a feature!

At best you could say that it’s the downside of a good tradeoff, but the downside of a tradeoff is still a downside. Calling it a feature doesn’t make sense.

→ More replies (1)

2

u/latkde Nov 17 '22

Could you give an example of how Swift addresses this problem? Or are you talking about “actors”?

→ More replies (8)

1

u/kennethuil Nov 18 '22

Working with shared mutable state is a mess thanks to the mechanism specifically designed to facilitate it?

→ More replies (1)

4

u/[deleted] Nov 18 '22
  • The non-separation between RFC and Cargo

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-analyzer without 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).

  • The lack of standard or specification

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 on rustc. 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 rustc is doing.

It is up to the language team to try making it, if possible.

  • The Crates philosophy of "small crates".

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.

  • Rust's syntax being too "magic"

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!

  • Compile time

This is a recurrent problem of rustc and 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).

  • Cargo's build scripts (formerly 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.

struct Foo {
    a: Vec<i32>,
    ra: &'SOMETHING i32
}

It should also have a concept like StableDeref, rental etc., 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 Trait is 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.

5

u/NobodyXu Nov 18 '22

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.

Maybe you want std::borrow::Cow or beef which provides smaller Cow implementation (same size as String)?

&dyn Trait is nice, but not quite the same thing--this would still be statically typed, just a different call ABI.

dyn Trait uses dynamic dispatch instead of monomorphization. It's not a different call API, but it's a fat pointer that contains the vtable.

3

u/idcmp_ Nov 17 '22

Also, cross-compiling (compared to something like Go).

1

u/[deleted] Nov 18 '22

Yeah it's not quite as easy as Go or Zig but it's far far better than C. I think it can be improved by two things:

  1. More native Rust crates, less dependency on C (e.g. OpenSSL). This is part of the reason Go is so easy to cross-compile - it has very few C dependencies. Try cross-compiling something that uses cgo and it is just as bad as Rust.
  2. Removing the dependency on libc (on Linux). I think there's been some work on this.
→ More replies (3)

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?

7

u/LadulianIsle Nov 18 '22

Yes. Just have a different funcrtion, since if it takes in different arguments, it likely does something different and so should be named something different. If it doesn't, then you have generics and traits to lean on.

→ More replies (2)

2

u/robin-m Nov 18 '22

Overloading is very useful with C++ templates, and a bit less with generics. In most places in Rust you don’t really need them. Where I would like to have them is when you start to have foo/foo_mut/try_foo/try_foo_mut. And sometime, I would also like to have overload when creating a bunch of new_with functions.

3

u/coderstephen isahc Nov 18 '22

Assuming you are talking about function overloading: Rust does not have it. Although with traits you can get similar behavior. But over time I've started to agree more with the opinion that excessive function overloading is an anti-pattern anyway.

For operator overloading, Rust has that.

→ More replies (5)
→ More replies (8)

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.

0

u/[deleted] Nov 18 '22

[deleted] — view deleted comment

2

u/GerwazyMiod Nov 18 '22

But if compiler knows what function you are really calling by looking at call arguments - inference should still work, right?

4

u/ieatbeees Nov 18 '22

Not necessarily. If you could overload a function to take either an i32 or u32 like this:

fn do_things(value: i32) { ... }
fn do_things(value: u32) { ... }

Then the compiler wouldn't be able to infer the type of the variable here:

let value = 7;
do_things(value);

Because 7 is a valid value for both i32 and u32

→ More replies (3)

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

6

u/[deleted] Nov 17 '22

What do you mean exactly? If you have access to a mutable struct, you can mutate any of its fields as long as they are marked public?

→ More replies (9)

3

u/Nilstrieb Nov 18 '22

An RFC is going to be merged to be able to have public fields but restrict mutability on them! https://github.com/rust-lang/rfcs/pull/3323

→ More replies (6)

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.

3

u/KnorrFG Nov 18 '22

What do you miss, that cannot be provided by rust-analyzer + any lsp-compatible editor?

→ More replies (6)

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/[deleted] Nov 18 '22

I think the lifetime abstractions and associated meta-programming is the worst offender here.

Lifetimes can be avoided almost always. I think you're stuck in OOP land and having a hard time adjusting.

I felt I really had to rethink my first intuition for every pattern I wanted to implement in Rust at first. I started with a game framework / rendering engine, meaning I had to plan ahead. If you just think you can learn Rust by simply doing, you're going to have a bad time.

Anytime you'd have a lifetime in a field inside a struct, rethink everything. Make it Rc/Arc or Box it if you have to. Borrowing in Rust should be short term only.

2

u/ericanderton Nov 18 '22

Thanks for the encouragement. I appreciate it, and will take this with me when I take up Rust again.

I swear, this has to be the most polite community on Reddit.

→ More replies (1)

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

11

u/kodemizer Nov 17 '22

You get used to it. I find it very readable now.

2

u/Cold_Training869 Nov 17 '22

Good to hear. I am new to it so that makes sense.

5

u/kodemizer Nov 17 '22

If you're using vscode, rust-analyzer is very helpful in making it readable with inline type-hints

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/alexschrod Nov 18 '22

I can't think of any language that has explicit "kwargs" except for Python. You can simulate it in JS, but that's only because JS objects are really just maps/dictionaries without any type safety whatsoever.

2

u/v_maria Nov 17 '22

it's not very expressive. writing rust is rather mechanical

16

u/reinis-mazeiks Nov 17 '22

whaaat? what about macros, generics, the amazing ecosystem + literally any other abstraction?

i don't know what expressive languages you've worked with, but compared to my experience with JS, Python and Java, Rust feels very expressive. i can get so much done by writing smol elegant codes.

→ More replies (7)

7

u/CrimsonVoid Nov 17 '22

this is my biggest gripe working with rust too, it's just too verbose to express common ideas. i've tried explaining this to people, but user ergonomics constantly falls on deaf ears because there's always an alternative, usually more cumbersome, way to write it.

and, imo, macros only serve to exacerbate and hide the problem (and can sometimes even constrain design spaces)

ps. not that it matters sorry about the downvotes. the rust community is more culty than early go.

3

u/[deleted] Nov 17 '22

Verbosity is kind of the tradeoff for what Rust gives you in return though. All the implicit stuff people would want to see fits a GC language... You have to be verbose if memory is to be safe without GC.

I understand the macro comment you make. As I only use Rust for personal stuff, it's not a problem. I can see how badly documented macros can be a terrible hassle for teams though.

1

u/Cherubin0 Nov 18 '22

I came to hate expressive languages.

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:

  • Specialization or at least some mechanism for dealing with overlapping blanket implementations (e.g. negative bounds)
  • Better support for new-type wrappers. I've had a go at solving this with macros (see impl-tools), but the result is imperfect.

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.

→ More replies (1)

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 &mut should 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/robin-m Nov 18 '22

For those who didn’t know the acronym, RPITIT is “return position impl trait in trait”.

-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 usize to a u8 (resulting in usize) and even a u32 to a char (resulting in u32) without casts. This is something which reasonably could be fixed by writing some more Add/Sub/etc. implementations, perhaps in an edition.

Also the decision to make the Index operation (square brackets) generally panic if out of bounds makes it essentially useless for any application where panics are unacceptable. a[i] should return None if out-of-bounds, instead of requiring a separate method, get().

17

u/flickpink Nov 17 '22

God, please no. This is exactly the kind of behavior that crept into other languages and made them the mess they are today

23

u/csreid Nov 17 '22

Also the decision to make the Index operation (square brackets) generally panic if out of bounds makes it essentially useless for any application where panics are unacceptable. a[i] should return None if out-of-bounds, instead of requiring a separate method, get().

Yikes, big no from me. Maybe we're just in different worlds (probably), but handling Nones all over the place sounds awful and anyway, if I'm indexing something out of bounds, my code is probably broken and I'd wanna know about it.

If anything, it could maybe return like an IndexOutOfBounds error type or something, but that still makes the code pretty messy.

18

u/[deleted] Nov 17 '22

I!d argue that having a panicking index and a get that returns an option was the right call.

2

u/VegetableBicycle686 Nov 18 '22

> different worlds

I think that's it actually yes. Panics have very different severities in different applications and different platforms, and might result in a nice user-facing error message in a GUI/web app, or crash the whole application if panic=abort. So there's perhaps no way to please everyone.

I find it quite interesting that there's been strong support in this thread for the existing panicking Index behaviour when the casual use of `unwrap()` is frowned upon though.

3

u/LadulianIsle Nov 18 '22

Generally because they imply:

unwrap = lazy

panic! = I have no idea how to deal with this

[] = I know what I'm doing

I think the closest equivalent to panic! is actually expect

→ More replies (1)

5

u/[deleted] Nov 17 '22

Are you sure you'd want EVERYTHING to be an Option<> just in case it's out of bounds? I'd rather have it be a Result instead. But when you know what you're doing you just don't have to check which is nice, and if you do need to check, implement it. If your fn returns a Result anyway it's 1 if statement away.

2

u/78yoni78 Nov 17 '22

The index return type makes it so much more familiar to programmers from other languages

and about the operations, there are certain contexts when you don’t want to that implicit number conversion

2

u/[deleted] Nov 17 '22

I like strict typing. Makes me feel at home after Standard ML.

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.

3

u/[deleted] Nov 17 '22

Web doesn't require that much boilerplate. Rocket with whatever db backend (I usually use rusqlite) doesn't take that much boilerplate to start. As with examples, most libraries have plenty and documentation on functions and classes are great in Rust.

→ More replies (3)

1

u/plutoniator Nov 18 '22

verbosity + complexity you can't opt out of

→ More replies (5)

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.

2

u/UnemployedCoworker Nov 19 '22

There's the fancy-regex crate that provides backtracking

→ More replies (1)