I wonder a lot about this too. As far as I know, rust is alone. It’s the first language to exist which does compile time memory management in a safe way. Every other language either is memory-unsafe (C, Zig) or garbage collected. (Go, JS, etc).
Rust might the first language of its kind, but it probably won’t be the last. I’d be very surprised if we’re still using rust 100 years from now. Subsequent languages can learn from rust’s accidental complexity and clean up the approach.
Personally I suspect it’s possible to have a borrow checked language that’s much simpler than rust. I don’t know what that would look like, but it would be surprising to me if we found the best programming language in this space on our (collective) first attempt at it.
But I don’t have enough insight to figure out what rust’s successor would look like either. But luckily for both of us, there are a lot of smart people thinking about the problem now. Let’s give it a decade and see.
* Andrew Kelley is looking into combining escape analysis with allocators to assist in Zig's memory safety. [0] It could be quite a step forward!
* D is adding a borrow checker! [1]
* Cone is adding a borrow checker on top of user-definable allocators. [2]
* We're currently prototyping a region-based borrow checker [3] for Vale, which should get us most of the benefit of Rust's borrow checker with only a fraction of the complexity. It's opt-in, not upwardly infectious, and can stay near the "computational leaves" of one's program.
[0] https://news.ycombinator.com/item?id=31853964
[1] https://dlang.org/changelog/2.092.0.html#ob
We later discovered generational references, a method for memory-safe single ownership with no borrow checker, reference counting, nor garbage collection. To our delight, the region borrow checker works even better with generational references than with reference counting =)
First, Rust's borrow checker incurs zero runtime overhead for any pointer operations (whether dereferencing, copying, or dropping a pointer) and requires no extra storage at runtime (no reference counts or generation numbers); it's entirely a set of compile-time checks. Generational references, on the other hand, require storing an extra piece of data alongside both every heap allocation and every non-owning reference, and they incur an extra operation at every dereference.
Second, since Rust's borrow checker exists entirely at compile time, it doesn't introduce any runtime failures. If a program violates the rules of the borrow checker, it won't compile; if a program compiles successfully, the borrow checker does not insert any conditional runtime panics or aborts. Generational references, in comparison, consist entirely of a set of runtime checks; you won't found out if you violated the rules of generational references until it happens at runtime during a particular execution and your program crashes.
Finally, Rust's borrow checker applies to references of all kinds, whether they point to a heap-allocated object, a stack-allocated object, an inline field inside a larger allocation, a single entry in an array, or even an object allocated on a different heap and passed over FFI. Its checks still apply even in scenarios where there is no heap. Generational references, on the other hand, are entirely specific to heap-allocated objects. They don't work for stack-allocated objects, they don't work for foreign objects allocated on a different heap, and they don't work in a scenario with no heap at all.
All of these are fundamental differences which mean that Vale's generational reference system is not at all a replacement for Rust's borrow checker. It's not zero-overhead, it doesn't catch errors at compile time, and it's fundamentally specific to heap-allocated objects. In these ways it's more comparable to Rust's Rc, which introduces runtime overhead and is specific to heap-allocated objects, or RefCell, which performs checks at runtime that can result in aborting the program.
[1] https://plover.com/~mjd/misc/hbaker-archive/LRefCounts.html
It really is a very tough hill to climb to crack the top 10 among languages. Relatively speaking, D has done well for itself, and arguably is in the position to climb further up and possibly be in the top 20 of language rankings.
Have seen a lot of talk and theories about why D didn't or hasn't become more popular. Some of them have to do with circumstances, not just about the number of features. For instance, Dlang's DMD reference compiler was under license restrictions by Symantec, which wasn't changed until 2017 (now it's under the commercial friendly Boost license). A lot of companies and corporate sponsors get leery about licensing issues.
There were also early squabbles about API design, like Tango versus Phobos, which are mostly resolved these days. But, years ago, it was less clear about the direction or how it would get sorted out.
D, as a contender to climb even higher up the language ranking charts, is still a strong possibility. D might even remain and always be more popular than Zig will ever be (especially if it wants to fight and die on the more syntactically complex "better C" hill), despite this view on D adding so much. Which could even be more of a selling point (kitchen sink included), than an hindrance, and particularity as an already established and developed older language.
Cyclone’s initial release was ‘02 and it finalized in ‘06.
We stand on the shoulders of giants :)
I may take serious issue with pcwalton’s assessment of the performance characteristics of OS threads vs other concurrency implementations, but fun HN arguments aside; I have never seen or heard of any lack of acknowledgement of preceding language/implementation work leading to Rust’s development. So I certainly wasnt attempting to imply any stealing or denial of credit/attribution.
This is an interesting perspective, I can’t think of a reason you would be incorrect, but I know I have some default intuition that likeness is most often used to imply derivedness. Also, that’s a great way to phrase what you meant.
Basically what I'm wondering is if Rust has room to become that language that's learned from the ways Rust has been clunky in the past, without introducing dramatically breaking changes
While we cannot, and should not, take away its glory in achieving this, we should also not address it as if all belongs to Rust alone.
I would claim that a modern rifle flies at hundreds of miles an hour, and is operated remotely.
[0] https://github.com/vlang/v [1] https://news.ycombinator.com/item?id=19086589 [2] https://news.ycombinator.com/item?id=31795445
EDIT to reflect critical attitude as indicated by [2].
Vlang has continually maintained its development pace and popularity (https://github.com/vlang/v/releases), so that pretending to dismiss it as if it was nothing or attempting to smear the author just does not work. It's not going away. Vlang is also not a one-man show, but has numerous other committed developers, new contributors, and loyal long time supporters.
You can see this in the latest Vlang release thread. I suggest those curious take a look at it and judge for themselves.
I know you're very fond of V but misrepresenting criticism or a negative view of the project as "fear", "perceived threat", and so on is rather dishonest and a disservice to the project. The above is a comparison of before release and long after where there's been a chance to evaluate V for what it is rather than for what it advertised.
I used to think this too, but my opinions have evolved a bit.
Recall the transition from goto-heavy assembly code to C; it solved all the things assembly solved, and was a substantially simpler language. One of the keys to designing a good language (or any good abstraction, really) is to identify the patterns that already informally exist.
So if we want to see a simpler Rust, we need to look at the informal patterns that exist in Rust.
* Zig did this with Rust's async/await, by making it colorblind. [0]
* Vale did this with Rust's generational indices, by making generational references, a way to get memory-safe single ownership without a borrow checker. [1] It then adds a hardened FFI boundary to get more solid safety guarantees than Rust could. [2]
* HVM did this for Haskell by looking at Rust's particular blend of borrowing and cloning, and making it happen automatically. [3]
* Lobster did something similar for an imperative mutable language, to reduce RC costs lower than ever before. [4]
I think Rust is an amazing first attempt at an interesting new problem space, and a huge step forward for the field. Now, language designers are starting to notice that the building blocks that Rust trailblazed might be combined in new interesting ways, to make new interesting languages.
It's an exciting time for programming languages!
[0] https://kristoff.it/blog/zig-colorblind-async-await/
[1] https://verdagon.dev/blog/generational-references
[2] https://vale.dev/memory-safe
Zig's async/await is not colorblind. [1] It just appears that way at first because the compiler infers as much as it can at compile time.
[1]: https://gavinhoward.com/2022/04/i-believe-zig-has-function-c...
In general, the higher level the language, the more flexibility you need to give up (but that's ok for many solutions).
Zig looks nice to read and understand. However at my skill level (more or less a skript kiddie) I don't trust myself to not cause major memory-related bugs. In fact, I can't help but wonder if it's hubris or what when extremely intelligent, college educated, programmers with more than my lifetime of experience who still manage to write programs riddled with memory safety issues and in the very next breathe say memory safety isn't an issue just write safe code. I wonder what skill/knowledge thresholds are where "I don't trust myself to not make those mistakes" turns into "I won't make those mistakes."? Honestly it reminds me of the low IQ/high IQ meme [4].
[1] https://gitlab.com/NadyaNayme/rusty-eyes
[2] https://github.com/NadyaNayme/Dorothy
Sure, it is a worthy tradeoff in certain, very niche cases (though other than writing other performant runtimes and realtime audio processing, I fail to see another area where a GC couldn’t fit - including even OSs), for which we need a language, but I really don’t get this recent hate for garbage collection, when it is truly one of the biggest productivity improvements for a PL, while simultaneously it being very performant (quite likely outperforming any naive manual take on more complex problems).
The importance of this can't be overlooked, which is debatably why people and companies are constantly looking for a way to escape heavily complex languages and syntax. It is part of the thinking behind somewhat newer languages like Go, or newer offshoots like Vlang (https://vlang.io/), which has a focus on high readability and general usability.
If a language is being geared towards the majority or mass appeal, then it has to find that correct sweet spot. There is simply going to be a cap on how far complexity will be embraced or how much specialization will be found useful.
“Genius is making complex ideas simple, not making simple ideas complex.” — Albert Einstein
> ...I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.
Debatably, such languages making the attempt, are less likely to succeed. Off rip, Rust already occupies that space. So, trying to make a "better Rust", which is already a specialist in that field (safety) and has already got "the push" from large corporate backers (Mozilla, Samsung, Quantum...) will usually mean failure, remaining in niche status, or overcoming incredible odds (like hitting a Lotto jackpot). The more the language specializes on that particular use case, then arguably the less general appeal and general use. And if there is already competition doing it better or being more known for that focus, the harder the hill to climb.
For that matter, trying to make a "better C", is another tough hill. Not only because C is so entrenched and established, but that there is already a long list of quasi "better Cs" out there such as Object Pascal, D, Nim, etc... Add in more complex or confusing syntax, less features, less functionality, or less usefulness... Then the hill gets even more steep. Hitting the bullseye, just isn't easy.
Could you expand on the specific problems that each language avoids?
The big thing that this allows is for you take the ideas of C++ templates to the extreme. In Julia pretty much every function behaves like a C++ function that is templated on the type of every input. This has the major advantage that it is really easy to write extremely fast generic code. This only works in general though because Julia only has to generate code for the types that actually appear rather than all the type combinations that static analysis can conclude might appear.
In what world did people not know about MPMC queues?
Here are the experiences of Wooga and Activision/Blizzard using it.
https://www.gdcvault.com/play/1016648/Why-Erlang
http://www.erlang-factory.com/upload/presentations/395/Erlan...
Go's concurrency builds on CSP and they're open about it, but it is not just about who came up with it but who made it mainstream and for that Go certainly deserves credit.
That’s because other languages did not need channels as a core language features.
Go does for the same reasons it needs e.g. hashmaps or append as “core language features”: no generics.
As far as I could see, there was one cool thing Go brought to the table, and it’s select {}. That was (and still is, I think) pretty uncommon, though not unheard of (Erlang’s receive is similar, though it has different capabilities owing to different language semantics).
git blame
Oh that was me.
> I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.
You could be right about this, but boy, I hope you are wrong. And I'm trying to prove that it's possible.
I think the answer is structured concurrency [1], and here's why:
1. Structured concurrency can replace everything async/await can do. At least, I believe so, kind of like it's believed that structured programming can replace any unstructured use of goto.
2. If you extend structured concurrency a bit so that the thread tree is actually a DAG [2], you basically get a borrow checker for free because every item is rooted in a thread stack somewhere, and where it is rooted is always before everything that it could own and after everything that could own it.
3. Making the thread tree a DAG also means it's easy to implement RAII and have it work meaning no use-after-free, no double frees, etc.
Put that on top of a language that has memory safety by default, and you will have everything that Rust gives you without the complexity.
This isn't theoretical; I have implemented this in C. [3] (See [4] for a use of it.) I have even implemented bounds checking in C. [5]
However, I'm also implementing a programming language with these ideas (see [6] for the example file and [7] within that file for how structured concurrency might be exposed in the language).
As for readability, I do think that what I have is readable. However, I appreciate comments; readability is important to me too, but I've spent so long with this work that I am blind to what is actually readable to other people.
[1]: https://gavinhoward.com/2019/12/structured-concurrency-defin...
[2]: https://lobste.rs/s/8msejg/notes_on_structured_concurrency_g...
[3]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...
[4]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/rig/bui...
[5]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...
[6]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...
[7]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...
Whether we look at Zig, Go or Julia they stay relatively simple because they simply avoid solving certain problems. I think that is a fair tradeoff. I think good language design is really about figuring out what problems can we dump on the user which they will be able to handle relatively well.
A reason why there are so many languages I think is because different people have different preferences in terms of what problems the want to avoid dealing with and what problems they are fine dealing with.
Personally I think that if you "solve" a problem by making the language so complex that developers cannot easily read and reason about the code, then you haven't actually solved any problem. Priority must always be placed on the ability of developers to read and understand code.
Unreadable code will naturally be a source of bugs.