Rust's Complexity Problem – A Warning
medium.com
medium.com
BTW, I have many troubles with rust, that after more than a year are more stable (starting with rust I could have believed what this post say):
https://www.reddit.com/r/rust/comments/fj824y/whats_your_con...
I rewrite a huge (for a solo dev like me) codebase from .net/f# to rust, used in ERP-like app by the small/medium companies on my country. As "normal" and "boring crud" apps as you can tell.
The complexity of the development wet DOWN, A LOT. Even taking in consideration the use of F# (that I also pick to reduce the burden of using C#), the code have MUCH less bugs and troubles. We were on "fire mode" for some months and after the switch, all is calm as I have not experience in a lot of time.
And, as I say: I'm a solo developer. Still learning rust.
---
BTW: I only hit serious blocks working in a relational language on the side. For "normal" enterprise coding? Rust is a total win.
This is a problem for newcomers because they have to adapt their way of thinking into Rust way of thinking. Once one develops a set of patterns and principles this is not an issue.
Companies who have large codebases in Rust tend to have praise for it enabling solutions that are much easier to reason with and work on then if they were developed in C++.
It is obvious the author has little to no experience in developing production software in Rust.
Statements like these don’t necessarily speak for the user-friendliness of Rust or Rust itself. Safety? OK, cool. But for what cost?
There seems to be a class of developer that's been brainwashed into thinking generic programming is bad. It's pretty damn great when your type system is well designed.
The author's argument is pretty straight-forward: Rust's borrow-checker makes for complex code, so you should think carefully whether your application is resource-constrained enough to merit using Rust. If not, you should consider using a memory-managed language.
He's pointing this out as a contrasting point to projects rewriting in Rust, which is what naturally happens when a new language starts going down the path to becoming a Mainstream Programming Language™️. This sets up the question that I'm waiting to get answered: is Rust actually complex enough that it should be a niche PL rather than a mainstream PL?
How do current Rust devs feel about that so far?
That said, I think a counter argument here comes back to they complexity budget. I don't feel like language design and borrow checker are inherently more complex, but rather that they explicitly pull out that complexity, but in a way that feels manageable. I know that that since writing more Rust, my code written in other languages like C++ or even Python have started started having patterns that I picked up from my work in Rust, and that I qualitatively feel like that has raised my code quality in those languages. I'm also definitely more aware of some of the hidden complexity in certain tasks like dealing with system paths.
So at least in some degree of summary: no. I like the level of abstraction and complexity Rust has, and the mechanisms in place for dealing with that complexity have largely seemed both well thought-out and implemented such that they are accessible to a mainstream audience.
> Rust’s way of managing memory is unique and clever. Unique and clever are generally seen as good things, but in software development they usually lead to difficulties with long-term maintenance, among other issues
The citations he gives are
1. a stack overflow post
2. a blog post (by an author I respect, but still)
I don't think that this alone proves his point. Even if we ignore that aspect of things, Rust is by far the easiest programming language I've ever had to do long-term maintenance on. This is specifically due to the guarantees.
So when I read the above, I see a very general argument, and my experience contradicts it here, so I don't really agree.
I am also, of course, incredibly biased.
Can you think of any cases where he might be right? How often do you hit, for instance, "This code cleanly fit its original construction, but now I have to add some complexity for new cases, and Rust is making that harder?" Put another way, once you're familiar with the borrow checker, how often do you find yourself or your teams fighting it?
> Put another way, once you're familiar with the borrow checker, how often do you find yourself or your teams fighting it?
Extremely rarely, if ever. It yells at you, you go "oh yeah, oops" and fix it, and move on with life.
But, I should qualify that's mostly personal experience and what I hear from other folks generally and other teams at work; my team at work doesn't really write Rust, our main codebase is in Typescript and Go.
I just saw this thread by the ex-CTO of Chef, it matches my experiences here: https://twitter.com/adamhjk/status/1239989909714173952
And as of earlier today, it's no longer just the way bytes are stored on Dropbox, but now every file sync too https://news.ycombinator.com/item?id=22595782
It seems to be holding up! Still relatively early days.
Dubious claim; in fact, the opposite seems true, since simpler code passes the borrow checker more easily
6. "A programming language is low level when its programs require attention to the irrelevant." - Alan J. Perlis.
which applications don't require memory safety?
I had a Rust vs Haskell debate with a VPE at a company (he wanted to move to Rust.) He refused to acknowledge that the fact that Haskell has a GC is a big advantage over Rust for many applications (ours included.) It didn't help that he (somewhat arrogantly) fashioned himself a "systems engineer" and would've chosen C++ if he could've.
It wasn't the crux of the argument (there's a lot more to those languages) and this VPE clearly wanted to move away from Haskell from day 1, but nonetheless - a very frustrating discussion to have.
I'm not a Rust expert though so please correct me if there's a way to right large Rust programs without worrying about memory management.
Haskell vs Rust is probably a question of much more than a GC or not though.
Oh yes 100%
My issue was that the discussion was disingenuous. GC was used to knock Haskell, but the cost of Rust's memory management model was not listed at all, thus painting an unbalanced pro/con picture (the scales were unbalanced!)
That's the thing: it depends on what you mean by "think." At this point, I never think about memory in Rust; that's what the borrow checker is for. I write my code, usually it's just fine, sometimes there's an error and I go "oops" and fix it.
Consider how you'd feel if someone said "ugh, you know, Haskell makes you think about types throughout your program's logic and structure. That's a cost many programs don't benefit from at all." I would assume, given that you like Haskell, you understand that types are a tool to help you write programs, and dealing with the compiler telling you about types isn't really a burden. Same with Rust. (lifetimes are types!)
And Haskell's types aren't necessarily what you want either (I still write bash and python and go for a reason!), but I'm guessing they're more generally applicable than lifetimes. I would love to be wrong & learn more though :)
> I'm guessing [types are] generally more applicable than lifetimes.
I think this is an open question! A lot of people argue (you can see some of it in this thread) that Rust's rules teach them a certain programming style that carries over into other languages.
Why does it usually leave you worse off? Because, since it's garbage collected, the language usually doesn't see the need to also provide a good way for the programmer to manage lifetimes, because, hey, we've got garbage collection, so why would they need to? The result is that the programmer has no help at all with the other resources.
So that's where I think the line is. Do you just have memory to worry about? Or do you have other resources as well?
And, to be clear: Yes, if you only have memory to worry about, garbage collection is fabulous. A whole set of problems just... goes away. It's very freeing.
I know Haskell is trying to get Linear Types for those purposes (with a paper + working ghc branch) but even those are going to take time to get nice imo.
We see people switch from Rust to node due to scale and reliability. If you're not feeling those pains from Node, then you should absolutely keep using it!