by UltraSane · 1w ago · 0 comments
Imagine a alternate reality where Ada replaced C by 1995. We would be in a MUCH better place.
Dunno if you have ever worked in software engineering, but if you have, count the times you have seen a backend server api written without any input sanitization or checking. Most of these exploits can be defeated by checks on inputs. I.e, no "Alex\x90\x90\x90\x90\xcc\xcc\xcc\xcc", is not a valid input for someones name.
There are ways of writing safe C. There are ways of writing unsafe Rust. Go look at any major Rust Codebase that touches libc, you will find unsafe{} everywhere.
Then Rust came along and those dudes either tried to say it was too hard (odd contrast, that) or it’d be too much work to rewrite things.
I’m hoping that LLMs will lower the cost of porting for enough people but what would really help is shedding the idea that the status quo is sustainable. Having consequences for sticking with C would help but we need a way to get companies to pay to migrate without destroying open source.
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.
This was one of the reasons why people switched to things like Java, Perl, Python, PHP, etc. where performance wasn’t critical. I remember having that conversation with a number of clients who’d been burned on delays and reliability issues building everything in C as opposed to using a higher level language and maybe a couple of C libraries.