this post was submitted on 25 Feb 2025
170 points (99.4% liked)

Rust

6447 readers
54 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 day ago

Well, the others already responded to some of your points, I'll try to answer the rest.

Ada has a much more serious package and module system (that area is under development for Rust though).

Well, I don't know what the Ada system is like, but I will say that Rust has one of the nicest module systems, in my opinion. "Serious" isn't necessarily the adjective I would choose for it, but it works well despite being fairly simple and what I love in particular, is that you can start a codebase small and grow it larger and larger without breakage of module paths.
You do need to build a midsized codebase to really experience that, but basically you can go from a file to a folder to a folder with lots of subfolders without ever changing the imports, even when you move the actual type definition to be further down the tree.

Rust doesn’t currently have exceptions, so you have to check error codes pervasively through your program, and that sounds easy to mess up. I don’t know whether Rust’s designers think of this as a shortcoming (fixable later) or a feature.

As the others already said, it's a feature. It comes from the functional world (putting data flow and control flow on the same path) and yeah, I find if you want to do solid error handling, it's really good at forcing you to do it.
If you don't want to do solid error handling (e.g. because you're just writing a script or the startup logic of an application), you can get behavior very similar to exceptions by using anyhow for error handling.

I’ll defer to you about the description of the borrow checker. I doubt it’s idiomatic to use standard functional programming techniques in Rust, e.g. shared immutable tree structures for lookups. That usually relies on garbage collection.

Well, the borrow checker also kind of obsoletes relying on immutability for correctness. If you actually want to share that tree between threads, you do need a mutex then, but within the same thread just the ownership and mutability rules prevent you from updating the tree while others might be reading it. Effectively, if the compiler allows you to update the tree, it is safe to do so.

This is IMHO not talked about nearly enough, but Rust effectively makes mutability a viable strategy again, particularly because it also forces you to make mutability explicitly visible at all times. It is somewhat antithetical to functional programming to mutate a variable, because it is a side-effect. But if this side-effect cannot bite you, it's not actually a problem.
In particular, always cloning values is only not a problem, if you're really doing puristic FP. As soon as you store state and you duplicate this state to update it, you might have two different states in your application.