by antonvs · 6d ago · 0 comments
To me, its type system and traits design make it one of the nicest mainstream languages. I'd rather be using a functional language, like Haskell or an ML, and I do sometimes, but I don't pick my work based on that. I work regularly with Java, Go, Typescript, and Python, and out of those I find Rust significantly superior on several dimensions.
Python is terrible, Go is basically weakly-typed Python, Typescript barely deserves comment other than that it's impressive that such a fancy type system was bolted onto Javascript, and Java is basically COBOL at this point - reliable, but clunky and showing its age. Attempts like Kotlin to leverage the JVM aren't very convincing.
Gleam looks interesting but I haven't had a chance to work with it yet, and it's hardly mainstream.
You mentioned Ada/SPARK, but SPARK is not really for general purpose programming, and Ada in general has a similar issue to Java, but worse because of its age. It's as if someone really liked PL/I but decided it needed more features and a syntax closer to COBOL.
Speaking of implicitness: There's a lot of implicitness in rust that can go wrong, especially with the traits system, and composition. Canonical example is copy + iter, which never gives you what you want.
This is a language design problem. The composition of two very basic stdlib traits should not cause such a problem, suggests something wrong with traits in principle -- it's not "solving" polymorphism in the way that was hoped, are the userland traits that your senior Dev (or fable) wrote free of compositional implicitness unsoundness? Are you sure?
Second example of compositional implicitness causing problems: recently identified CVE's in rust stdlib where drop can easily be composed to call a panicking function where lots of shenanigans can happen. There's no way to annotate "can panic" in rust (nor should there be?). It's easy to implement a custom type with a Drop that calls, say, a panickable- inner-type method that will have exactly those problems. Note that these CVE's happen because in rust, IIUC, a panic unwinds through drop instructions, AND can be caught.
Not an explicitness problem but macros too. Sometimes macros create major gunning fog while reading a codebase.
Allocators being bolted on as an afterthought is kinda bad for a systems PL. For example, postgres has something like 11 allocators and Erlang has 10, but it looks like it's getting fixed?
I will chime in here to say that the adoption of async was imho a terrible decision and led me to abandon Rust for most purposes. I want proper threads and CSP-based abstraction.
Someone who's saying "the rest of the language sucks" may be thinking of something like that, hence my question above.
But when it comes to performance overhead, programming around the constraints of the borrow checker can introduce runtime costs that wouldn't otherwise be necessary - e.g. when cloning is used to handle borrowing conflicts.
Even if, in theory, it's possible to restructure a program to avoid performance impacts, in practice people don't always do that, not least because more efficient solutions may not always be obvious. This comes back to my point about coding effort.
I spent a bunch of time, pre-LLM, to try to replace a bunch of unsafe blocks scattered throughout an ML inference codebase, that someone had used to achieve maximum performance. I wasn't able to get a version that performed as well.
This kind of thing may not matter if you're writing e.g. ordinary web services, but for more performance-critical code, it can be an issue. Of course, `unsafe` is always an option to deal with that, but that undermines Rust's guarantees.
Whether that is “something natural to you”, “something you learn and adapt to” or “something you fight with forever” seems to vary per-person, with I suspect, most people falling into the forest 2 categories.