Rewriting Rust

368 points by yett 9 months ago | 400 comments
  • gary17the 9 months ago
    > The rust RFC process is a graveyard of good ideas.

    I actually have quite an opposite view: I think the Rust core team is 100% correct to make it very hard to add new "features" to the PL, in order to prevent the "language surface" from being bloated, inconsistent and unpredictable.

    I've seen this happen before: I started out as a Swift fan, even though I have been working with Objective-C++ for years, considered it an awesome powerhouse and I did not really need a new PL for anything in particular in the world of iOS development. With time, Swift's insistence on introducing tons of new language "features" such as multiple, redundant function names, e.g., "isMultiple(of:)", multiple rules for parsing curly braces at al. to make the SwiftUI declarative paradigm possible, multiple rules for reference and value types and mutability thereof, multiple shorthand notations such as argument names inside closures, etc. - all that made me just dump Swift altogether. I would have to focus on Swift development exclusively just to keep up, which I was not willing to do.

    Good ideas are "dime a dozen". Please keep Rust as lean as possible.

    • josephg 9 months ago
      Author here. I hear what you're saying. But there's lots of times while using rust where the language supports feature X and feature Y, but the features can't be used together.

      For example, you can write functions which return an impl Trait. And structs can contain arbitrary fields. But you can't write a struct which contains a value returned via impl Trait - because you can't name the type.

      Or, I can write if a && b. And I can write if let Some(x) = x. But I can't combine those features together to write if let Some(x) = x && b.

      I want things like this to be fixed. Do I want rust to be "bigger"? I mean, measured by the number of lines in the compiler, probably yeah? But measured from the point of view of "how complex is rust to learn and use", feature holes make the language more complex. Fixing these problems would make the language simpler to learn and simpler to use, because developers don't have to remember as much stuff. You can just program the obvious way.

      Pin didn't take much work to implement in the standard library. But its not a "lean" feature. It takes a massive cognitive burden to use - to say nothing of how complex code that uses it becomes. I'd rather clean, simple, easy to read rust code and a complex borrow checker than a simple compiler and hard to use language.

      • withoutboats3 9 months ago
        These features are slow to be accepted for good reasons, not just out of some sort of pique. For example, the design space around combining `if let` pattern matching with boolean expressions has a lot of fraught issues around the scoping of the bindings declared in the pattern. This becomes especially complex when you consider the `||` operator. The obvious examples you want to use work fine, but the feature needs to be designed in such a way that the language remains internally consistent and works in all edge cases.

        > Pin didn't take much work to implement in the standard library. But its not a "lean" feature. It takes a massive cognitive burden to use - to say nothing of how complex code that uses it becomes. I'd rather clean, simple, easy to read rust code and a complex borrow checker than a simple compiler and a horrible language.

        Your commentary on Pin in this post is even more sophomoric than the rest of it and mostly either wrong or off the point. I find this quite frustrating, especially since I wrote detailed posts explaining Pin and its development just a few months ago.

        https://without.boats/blog/pin/https://without.boats/blog/pinned-places/

        • senorrib 9 months ago
          I think you just proved his point on how hard it is to understand and correctly use Pin.
          • adwn 9 months ago
            > Your commentary on Pin in this post is even more sophomoric than the rest of it and mostly either wrong or off the point. I find this quite frustrating, especially since I wrote detailed posts explaining Pin and its development just a few months ago.

            To me, this sounds as if the Pin concept is so difficult to understand that it's hard to even formulate correct criticism about it.

            I get that Pin serves a critical need related to generators and async, and in that it was a stroke of genius. But you as the creator of Pin might not be the right person to judge how difficult Pin is for the more average developers among us.

            • josephg 9 months ago
              > The obvious examples you want to use work fine, but the feature needs to be designed in such a way that the language remains internally consistent and works in all edge cases.

              True. How long should that process take? A month? A year? Two years?

              I ask because this feature has been talked about since I started using rust - which (I just checked) was at the start of 2017. Thats nearly 8 years ago now.

              6 years ago this RFC was written: https://rust-lang.github.io/rfcs/2497-if-let-chains.html - which fixes my issues. But it still hasn't shipped.

              Do I have too high expectations? Is 6 years too quick? Maybe, a decade is a reasonable amount of time to spend, to really talk through the options? Apparently 433 people contributed to Rust 1.81. Is that not enough people? Do we need more people, maybe? Would that help?

              Yes, I do feel piqued by the glacial progress. I don't care about the || operator here - since I don't have any instinct for what that should do. And complex match expressions are already covered by match, anyway.

              Rust doesn't do the obvious thing, in an obvious, common situation. If you ask me, this isn't the kind of problem that should take over 6 years to solve.

              > Your commentary on Pin in this post is even more sophomoric than the rest of it and mostly either wrong or off the point. I find this quite frustrating, especially since I wrote detailed posts explaining Pin and its development just a few months ago.

              If I'm totally off base, I'd appreciate more details and less personal insults.

              I've certainly given Pin an honest go. I've used Pin. I've read the documentation, gotten confused and read everything again. I've struggled to write code using it, given up, then come back to it and ultimately overcame my struggles. I've boxed so many things. So many things.

              The thing I've struggled with the most was writing a custom async stream wrapper around a value that changes over time. I used tokio's RwLock and broadcast channel to publish changes. My Future needed a self-referential type (because I need to hold a RwLockGuard across an async boundary). So I couldn't just write a simple, custom struct. But I also couldn't use an async function, because I needed to implement the stream trait.

              As far as I can tell, the only way to make that code work was to glue async fn and Futures together in a weird frankenstruct. (Is this a common pattern? For all the essays about Pin and Future out there, I haven't heard anyone talk about this.) I got the idea from how tokio implements their own stream adaptor for broadcast streams[1]. And with that, I got this hairy piece of code working.

              But who knows? I've written hundreds of lines of code on top of Pin. Not thousands. Maybe I still don't truly get it. I've read plenty of blog posts, with all sorts of ideas about Pin being about a place, or about a value, or a life philosophy. But - yes, I haven't yet, also read the 9000 words of essay you linked. Maybe if I do so I'll finally, finally be enlightened.

              But I doubt it. I think Pin is hard. If it was simple, you wouldn't have written 9000 words talking about it. As you say:

              > Unfortunately, [pin] has also been one of the least accessible and most misunderstood elements of async Rust.

              Pin foists all its complexity onto the programmer. And for that reason, I think its a bad design. Maybe it was the best option at the time. But if we're still talking about it years later - if its still confusing people so long after its introduction - then its a bad part of the language.

              I also suspect there are way simpler designs which could solve the problems that pin solves. Maybe I'm an idiot, and I'm not the guy who'll figure those designs out. But in that case, I'd really like to inspire smarter people than me to think about it. There's gotta be a simpler approach. It would be incredibly sad if people are still struggling with Pin long after I'm dead.

              [1] https://github.com/tokio-rs/tokio/blob/master/tokio-stream/s...

              • wokwokwok 9 months ago
                > The obvious examples you want to use work fine, but the feature needs to be designed in such a way that the language remains internally consistent and works in all edge cases.

                ?? Then why did the language team put it on the 2024 roadmap? Am I looking at something different? (Specifically on under the 'Express yourself more easily' (1) goal, which links to the RFC issue (2)).

                It certainly looks like the implementation is both complete and unblocked, and actively used.

                It looks more like the issue is (despite being put on the roadmap and broadly approved as a feature), being argued about because of the alternative proposal for 'is' syntax.

                ie. If you want to generalize then yes, there are features which are difficult to implement (yeah, I'll just make a Move trait... yeah... No. It's not that easy).

                BUT.

                That's not a problem.

                A lot of clever folk can work through issues like that and find solutions for that kind of problem.

                The real problem is that RCFs like this end up in the nebulous 'maybe maybe' bin, where they're implemented, have people who want them, have people who use them, have, broadly the approval of the lang team (It's on the roadmap).

                ...but then, they sit there.

                For months. Or years. While people argue about it.

                It's kind of shit.

                If you're not going to do it, make the call, close the RFC. Say "we're not doing this". Bin the code.

                Or... merge it into stable.

                Someone has to make the call on stuff like this, and it's not happening.

                This seems to happen to a fair few RFCs to a greater or less extent, but this one is particularly egregious in my opinion.

                [1] - https://lang-team.rust-lang.org/roadmaps/roadmap-2024.html#t... [2] - https://github.com/rust-lang/rust/issues/53667

                • criticalfault 9 months ago
                  Given that your proposal is backwards compatible, what is preventing it from moving to standard language faster? Especially if it improves the situation drastically.

                  Also, why would pinned be a syntactic sugar for Pin and not the other way around?

                  • adastra22 9 months ago
                    A properly designed feature shouldn’t require an entire blog post, let alone multiple, to understand.
                  • gary17the 9 months ago
                    I think it would be helpful to clearly distinguish between PL simplification (e.g., "if let Some(x) = x, x == 42 {}") and convenience-driven PL expansion (e.g., "let @discardable lhs = rhs ?? 0;"). In case of the former, I'm with you. In case of the latter, I'm not. Rust likely isn't meant to be a tool that is easy to learn at all costs (since the borrow checker does exist, after all). Rust is, IMvHO, supposed to be like vi: hard to learn and easy to use :).
                    • adastra22 9 months ago
                      We should strive for easy to learn, easy to use.
                    • valenterry 9 months ago
                      Yeah, I agree wholeheartedly with that. This is also what I really dislike in many languages.

                      You should have a look at Scala 3. Not saying that I'm perfectly happy with the direction of the language - but Scala really got those foundations well and made it so that it has few features but they are very powerful and can be combined very well.

                      Rust took a lot of inspiration from Scala for a reason - but then Rust wants to achieve zero-cost abstraction and do high-performance, so it has to make compromises accordingly for good reasons. Some of those compromises affect the ergonomics of the language unfortunately.

                      • nindalf 9 months ago
                        It is easier to make big breaking changes when there are fewer users, for sure. I think what you ignore is both the progress that is being made and how difficult it is to make that progress while maintaining a stable language that works for all the existing users.

                        I'll give an example - async traits. On the surface it seems fairly simple to add? I can say async fn, but for the longest time I couldn't say async fn inside a trait? It took years of work to solve all the thorny issues blocking this in a stable, backwards compatible way and finally ship it [1]. There is still more work to be done but the good news is that they're making good progress here!

                        You pointed out one feature that Rust in Linux needs (no panics), but there are several more [2]. That list looks vast, because it is. It represents years of work completed and several more years of work in the Rust and Rust for Linux projects. It might seem reasonable to ask why we can't have it right now, but like Linus said recently "getting kernel Rust up to production levels will happen, but it will take years". [3] He also pointed out that the project to build Linux with clang took 10 years, so slow progress shouldn't discourage folks. The important thing is that the Rust project maintainers have publicly committed to working on it right now - "For 2024H2 we will work to close the largest gaps that block support (for adopting Rust in the kernel)". [4]

                        You dream of a language that could make bold breaking changes and mention Python 2.7 in passing. The Python 2/3 split was immensely painful and widely considered to be a mistake, even among the people who had advocated for it. The Rust project has a better mechanism for small, opt-in, breaking changes - the Edition system. That has worked well for the last 9 years and has led to tremendous adoption - more than doubling every year [5]. IMO there's no reason to fix what isn't broken.

                        I guess what I'm saying is, patience is the key here. Each release might not bring much because it only represents 6 weeks of work, but the cumulative effect of a year's worth of changes is pretty fantastic. Keep the faith.

                        [1] - https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-trait...

                        [2] - https://github.com/Rust-for-Linux/linux/issues/2

                        [3] - https://lwn.net/SubscriberLink/991062/b0df468b40b21f5d/

                        [4] - https://blog.rust-lang.org/2024/08/12/Project-goals.html

                        [5] - https://lib.rs/stats

                        • devit 9 months ago
                          You can make the struct generic on the type to have a field being an impl Trait type.
                          • josephg 9 months ago
                            I know. Sometimes that can work. But that choice will ripple out to cause all sorts of other complications throughout your codebase. Now you have a Struct<T>. How do you pass one of these structs as a parameter to another function? Do you need to make that function generic over all T? How do you embed that into another struct, in turn? Do you put generic arguments everywhere? And so on.

                            Fundamentally, I don't want my type to be generic over all implementations. I want a concrete type. I want the type returned by one specific, often private, function.

                            But, nope. Not today. Maybe with TAIT, whenever that ships.

                          • cdaringe 9 months ago
                            Dude YES. This stuff was maddening in rust. “How many links to GitHub issues will the compiler fire at me today” was a sincere feeling. I think it’s much better these days, but you still get em doing async work
                            • pdimitar 9 months ago
                              I hate it as well and I also feel async Rust needs years of much better love than it received at its conception. But... some info is still better than no info.
                          • kazinator 9 months ago
                            It's easier to write RFCs than to implement them, and there are more people who can write RFCs. At any popularity level, you have more of the former. Therefore, an RFC queue will always look like a graveyard of good ideas, even if 100% of the queued ideas are being accepted and eventually worked on, simply due to the in/out differential rate.

                            If you want an edge over the people who are writing RFCs, don't write an RFC. Write a complete, production-ready implementation of your idea, with documentation and test cases, which can be cleanly merged into the tree.

                            • JoshTriplett 9 months ago
                              > If you want an edge over the people who are writing RFCs, don't write an RFC. Write a complete, production-ready implementation of your idea, with documentation and test cases, which can be cleanly merged into the tree.

                              Please by all means provide an implementation, but do write the RFC first. (Or in some cases smaller processes, such as the ACP process for a small standard-library addition.) Otherwise you may end up wasting a lot of effort, or having to rewrite the implementation. We are unlikely to accept a large feature, or even a medium feature, directly from a PR without an RFC.

                              • estebank 9 months ago
                                I've noticed that having even a minimal implementation helps a lot to inform the RFC: some details are non-obvious until you are either forced to clamp down behavior or have tried to use the feature. The RFC discussion doesn't always surface these.

                                I've also been thinking that we should go over our stabilized RFCs and add an appendix to all of them documenting how the current implementation diverges from the original proposal.

                            • hiimkeks 9 months ago
                              I general I agree, but we are also in the paradoxical situation that generic associated constants in traits are stable, but you can't actually use them as constants. You can't use them as const generics for other types, and you can't use them for array lengths.

                              I'd argue that this makes them pretty useless: if you just want a value that you can use like any other, then you can define a function that returns it and be done with it. Now we have another way to do it, and in theory it could do more, but that RFC has been stale for several years, nobody seems to be working on it, and I believe it's not even in nightly.

                              If the support would actually be good, we could just get rid of all the support crates we have in cryptography libraries (like the generic_array and typenum crates).

                              That said, I agree that the Rust team should be careful about adding features.

                              • nicce 9 months ago
                                > Now we have another way to do it, and in theory it could do more, but that RFC has been stale for several years, nobody seems to be working on it, and I believe it's not even in nightly.

                                What is this way? I have been fighting with this problem for quite some time recently.

                              • formerly_proven 9 months ago
                                > Please keep Rust as lean as possible.

                                Alternatively: Rust is already the Wagyu of somewhat-mainstream PLs, don't keep adding fat until it's inedible.

                                • 9 months ago
                                • goodpoint 9 months ago
                                  > Good ideas are "dime a dozen". Please keep Rust as lean as possible.

                                  Good ideas are rare and precious by definition.

                                  • gary17the 9 months ago
                                    I think it would be helpful to clearly distinguish between "good ideas" and "excellent ideas". It's relatively easy in the complex art of programming to come up with a dozen good ideas. It seems very hard in the complex art of programming to come up with even one truly excellent idea.
                                • dist1ll 9 months ago
                                  I think the dependency situation is pretty rough, and very few folks want to admit it. An example I recently stumbled upon: the cargo-watch[0] crate.

                                  At its core its a pretty simple app. I watches for file changes, and re-runs the compiler. The implementation is less than 1000 lines of code. But what happens if I vendor the dependencies? It turns out, the deps add up to almost 4 million lines of Rust code, spread across 8000+ files. For a simple file-watcher.

                                  [0] https://crates.io/crates/cargo-watch

                                  • alexvitkov 9 months ago
                                    That's what inevitably happens when you make transitive dependencies easy and you have a culture of "if there's a library for it you must use it!"

                                    C/C++ are the only widely used languages without a popular npm-style package manager, and as a result most libraries are self-contained or have minimal, and often optional dependencies. efsw [1] is a 7000 lines (wc -l on the src directory) C++ FS watcher without dependencies.

                                    The single-header libraries that are popular in the game programming space (stb_* [2], cgltf [3], etc) as well as of course Dear ImGui [4] have been some of the most pleasant ones I've ever worked with.

                                    At this point I'm convinced that new package managers forbidding transitive dependencies would be an overall net gain. The biggest issue are large libraries that other ones justifiably depend on - OpenSSL, zlib, HTTP servers/clients, maybe even async runtimes. It's by no means an unsolvable problem, e.g. instead of having zlib as a transitive dependency, it could:

                                    1. a library can still hard-depend on zlib, and just force the user to install it manually.

                                    2. a library can provide generic compress/decompress callbacks, that the user can implement with whatever.

                                    3. the compress/decompress functionality can be make standard

                                    [1] https://github.com/SpartanJ/efsw

                                    [2] https://github.com/nothings/stb

                                    [3] https://github.com/jkuhlmann/cgltf

                                    [4] https://github.com/ocornut/imgui

                                    • lifthrasiir 9 months ago
                                      > The single-header libraries that are popular in the game programming space (stb_* [2], cgltf [3], etc) as well as of course Dear ImGui have been some of the most pleasant ones I've ever worked with.

                                      The mainstream game programming doesn't use C at all. (Source: I had been a gamedev for almost a decade, and I mostly dealt with C# and sometimes C++ for low-level stuffs.) Even C++ is now out of fashion for at least a decade, anyone claiming that C++ is necessary for game programming is likely either an engine developer---a required, but very small portion of all gamedevs---or whoever haven't done significant game programming recently.

                                      Also, the reason that single-header libraries are rather popular in C is that otherwise they will be so, SO painful to use by the modern standard. As a result, those libraries have to be much more carefully designed than normal libraries either in C or other languages and contribute to their seemingly higher qualities. (Source: Again, I have written sizable single-header libraries in C and am aware of many issues from doing so.) I don't think this approach is scalable in general.

                                      • raverbashing 9 months ago
                                        > The mainstream game programming doesn't use C at all. (Source: I had been a gamedev for almost a decade

                                        Game programming changed a lot, parent is talking about stuff older than 10 yrs

                                        There was a lot of PC gaming in C/C++, and "Engine" were developed together with games for the most part. Think all the Doom and Quake saga

                                        That's what he's talking about

                                      • mike_hearn 9 months ago
                                        > as a result most libraries are self-contained or have minimal, and often optional dependencies

                                        If you ignore the OS, then sure. Most C/C++ codebases aren't really portable however. They're tied to UNIX, Windows or macOS, and often some specific version range of those, because they use so many APIs from the base OS. Include those and you're up to millions of lines too.

                                        • xpe 9 months ago
                                          > That's what inevitably happens when you make transitive dependencies easy and you have a culture of "if there's a library for it you must use it!"

                                          1. This doesn't mean that C++'s fragmented hellscape of package management is a good thing.

                                          2. "inevitably"? No. This confuses the causation.

                                          3. This comment conflates culture with tooling. Sure, they are related, but not perfectly so.

                                          • the_gipsy 9 months ago
                                            > a library can provide generic compress/decompress callbacks, that the user can implement with whatever.

                                            This only works for extremely simple cases. Beyond toy example, you have to glue together two whole blown APIs with a bunch of stuff not aligning at all.

                                            • Measter 9 months ago
                                              Having a quick look at efsw, it depends on both libc and the windows API, both are huge dependencies. The Rust bindings for libc come to about 122 thousand lines, while the winapi crate is about 180 thousand lines.

                                              [Edit] And for completeness, Microsoft's Windows crate is 630 thousand lines, though that goes way beyond simple bindings, and actually provides wrappers to make its use more idiomatic.

                                              • xpe 9 months ago
                                                > At this point I'm convinced that new package managers forbidding transitive dependencies would be an overall net gain.

                                                Composition is an essential part of software development, and it crosses package boundaries.

                                                How would banishing inter-package composition be a net gain?

                                              • DanielHB 9 months ago
                                                The fact is that dependency jungle is the prevalent way to get shit done these days. The best the runtime can do is embrace it, make it as performant and safe as possible and try to support minimum-dependency projects by having a broad std library.

                                                Also I am no expert, but I think file-watchers are definitely not simple at all, especially if they are multi-platform.

                                                • kreyenborgi 9 months ago
                                                  https://github.com/eradman/entr is

                                                      Language                     files          blank        comment           code
                                                      -------------------------------------------------------------------------------
                                                      C                                4            154            163            880
                                                      Bourne Shell                     2             74             28            536
                                                      C/C++ Header                     4             21             66             70
                                                      Markdown                         1             21              0             37
                                                      YAML                             1              0              0             14
                                                      -------------------------------------------------------------------------------
                                                      SUM:                            12            270            257           1537
                                                      -------------------------------------------------------------------------------
                                                  
                                                  including a well-designed CLI.

                                                  entr supports BSD, Mac OS, and Linux (even WSL). So that's several platforms in <2k lines of code. By using MATHEMATICS and EXTRAPOLATION we find that non-WSL Windows file-watching must take four million minus two thousand equals calculate calculate 3998000 lines of code. Ahem.

                                                  Though to be fair, cargo watch probably does more than just file-watching. (Should it? Is it worth the complexity? I guess that depends on where you land on the worse-is-better discussion.)

                                                  • lifthrasiir 9 months ago
                                                    You are comparing a bicycle and a car; while you might only need a bicycle for your daily life, they are not directly comparable.

                                                    BSD, Mac OS and Linux share the same interface that approximates POSIX---so it only supports a single platform with different variants. Its CLI is not well-designed, it's just a fixed unconditional terminal sequence that even doesn't look at $TERM and its options have no long counterpart (probably because it couldn't use getopt_long which is a GNU extension). And cargo-watch actually parses the `cargo metadata` JSON output (guess what's required for parsing JSON in C) and deals with ignore patterns which are consistent in syntax (guess what's required for doing that besides from fnmatch).

                                                    And I'm not even meant to say that the supposed figure of 4M LoC is all required. In fact, while the problem itself does exist, I don't think that figure is accurate at all, given the massive `windows` crate was blindly counted towards. I guess the faithful reproduction of cargo-watch without any external library will take about 20--50K lines of code in Rust and in C. But doing it in C would be much more painful and you will instead cut requirements.

                                                    • ben-schaaf 9 months ago
                                                      Note that entr doesn't recursively watch for file changes. It has a list of files it watches for changes, but this list isn't amended when new files are added. Fundamentally that's a fairly small subset of proper recursive file watching. In terms of just watching files a better project to compare against is https://github.com/inotify-tools/inotify-tools.
                                                      • raincole 9 months ago
                                                        > By using MATHEMATICS and EXTRAPOLATION we find that non-WSL Windows file-watching must take four million minus two thousand equals calculate calculate 3998000 lines of code

                                                        You joke, but Windows support is the main (probably the only?) reason why cargo-watch is huge. Rust ecosystem has some weird shit when interacting with Windows.

                                                      • dist1ll 9 months ago
                                                        That's the usual response I get when I bring this issue up. "file watching is actually very complicated" or "if you avoided deps, you'd just reimplement millions of loc yourself.

                                                        Forgive me if I'm making a very bold claim, but I think cross-platform file watching should not require this much code. It's 32x larger than the Linux memory management subsystem.

                                                        • joatmon-snoo 9 months ago
                                                          Good file watching that provides flexible primitives absolutely requires:

                                                          - ok, a single ext4 file inode changes, and its filename matches my hardcoded string

                                                          - oh, you don’t want to match against just changes to “package.json” but you want to match against a regex? voila, now you need a regex engine

                                                          - what about handling a directory rename? should that trigger matches on all files in the renamed directory?

                                                          - should the file watcher be triggered once per file, or just every 5ms? turns out this depends on your use case

                                                          - how do symlinks fit into this story?

                                                          - let’s say i want to handle once every 5ms- how do i actually wait for 5ms? do i yield the thread? do i allow other async contexts to execute while i’m waiting? how do those contexts know when to execute and when to yield back to me? now you have an async runtime with timers

                                                          - how does buffering work? are there limits on how many file change events can be buffered? do i dynamically allocate more memory as more file changes get buffered? now you need a vector/arraylist implementation

                                                          And this is before you look at what this looks like on different platforms, or if you want polling fallbacks.

                                                          Can you do it with less dependencies? Probably, if you start making hard tradeoffs and adding even more complexity about what features you activate - but that only adds lines of code, it doesn’t remove them.

                                                          What you describe is ideologically nice, but in practice it’s over-optimizing for a goal that most people don’t really care about.

                                                          • SkiFire13 9 months ago
                                                            It's not just file watching, that would be the watchexec crate, while cargo-watch properly integrate with cargo. Moreover cargo-watch also includes:

                                                            - proper CLI support, with help messages, subcommands and so on

                                                            - support for reading cargo's metadata

                                                            - logging

                                                            - support for dotenv files

                                                            - proper shell escaping support

                                                            - and it seems also support for colored terminal writing.

                                                            Moreover both watchexec and cargo-watch end up depending on winapi, which includes binding for a lot of windows API, some which might be needed and some which not be.

                                                            This could also be worse if the offial windows crate by Microsoft was used (or maybe it's already used due to some dependency, I haven't checked), since that's gigantic.

                                                            • DanielHB 9 months ago
                                                              I think the issue of file-watching is that the libs usually support multiple implementations (with different tradeoffs and with multiple fallbacks) for file-watching with a lot of them being platform specific.
                                                              • j-krieger 9 months ago
                                                                Eh. The standard library is also a gigantic dependency written entirely by volunteers.
                                                              • SkiFire13 9 months ago
                                                                > try to support minimum-dependency projects by having a broad std library.

                                                                Since everyone depends on the standard library this will just mean everyone will depend on even more lines of code. You are decreasing the number of nominal dependencies but increasing of much code those amount to.

                                                                Moreover the moment the stdlib's bundled dependency is not enough there are two problems:

                                                                - it can't be changed because that would be a breaking change, so you're stuck with the old bad implementation;

                                                                - you will have to use an alternative implementation in another crate, so now you're back at the starting situation except with another dependency bundled in the stdlib.

                                                                Just look at the dependency situation with the python stdlib, e.g. how many versions of urllib there are.

                                                                • DanielHB 9 months ago
                                                                  You do have good points as well and it depends heavily on how disciplined the std lib makers are. Go for example has a very clean and stable std lib.

                                                                  I posted this in some other thread:

                                                                  I am not a Rust expert but the thing with the standard libraries is that it only has peer dependencies with itself and they are all synced to the same version. Meaning if you only use the std lib you:

                                                                  1) Will never include two different versions of the same peer dependency because of incompatible version requirements.

                                                                  2) Will usually not have two dependencies relying on two different peer-dependencies that do the same thing. This can still happen for deprecated std lib features, but tends to be a much lesser issue.

                                                                  These two issues are usually the ones that cause dependency size explosion in projects.

                                                                • chillfox 9 months ago
                                                                  "I think file-watchers are definitely not simple at all"

                                                                  I don't really know much about Rust, but I got curious and had a look at the file watching apis for windows/linux/macos and it really didn't seem that complicated. Maybe a bit fiddly, but I have a hard time imagining how it could take more than 500 lines of code.

                                                                  I would love to know where the hard part is if anyone knows of a good blog post or video about it.

                                                                  • 0x000xca0xfe 9 months ago
                                                                    If you lose track of your dependencies you are just asking for supply chain attacks.

                                                                    And since xz we know resourceful and patient attackers are reality and not just "it might happen".

                                                                    Sorry but sprawling transitive micro-dependencies are not sustainable. It's convenient and many modern projects right now utilize it but they require a high-trust environment and we don't have that anymore, unfortunately.

                                                                  • cogman10 9 months ago
                                                                    This is a natural and not really scary thing.

                                                                    All code is built on mountains of dependencies that by their nature will do more than what you are using them for. For example, part of cargo watch is to bring in a win32 API wrapper library (which is just autogenerated bindings for win32 calls). Of course that thing is going to be massive while watch is using only a sliver of it in the case it's built for windows.

                                                                    The standard library for pretty much any language will have millions of lines of code, that's not scary even though your apps likely only use a fraction of what's offered.

                                                                    And have you ever glanced at C++'s boost library? That thing is monstrously big yet most devs using it are going to really only grab a few of the extensions.

                                                                    The alternative is the npm hellscape where you have a package for "isOdd" and a package for "is even" that can break the entire ecosystem if the owner is disgruntled because everything depends on them.

                                                                    Having fewer larger dependencies maintained and relied on by multiple people is much more ideal and where rust mostly finds itself.

                                                                    • throwitaway1123 9 months ago
                                                                      > The alternative is the npm hellscape where you have a package for "isOdd" and a package for "is even" that can break the entire ecosystem if the owner is disgruntled because everything depends on them.

                                                                      The is-odd and is-even packages are in no way situated to break the ecosystem. They're helper functions that their author (Jon Schlinkert) used as dependencies in one of his other packages (micromatch) 10 years ago, and consequently show up as transitive dependencies in antiquated versions of micromatch. No one actually depends on this package indirectly in 2024 (not even the author himself), and very few packages ever depended on it directly. Micromatch is largely obsolete given the fact that Node has built in globbing support now [1][2]. We have to let some of these NPM memes go.

                                                                      [1] https://nodejs.org/docs/latest-v22.x/api/path.html#pathmatch...

                                                                      [2] https://nodejs.org/docs/latest-v22.x/api/fs.html#fspromisesg...

                                                                      • preommr 9 months ago
                                                                        > The alternative is the npm hellscape where you have a package for "isOdd" and a package for "is even" that can break the entire ecosystem if the owner is disgruntled because everything depends on them.

                                                                        This used to be true 5-10 years ago. The js ecosystem moves fast and much has been done to fix the dependency sprawl.

                                                                        • dartos 9 months ago
                                                                          I… don’t think that’s true.

                                                                          Just look at how many downloads some of those packages have today.

                                                                          Look at the dependency tree for a next or nuxt app.

                                                                          What the js world did is make their build systems somewhat sane, whatwith not needing babel in every project anymore.

                                                                      • lifthrasiir 9 months ago
                                                                        I consciously remove and rewrite various dependencies at work, but I feel it's only a half of the whole story because either 1K or 4M lines of code seem to be equally inaccurate estimates for the appropriate number of LoC for this project.

                                                                        It seems that most dependencies of cargo-watch are pulled from three direct requirements: clap, cargo_metadata and watchexec. Clap would pull lots of CLI things that would be naturally platform-dependent, while cargo_metadata will surely pull most serde stuffs. Watchexec does have a room for improvement though, because it depends on command-group (maintained in the same org) which unconditionally requires Tokio! Who would have expected that? Once watchexec got improved on that aspect however, I think these requirements are indeed necessary for the project's goal and any further dependency removal will probably come with some downsides.

                                                                        A bigger problem here is that you can't easily fix other crates' excessive dependencies. Watchexec can be surely improved, but what if other crates are stuck at the older version of watchexec? There are some cases where you can just tweak Cargo.lock to get things aligned, but generally you can't do that. You have to live with excessive and/or duplicate dependencies (not a huge problem by itself, so it's default for most people) or work around with `[patch]` sections. (Cargo is actually in a better shape given that the second option is even possible at all!) In my opinion there should be some easy way to define a "stand-in" for given version of crate, so that such dependency issues can be more systematically worked around. But any such solution would be a huge research problem for any existing package manager.

                                                                        • cmrdporcupine 9 months ago
                                                                          It's frustrating because the grand-daddy of build systems with automatic transitive dependency management -- Maven -- already had tools from day one to handle this kind of thing through excluded dependencies (a blunt instrument, but sometimes necessary). In my experience, [patch] doesn't cut it or compare.

                                                                          That, and the maven repository is moderated. Unlike crates.io.

                                                                          Crates.io is a real problem. No namespaces, basically unmoderated, tons of abandoned stuff. Version hell like you're talking about.

                                                                          I have a hard time taking it at all seriously as a professional tool. And it's only going to get worse.

                                                                          If I were starting a Rust project from scratch inside a commercial company at this point, I'd use Bazel or Buck or GN/Ninja and vendored dependencies. No Cargo, no crates.io.

                                                                          • lifthrasiir 9 months ago
                                                                            > In my experience, [patch] doesn't cut it or compare.

                                                                            AFAIK what Maven does is an exclusion of dependency edges, which is technically an unsafe thing to do. Cargo [patch] is a replacement of dependency vertices without affecting any edges. (Maven surely has a plugin to do that, but it's not built-in.) They are different things to start with.

                                                                            Also I believe that the edge exclusion as done by Maven is (not just "technically", but) really unsafe and only supported due to the lack of better alternatives. Edges are conceptually dependent to the incoming vertex, so it should be that vertex's responsibility to override problematic edges. An arbitrary removal of edges (or vertices) is much harder to track and many other systems have related pains from that.

                                                                            What I'm proposing here is therefore the extension of Cargo's vertex replacement: you should be able to share such replacements so that they can be systematically dealt. If my transitive dependencies contain some crate X with two different versions 1.0 and 2.0 (say), I should be able to write an adapter from 2.0 to 1.0 or vice versa, and ideally such adapter should be available from the crate author or from the community. I don't think Maven did try any such systematic solution.

                                                                            > That, and the maven repository is moderated. Unlike crates.io.

                                                                            Only the central repository is moderated by Maven. Maven is not much better than Cargo once you have more remote repositories.

                                                                            > Crates.io is a real problem. No namespaces, basically unmoderated, tons of abandoned stuff. Version hell like you're talking about.

                                                                            Namespace is not a solution for name squatting: namespace is just yet another identifier that can be squatted. If you are worried about squatting, the only effective solution is sandboxing, everything else is just moving the goal post.

                                                                            The very existence of remote repositories also means that you can't always moderate all the stuffs and get rid of abandoned stuffs. You have to trust repositories, just like that you have to trust crates with crates.io today.

                                                                        • conradludgate 9 months ago
                                                                          I bet most of those lines are from the generated windows api crates. They are notoriously monstrous
                                                                          • dist1ll 9 months ago
                                                                            You're right, the windows crate alone contributes 2.2M. I wonder if there's a way to deal with this issue.
                                                                            • lifthrasiir 9 months ago
                                                                              The exact size of the `windows` crate depends on feature flags, because parsing 2.2M lines of code is always going to be very expensive even when you immediately discard them.
                                                                              • Flex247A 9 months ago
                                                                                Enabling FAT LTO reduces the final binary size but it isn't a permanent fix.
                                                                              • jeroenhd 9 months ago
                                                                                I love and hate the Windows API crates. They're amazing in that they bring pretty much the entire modern Windows API into the language without needing to touch FFI generators yourself, but the Windows API is about as large as almost every package that comes with a desktop Linux install.

                                                                                I wish crates that used Windows stuff wouldn't enable it by default.

                                                                                • lifthrasiir 9 months ago
                                                                                  Well, they do! What happens here is that `windows` crates are lightly processed even when they are disabled, for the reason JoshTriplett mentioned elsewhere. Such "light" processing is negligible in practice, but technically all those lines are processed (and `Cargo.lock` will list them even when they are entirely unused), hence the overblown and extremely misleading figure.
                                                                              • nullifidian 9 months ago
                                                                                Some amount of the risk from the "dependency jungle" situation could be alleviated by instituting "trusted" set of crates that are selected based on some popularity threshold, and with a rolling-release linux-distro-like stabilization chain, graduating from "testing" to "stable". If the Rust Foundation raised more money from the large companies, and hired devs to work as additional maintainers for these key crates, adding their signed-offs, it would be highly beneficial. That would have been a naturally evolving and changing equivalent to an extensive standard library. Mandating at least two maintainer sign offs for such critical set of crates would have been a good policy. Instead the large companies that use rust prefer to vet the crates on their own individually, duplicating the work the other companies do.

                                                                                The fact that nothing has changed in the NPM and Python worlds indicates that market forces pressure the decision makers to prefer the more risky approach, which prioritizes growth and fast iteration.

                                                                                • tbillington 9 months ago
                                                                                  vendor + linecount unfortunately doesn't represent an accurate number of what cargo-watch would actually use. It includes all platform specific code behind compile time toggles even though only one would be used at any particular time, and doesn't account for the code not included because the feature wasn't enabled. https://doc.rust-lang.org/cargo/reference/features.html

                                                                                  whether those factors impact how you view the result of linecount is subjective

                                                                                  also as one of the other commenters mentioned, cargo watch does more than just file watching

                                                                                  • the_clarence 9 months ago
                                                                                    Agree. That was always my major gripe with Rust: it's not battery included. The big selling point of golang was the battery included part and I think that's really what is missing in Rust. I hope that with time more stuff can't get into the rust stdlib
                                                                                    • umanwizard 9 months ago
                                                                                      Why, concretely, does this matter?

                                                                                      Other than people who care about relatively obscure concerns like distro packaging, nobody is impeded in their work in any practical way by crates having a lot of transitive dependencies.

                                                                                      • josephg 9 months ago
                                                                                        Author here. If I compile a package which has 1000 transitive dependencies written by different authors, there's ~1000 people who can execute arbitrary code on my computer, with my full user permissions. I wouldn't even know if they did.

                                                                                        That sounds like a massive security problem to me. All it would take is one popular crate to get hacked / bribed / taken over and we're all done for. Giving thousands of strangers the ability to run arbitrary code on my computer is a profoundly stupid risk.

                                                                                        Especially given its unnecessary. 99% of crates don't need the ability to execute arbitrary syscalls. Why allow that by default?

                                                                                        • pornel 9 months ago
                                                                                          Rust can't prevent crates from doing anything. It's not a sandbox language, and can't be made into one without losing its systems programming power and compatibility with C/C++ way of working.

                                                                                          There are countless obscure holes in rustc, LLVM, and linkers, because they were never meant to be a security barrier against the code they compile. This doesn't affect normal programs, because the exploits are impossible to write by accident, but they are possible to write on purpose.

                                                                                          ---

                                                                                          Secondly, it's not 1000 crates from 1000 people. Rust projects tend to split themselves into dozens of micro packages. It's almost like splitting code across multiple .c files, except they're visible in Cargo. Many packages are from a few prolific authors and rust-lang members.

                                                                                          The risk is there, but it's not as outsized as it seems.

                                                                                          Maintainers of your distro do not review code they pull in for security, and the libraries you link to have their own transitive dependencies from hundreds of people, but you usually just don't see them: https://wiki.alopex.li/LetsBeRealAboutDependencies

                                                                                          Rust has cargo-vet and cargo-crev for vetting of dependencies. It's actually much easier to review code of small single-purpose packages.

                                                                                          • bormaj 9 months ago
                                                                                            Are there any attempts to address this at the package management level (not a cargo-specific question)? My first thought is that the package could declare in its config file the "scope" of access that it needs, but even then I'm sure this could be abused or has limitations.

                                                                                            Seems like awareness about this threat vector is becoming more widespread, but I don't hear much discuss trickling through the grapevine re: solutions.

                                                                                          • zifpanachr23 9 months ago
                                                                                            Because for a lot of companies, especially ones in industries that Rust is supposedly hoping to displace C and C++ in, dependencies are a much larger concern than memory safety. They slow down velocity way more than running massive amounts of static and dynamic analysis tools to detect memory issues does in C. Every dependency is going to need explicit approval. And frankly, most crates would never receive that approval given the typical quality of a lot of the small utility crates and other transitive dependencies. Not to mention, the amount of transitive dependencies and their size in a lot of popular crates makes them functionally unauditable.

                                                                                            This more than any other issue is I think what prevents Rust adoption outside of more liberal w.r.t dependencies companies in big tech and web parts of the economy.

                                                                                            This is actually one positive in my view behind the rather unwieldy process of using dependencies and building C/C++ projects. There's a much bigger culture of care and minimalism w.r.t. choosing to take on a dependency in open source projects.

                                                                                            Fwiw, the capabilities feature described in the post would go a very long way towards alleviating this issue.

                                                                                            • umanwizard 9 months ago
                                                                                              Those companies can just ban using new rust dependencies, if they want to. Writing with minimal dependencies is just as easy in rust as it is in c++
                                                                                              • bobajeff 9 months ago
                                                                                                I disagree i think avoiding dependencies is partly how we have these codebases like chromium's where you can't easily separate the functionally you want and deal with them as a library. That to me isn't minimalism.
                                                                                                • anon-3988 9 months ago
                                                                                                  Does C++ codebases with similar features parity somehow requires less code?
                                                                                                • goodpoint 9 months ago
                                                                                                  There's been many massive supply chain attacks happening.

                                                                                                  And people are still calling it "obscure concerns"...

                                                                                                • hawski 9 months ago
                                                                                                  The friction in C and C++ library ecosystem is sometimes a feature for this sole reason. Many libraries try to pull as little as possible and other things as optional.
                                                                                                  • moss2 9 months ago
                                                                                                    Same problem with JavaScript's NPM. And Python's PIP.
                                                                                                    • jwr 9 months ago
                                                                                                      This isn't necessarily a language problem, though, more of a "culture" problem, I think.

                                                                                                      I write in Clojure and I take great pains to avoid introducing dependencies. Contrary to the popular mantra, I will sometimes implement functionality instead of using a library, when the functionality is simple, or when the intersection area with the application is large (e.g. the library doesn't bring as many benefits as just using a "black box"). I will work to reduce my dependencies, and I will also carefully check if a library isn't just simple "glue code" (for example, for underlying Java functionality).

                                                                                                      This approach can be used with any language, it just needs to be pervasive in the culture.

                                                                                                      • josephg 9 months ago
                                                                                                        > This isn't necessarily a language problem, though, more of a "culture" problem, I think.

                                                                                                        Author here. We could make it a language problem by having the language sandbox dependencies by default. Seems like an easy win to me. Technical solutions are almost always easier to implement than social solutions.

                                                                                                        • orwin 9 months ago
                                                                                                          I think this is made easier with Clojure macro capacity. In general, if you have powerfull metaprogramming tools, you trade dependency complexity with peace of mind (I still have flashbacks of C++ templates when i talk about metaprogramming :/. Does this qualify for PTSD?).
                                                                                                      • iforgotpassword 9 months ago
                                                                                                        Maybe they can learn from the Javascript folks, I heard they're very good at this.
                                                                                                        • pjmlp 9 months ago
                                                                                                          I think the interaction between both communities is exactly the reason of the current state.
                                                                                                          • teaearlgraycold 9 months ago
                                                                                                            Not sure if you're serious and talking about tree-shaking - or joking and talking about left-pad.
                                                                                                            • mseepgood 9 months ago
                                                                                                              No, they are the worst perpetrators re dependency hell.
                                                                                                              • M4Luc 9 months ago
                                                                                                                The Javascript folks are at least aware and self critical of this. In the Rust community it's sold as a great idea.
                                                                                                                • wiseowise 9 months ago
                                                                                                                  Yes, unironically they’re now.

                                                                                                                  Node has improved greatly in last two years. They always had native JSON support. Now have native test runner, watch, fetch, working on permission system à la deno, added WebSockets and working on native SQLite driver. All of this makes it a really attractive platform for prototyping which scales from hello world without any dependencies to production.

                                                                                                                  Good luck experimenting with Rust without pulling half the internet with it.

                                                                                                                  E: and they’re working on native TS support

                                                                                                                  • Denvercoder9 9 months ago
                                                                                                                    > without any dependencies

                                                                                                                    Nah, you still have those dependencies, they're just integrated in your interpreter. That has advantages (you're now only trusting a single source) and disadvantages (you always get all the goodies and the associated risks with that, even if you don't need them).

                                                                                                                • M4Luc 9 months ago
                                                                                                                  Another example is Axum. Using Go, C#, Deno or Node you don't even need any third party provided more or less secure and maintained lib. It all comes from the core teams.
                                                                                                                  • olalonde 9 months ago
                                                                                                                    Why do you care how many lines of code the dependencies are? Compile time? Lack of disk space?
                                                                                                                    • ptsneves 9 months ago
                                                                                                                      Think of the problem as a bill of materials. Knowing the origin and that all the components of a part are fit for purpose is important for some applications.

                                                                                                                      If I am making a small greenhouse i can buy steel profiles and not care about what steel are they from. If I am building a house I actually want a specific standardized profile because my structure's calculations rely on that. My house will collapse if they dont. If I am building a jet engine part I want a specific alloy and all the component metals and foundry details, and will reject if the provenance is not known or suitable[1].

                                                                                                                      If i am doing my own small script for personal purposes I dont care much about packaging and libraries, just that it accomplishes my immediate task on my environment. If I have a small tetris application I also dont care much about libraries, or their reliability. If I have a business selling my application and I am liable for its performance and security I damn sure want to know all about my potential liabilities and mitigate them.

                                                                                                                      [1] https://www.usatoday.com/story/travel/airline-news/2024/06/1...

                                                                                                                      • M4Luc 9 months ago
                                                                                                                        Security and maintenance. That's what's so compelling about Go. The std lib is not a pleasure to use. Or esp. fast and featureful. But you can rely on it. You don't depend on 1000 strangers on the internet that might have abandoned their Rust crate for 3 years and nobody noticed.
                                                                                                                        • cmrdporcupine 9 months ago
                                                                                                                          Some of us like to understand what's happening in the software we work on, and don't appreciate unnecessary complexity or unknown paths in the codebase that come through third party transitive dependencies.

                                                                                                                          Some of us have licensing restrictions we have to adhere to.

                                                                                                                          Some of us are very concerned about security and the potential problems of unaudited or unmoderated code that comes in through a long dependency chain.

                                                                                                                          Hard learned lessons through years of dealing with this kind of thing: good software projects try to minimize the size of their impact crater.

                                                                                                                        • armitron 9 months ago
                                                                                                                          This is the main reason we have banned Rust across my Org. Every third party library needs to be audited before being introduced as a vendored dependency which is not easy to do with the bloated dependency chains that Cargo promotes.
                                                                                                                          • skywal_l 9 months ago
                                                                                                                            The dependency hell issue is not directly related to Rust. The Rust language can be used without using any dependency. Have you banned javascript and python too?
                                                                                                                            • Zagitta 9 months ago
                                                                                                                              And in a similar vein have they audited the runtimes of all the languages they use? Because those a dependencies too and in many ways even more critical than libraries.
                                                                                                                            • OtomotO 9 months ago
                                                                                                                              Good on you, this approach will keep you employed for a looooooooong time, because someone has to write all that code then, right? ;)
                                                                                                                              • mu53 9 months ago
                                                                                                                                TBH, I have adjusted my programming recently to write more stuff myself instead of finding a library. Its not that bad. I think ChatGPT are really good at these at those types of questions since it can analyze multiple from github and give you an answer averaging them together.

                                                                                                                                Also, if you just have a really well defined problem, its easy to just whip out 10-50 lines to solve the issue and be done with it

                                                                                                                              • cmrdporcupine 9 months ago
                                                                                                                                Why ban Rust instead of just banning Cargo?

                                                                                                                                It's entirely possible to use Rust with other build systems, with vendored dependencies.

                                                                                                                                Crates.io is a blight. But the language is fine.

                                                                                                                                • j-krieger 9 months ago
                                                                                                                                  How do you solve this for other languages you use?
                                                                                                                                  • hu3 9 months ago
                                                                                                                                    I've seen this approach go a long way with languages that have a large standard library. Go and C# .NET comes to mind.
                                                                                                                                    • armitron 9 months ago
                                                                                                                                      Our main languages are Go and OCaml. We can leverage third party libraries without easily running into transitive dependency hell as there’s an implicit understanding in these communities that large number of dependencies is not a good thing. Or, expressed differently, there is coarser granularity in what ends up being a library. This is not the case with Cargo which has decided to follow the NPM approach.
                                                                                                                                    • simonask 9 months ago
                                                                                                                                      I'm sorry, but that feels like an incredibly poorly informed decision.

                                                                                                                                      One thing is to decide to vendor everything - that's your prerogative - but it's very likely that pulling everything in also pulls in tons of stuff that you aren't using, because recursively vendoring dependencies means you are also pulling in dev-dependencies, optional dependencies (including default-off features), and so on.

                                                                                                                                      For the things you do use, is it the number of crates that is the problem, or the amount of code? Because if the alternative is to develop it in-house, then...

                                                                                                                                      The alternative here is to include a lot of things in the standard library that doesn't belong there, because people seem to exclude standard libraries from their auditing, which is reasonable. Why is it not just as reasonable to exclude certain widespread ecosystem crates from auditing?

                                                                                                                                      • cmrdporcupine 9 months ago
                                                                                                                                        > One thing is to decide to vendor everything - that's your prerogative - but it's very likely that pulling everything in also pulls in tons of stuff that you aren't using, because recursively vendoring dependencies means you are also pulling in dev-dependencies, optional dependencies (including default-off features), and so on.

                                                                                                                                        What you're describing is a problem with how Cargo does vendoring, and yes, it's awful. It should not be called vendoring, it is just "local mirroring", which is not the same thing.

                                                                                                                                        But Rust can work just fine without Cargo or Crates.io.

                                                                                                                                      • joatmon-snoo 9 months ago
                                                                                                                                        This is what lockfiles are for.
                                                                                                                                      • dathinab 9 months ago
                                                                                                                                        > It turns out, the deps add up to almost 4 million lines of Rust code, spread across 8000+ files

                                                                                                                                        (Putting aside the question weather or not that pulls in dev dependencies and that watchin files can easily have OS specific aspecects so you might have different dependencies on different OSes and that neither lines and even less files are a good measurement of complexity and that this dependencies involve a lot of code from features of dependencies which aren't used and due to rust being complied in a reasonable way are reliable not included in the final binary in most cases. Also ignoring that cargo-watch isn't implementing file watching itself it's in many aspects a wrapper around watchexec which makes it much "thiner" then it would be otherwise.)

                                                                                                                                        What if that is needed for a reliable robust ecosystem?

                                                                                                                                        I mean, I know, it sound absurd but give it some thought.

                                                                                                                                        I wouldn't want every library to reinvent the wheel again and again for all kinds of things, so I would want them to use dependencies, I also would want them to use robust, tested, mature and maintained dependencies. Naturally this applies transitively. But what libraries become "robust, tested, mature and maintained" such which just provide a small for you good enough subset of a functionality or such which support the full functionality making it usable for a wider range of use-case?

                                                                                                                                        And with that in mind let's look at cargo-watch.

                                                                                                                                        First it's a CLI tool, so with the points above in mind you would need a good choice of a CLI parser, so you use e.g. clap. But at this point you already are pulling in a _huge_ number of lines of code from which the majority will be dead code eliminated. Through you don't have much choice, you don't want to reinvent the wheel and for a CLI libary to be widely successful (often needed it to be long term tested, maintained and e.g. forked if the maintainers disappear etc.) it needs to cover all widely needed CLI libary features, not just the subset you use.

                                                                                                                                        Then you need to handle configs, so you include dotenvy. You have a desktop notification sending feature again not reason to reinvent that so you pull in rust-notify. Handling path in a cross platform manner has tricky edge cases so camino and shell-escape get pulled in. You do log warnings so log+stderrlog get pulled in, which for message coloring and similar pull in atty and termcolor even through they probably just need a small subset of atty. But again no reason to reinvent the wheel especially for things so iffy/bug prone as reliably tty handling across many different ttys. Lastly watching files is harder then it seems and the notify library already implements it so we use that, wait it's quite low level and there is watchexec which provides exactly the interface we need so we use that (and if we would not we still would use most or all of watchexecs dependencies).

                                                                                                                                        And ignoring watchexec (around which the discussion would become more complex) with the standards above you wouldn't want to reimplement the functionality of any of this libraries yourself it's not even about implementation effort but stuff like overlooking edge cases, maintainability etc.

                                                                                                                                        And while you definitely can make a point that in some aspects you can and maybe should reduce some dependnecies etc. this isn't IMHO changing the general conclusion: You need most of this dependencies if you want to conform with standards pointed out above.

                                                                                                                                        And tbh. I have seen way way way to many cases of projects shaving of dependencies, adding "more compact wheel reinventions" for their subset and then ran into all kinds of bugs half a year later. Sometimes leading to the partial reimplementations becoming bigger and bigger until they weren't much smaller then the original project.

                                                                                                                                        Don't get me wrong there definitely are cases of (things you use from) dependencies being too small to make it worth it (e.g. left pad) or more common it takes more time (short term) to find a good library and review it then to reimplement it yourself (but long term it's quite often a bad idea).

                                                                                                                                        So idk. the issue is transitive dependencies or too many dependencies like at all.

                                                                                                                                        BUT I think there are issues wrt. handling software supply chain aspects. But that is a different kind of problem with different solutions. And sure not having dependencies avoid that problem, somewhat, but it's just replacing it IMHO with a different as bad problem.

                                                                                                                                        • wiseowise 9 months ago
                                                                                                                                          What do you propose? To include it as part of std? Are you insane? That would bloat your binaries! (Still don’t understand how the smart compiler isn’t smart enough to remove dead code) And imagine if there’s an update that makes cargo-watch not BlAzInGlY fAsT™ but uLtRa BlAzInGlY fAsT™? /s
                                                                                                                                        • TechDebtDevin 9 months ago
                                                                                                                                          You fuck around...
                                                                                                                                        • bjackman 9 months ago
                                                                                                                                          Rust isn't an Exciting New Language any more. It's in the "work towards widespread adoption" phase. Slower feature development is natural and healthy, the stakes are high, mistaken design choices are much more harmful than low velocity at this point.

                                                                                                                                          I'm not excited about Rust because of cool features, I'm excited because it's a whole new CLASS of language (memory safe, no GC, production ready). Actually getting it into the places that matter is way more interesting to me than making it a better language. That's easier to achieve if people are comfortable that the project is being steered with a degree of caution.

                                                                                                                                          • josephg 9 months ago
                                                                                                                                            Maybe. But javascript is arguably in that phase of its life as well, and JS has had a oodles of wonderful new features added in the last decade. Features like the spread operator, generator functions, async, arrow functions, leftpad, a new Date, and so on. The list of significant new features is endless.

                                                                                                                                            All that, despite JS being much older than rust, and much more widely used. Javascript also has several production implementations - which presumably all need to agree to implement any new features.

                                                                                                                                            Javascript had a period of stagnation around ES5. The difference seems to be that the ecmascript standards committee got their act together.

                                                                                                                                            • tinco 9 months ago
                                                                                                                                              They got their act together because there was a language built on top of Javascript that fixed all its problems, and it was quickly gaining wide adoption. If they hadn't done anything, we'd probably still be transpiling CoffeeScript.

                                                                                                                                              History repeated itself, and now Typescript has even more popularity than CoffeeScript ever did, so if the ecma committee is still on their act, they're probably working on figuring out how to adopt types into Javascript as well.

                                                                                                                                              More relevant to this argument, is the question if a similar endeavor would work for Rust. Are the features you're describing so life changing that people would work in a transpiled language that had them? For CoffeeScript, from my perspective at least, it was just the arrow functions. All the sugar on top just sealed the deal.

                                                                                                                                              • gary17the 9 months ago
                                                                                                                                                Javascript has a quite different use-case audience than Rust. As an example, try to convince a guy like Linus Torvalds to officially support a particular PL for Linux kernel development, when his absolute priority (quite rightly so) is predicable, performant and portable code generation on the same level as raw C, with ease-of-use of a PL not being even a distant second, if considered at all. JavaScript does not really have to live up to those kinds of challenges.

                                                                                                                                                The assumption that "[Rust] stagnation" is due to some kind of "Rust committee inefficiencies" might be incorrect.

                                                                                                                                                • josephg 9 months ago
                                                                                                                                                  Author here.

                                                                                                                                                  > Javascript has a quite different use-case audience than Rust.

                                                                                                                                                  Eh. That sounds like a "just so" explanation to me. Linus Torvalds doesn't work on the rust compiler.

                                                                                                                                                  I think I could make much more convincing arguments that javascript should move slower than rust - given there's so many large language runtime projects. (V8, Safari, Javascript, Node, Deno, Bun, etc etc). But evidently, that isn't the case.

                                                                                                                                                  I'm open to the reason for rust's slow development being that the language developers want the language to move slowly. Thats fine. But, I personally don't want that. I've been waiting for generators to ship for 7 years. Or TAIT to appear - again, for years. I'd much rather rust to move faster.

                                                                                                                                                  Of course I attribute all of this to the process & team which makes these decisions. What else is there? What else has any affect on the development of rust?

                                                                                                                                              • johnisgood 9 months ago
                                                                                                                                                Is it really a new class of language considering we had Ada / SPARK for ages? It takes safety further, too, with formal verification.
                                                                                                                                                • thesuperbigfrog 9 months ago
                                                                                                                                                  >> Is it really a new class of language considering we had Ada / SPARK for ages? It takes safety further, too, with formal verification.

                                                                                                                                                  Rust and Ada have similar goals and target use cases, but different advantages and strengths.

                                                                                                                                                  In my opinion, Rust's biggest innovations are 1) borrow checking and "mutation XOR sharing" built into the language, effectively removing the need for manual memory management or garbage collection, 2) Async/Await in a low-level systems language, and 3) Superb tooling via cargo, clippy, built-in unit tests, and the crates ecosystem (in a systems programming language!) Rust may not have been the first with these features, but it did make them popular together in a way that works amazingly well. It is a new class of language due to the use of the borrow checker to avoid memory safety problems.

                                                                                                                                                  Ada's strengths are its 1) powerful type system (custom integer types, use of any enumerated type as an index, etc.), 2) perfect fit for embedded programming with representation clauses, the real-time systems annex, and the high integrity systems annex, 3) built-in Design-by-Contract preconditions, postconditions, and invariants, and 4) Tasking built into the language / run-time. Compared to Rust, Ada feels a bit clunky and the tooling varies greatly from one Ada implementation to another. However, for some work, Ada is the only choice because Rust does not have sufficently qualified toolchains yet. (Hopefully soon . . .)

                                                                                                                                                  Both languages have great foreign function interfaces and are relatively easy to use with C compared to some other programming languages. Having done a fair bit of C programming in the past, today I would always choose Rust over C or C++ when given the choice.

                                                                                                                                                  • sacado2 9 months ago
                                                                                                                                                    It also has range types, avoiding a whole class of bugs.
                                                                                                                                                  • M4Luc 9 months ago
                                                                                                                                                    [dead]
                                                                                                                                                  • knighthack 9 months ago
                                                                                                                                                    Since Rustaceans are so neurotic about rewriting everything in Rust, I genuinely thought that an article about rewriting Rust (in Rust) had to be a meta-satirical joke.
                                                                                                                                                    • zokier 9 months ago
                                                                                                                                                      That happened already way back in the prehistory :)

                                                                                                                                                      Originally Rust was written in OCaml, but eventually it got rewritten in Rust

                                                                                                                                                      • josephg 9 months ago
                                                                                                                                                        Author here. That was the reference I was going for with the title :D
                                                                                                                                                        • nineteen999 9 months ago
                                                                                                                                                          They want you (us?) to rewrite everything in Rust. Not them.
                                                                                                                                                          • simonask 9 months ago
                                                                                                                                                            Who is "they"? Seriously, who?
                                                                                                                                                            • Joeboy 9 months ago
                                                                                                                                                              Well, if you work on security-critical software that's currently written in a memory-unsafe language, I would say that's a good candidate for a Rust rewrite. Likewise if you work on a widely used library that's awkwardly slow because it's written in python.

                                                                                                                                                              Which is not exactly the same as wanting everybody to rewrite everything in Rust, but I suppose it's the sort of thing that annoys nineteen999.

                                                                                                                                                              There are also a lot of devs rewriting things in Rust for their own entertainment or whatever, which I think is the main source of the "rewrite everything in Rust" meme.

                                                                                                                                                              • SenorKimchi 9 months ago
                                                                                                                                                                The Rust Evangelism Strike Force
                                                                                                                                                                • nineteen999 9 months ago
                                                                                                                                                                  The parent comment referred to "Rustaceans". Check the first two words.
                                                                                                                                                              • lopatin 9 months ago
                                                                                                                                                                PL people also like bootstrapping languages. Writing Rust in Rust might not be that far fetched?
                                                                                                                                                            • dathinab 9 months ago
                                                                                                                                                              It's kinda strange how he complains first about a slow decision making process and then lists features which are not stabilized for reasons fully unrelated to the decision making.

                                                                                                                                                              E.g. corutines are stuck because they have some quite hard to correctly resolve corner cases, i.e. in the compiler there isn't a full implementation you could "just turn on" but a incomplete implementation which works okay for many cases but you really can't turn on on stable. (At least this was the case last time I checked.) Similar function traits have been explicitly decided to not be stabilized like that for various technical reasons but also due to them changing if you involve future features. (Like async corotines.) Sure the part about return values not being associated types is mostly for backward compatibility but it's also in nearly all situations just a small ergonomics drawback.

                                                                                                                                                              And sure there are some backward compatibility related designs which people have loved to do differently if they had more time and resources at the point the decision was made. But also most of them are related to the very early rust times when the team still was much smaller and there where less resources for evaluating important decisions.

                                                                                                                                                              And sure having a break which changes a bunch of older decisions now that different choices can be made and people are more experienced would be nice. BUT after how catastrophic bad python2->python3 went and similar experiences in other languages many people agree that having some rough corners is probably better and making a rust 2.0. (And many of this things can't be done through rust editions!)

                                                                                                                                                              In general if you follow the rust weekly newletter you can see that decisions for RFC acceptance, including for stabilization are handled every week.

                                                                                                                                                              And sure sometimes (quite too often) things take too long, but people/coordination/limited-time problems are often harder to solve then technical problem.

                                                                                                                                                              And sure some old features are stuck (corotines) and some but also many "feature gates" aren't "implemented stuck features" (but e.g. things which aren't meant to be ever stabilized, abandoned features, some features have multiple different feature gates etc.)

                                                                                                                                                              • mplanchard 9 months ago
                                                                                                                                                                Shouldn’t read this without also reading Josh Triplett’s comment in response on reddit. One of the core examples in this post is just plain wrong (mutexes), for example: https://old.reddit.com/r/rust/comments/1fpomvp/rewriting_rus...

                                                                                                                                                                Edit: nevermind, comment is here too: https://news.ycombinator.com/item?id=41655268

                                                                                                                                                                • gyre007 9 months ago
                                                                                                                                                                  One of the things that hit me when I was picking up Rust was that I felt like it had every imaginable feature one could think of - I dont know if Rust team said no to anything (yes I know they obviously must’ve done) - and yet people wanted more and more (some justifiably, others less so) as the language “felt” incomplete or that the features thatd be used by 2% of devs are totally necessary in the language that is “understood” by 1% of developer populace. I’m not saying the author is wrong here, just pointing out how a complex language somehow needs to be even more complicated. Spoiler: it doesn’t. Zig is simpler, arguably faster, with much less drama in the community. I wish more funding went to Zig.
                                                                                                                                                                  • SkiFire13 9 months ago
                                                                                                                                                                    You'll be surprised by the amount of features that are often proposed by random people and are then rejected by the Rust community. Rust is definitely not trying to add all possible features, though you might get that feeling when you look at some feature like GATs and TAITs without having a clear idea of what problems they solve.

                                                                                                                                                                    Also, Zig might be a nice modern language, but it is not an option if you're aiming for memory safety.

                                                                                                                                                                    • pa7ch 9 months ago
                                                                                                                                                                      I think any replacement for c/c++ will not be strictly safe from memory safety vulnerabilities, but I think both Rust and Zig go far enough to effectively nearly eliminate that entire class of vulns in production software. Rust achieves further memory safety than most with its borrow checker but in many cases that seems to be more about safety from crashing than vulns. For example, Go is not memory safe under concurrency, but there have been no memory safety vulns related to its concurrency ever.

                                                                                                                                                                      One could also argue Rust's unsafe blocks will be harder to reason about bugs in than Zig code. And if you don't need any unsafe blocks it might not be an application best suited to Zig or Rust.

                                                                                                                                                                      • pas 9 months ago
                                                                                                                                                                        GAT solves typing problems (by making a subset of HKT possible)
                                                                                                                                                                      • josephg 9 months ago
                                                                                                                                                                        Author here.

                                                                                                                                                                        > I’m not saying the author is wrong here, just pointing out how a complex language somehow needs to be even more complicated. Spoiler: it doesn’t.

                                                                                                                                                                        True. But I think a lot of rust's complexity budget is spent in the wrong places. For example, the way Pin & futures interact adds a crazy amount of complexity to the language. And I think at least some of that complexity is unnecessary. As an example, I'd like a rust-like language which doesn't have Pin at all.

                                                                                                                                                                        I suspect there's also ways the borrow checker could be simplified, in both syntax and implementation. But I haven't thought enough about it to have anything concrete.

                                                                                                                                                                        I don't think there's much we can do about any of that now short of forking the language. But I can certainly dream.

                                                                                                                                                                        Rust won't be the last language invented which uses a borrow checker. I look forward to the next generation of these ideas. I think there's probably a lot of ways to improve things without making a bigger language.

                                                                                                                                                                        • bn-l 9 months ago
                                                                                                                                                                          > I wish more funding went to Zig.

                                                                                                                                                                          Unfortunately that attracts the worst types. And their crapness and damage potential is sometimes not realised until it’s way too late.

                                                                                                                                                                          • simonask 9 months ago
                                                                                                                                                                            I'm curious, what drama in the Rust community are you referring to?

                                                                                                                                                                            I see some drama associated with Rust, but it's usually around people resisting its usage or adoption (the recent kerfuffle about Rust for Linux, for example), and not really that common within the community. But I could be missing something?

                                                                                                                                                                            Zig is great, but it just isn't production ready.

                                                                                                                                                                          • throwup238 9 months ago
                                                                                                                                                                            The graveyard of features in nightly is actually pretty big. Important stuff like specialization is forever stuck there.
                                                                                                                                                                            • SkiFire13 9 months ago
                                                                                                                                                                              AFAIK many of those language features (specialization included) are blocked by the rewrite of the trait solver.
                                                                                                                                                                              • TwentyPosts 9 months ago
                                                                                                                                                                                Afaik specialisation (in full generality) would cause soundness issues, so it's not even just blocked by the trait solver, it's also blocked by figuring out a 'slimmed down' proposal that fixes those.

                                                                                                                                                                                And that's not even getting into the problem that it's a fairly controversial feature, since people are worried about terrible, hard to track specialisation trees. (See, inheritance.)

                                                                                                                                                                                • Maken 9 months ago
                                                                                                                                                                                  I think there is a bigger issue with specialization, and it's that nobody seems to agree in what the semantics should be. The orphan rules are clearly artificially limiting, but there is no formal description of a new set of rules to replace them, only proposals.
                                                                                                                                                                                • Ygg2 9 months ago
                                                                                                                                                                                  While there are trucks of nightly only features, some are stuck there for a good reason.

                                                                                                                                                                                  Specializations allow unsound behavior in safe Rust, which is exactly what nightly was supposed to catch.

                                                                                                                                                                                • nemothekid 9 months ago
                                                                                                                                                                                  >with much less drama in the community

                                                                                                                                                                                  There are only two kinds of languages: the ones people complain about and the ones nobody uses.

                                                                                                                                                                                  Much of Rust's (and almost every other large programming language) drama are problems of scale, not implementation. The more funding you wish for will indubitably create more drama.

                                                                                                                                                                                  • lifthrasiir 9 months ago
                                                                                                                                                                                    Zig is already far more complex than what was originally presented anyway, while Rust 1.0 and the current Rust are mostly identical. (Pre-1.0 versions of Rust were heavily changing and overwent at least two or three extreme changes that make them essentially different languages with the same name.) Zig should be funded more for other reasons, but I don't think Zig would be safe from this eventual complexity problem.
                                                                                                                                                                                    • OtomotO 9 months ago
                                                                                                                                                                                      I wish Zig had a borrow checker... then we could see how much better it would fare.

                                                                                                                                                                                      (This is not a diss on Zig at all, I love its approach!)

                                                                                                                                                                                      • rapnie 9 months ago
                                                                                                                                                                                        > I felt like it had every imaginable feature one could think of - I dont know if Rust team said no to anything

                                                                                                                                                                                        Ah, like Scala you mean?

                                                                                                                                                                                      • JoshTriplett 9 months ago
                                                                                                                                                                                        > Now, there are issue threads like this, in which 25 smart, well meaning people spent 2 years and over 200 comments trying to figure out how to improve Mutex. And as far as I can tell, in the end they more or less gave up.

                                                                                                                                                                                        The author of the linked comment did extensive analysis on the synchronization primitives in various languages, then rewrote Rust's synchronization primitives like Mutex and RwLock on every major OS to use the underlying operating system primitives directly (like futex on Linux), making them faster and smaller and all-around better, and in the process, literally wrote a book on parallel programming in Rust (which is useful for non-Rust parallel programming as well): https://www.oreilly.com/library/view/rust-atomics-and/978109...

                                                                                                                                                                                        > Features like Coroutines. This RFC is 7 years old now.

                                                                                                                                                                                        We haven't been idling around for 7 years (either on that feature or in general). We've added asynchronous functions (which whole ecosystems and frameworks have arisen around), traits that can include asynchronous functions (which required extensive work), and many other features that are both useful in their own right and needed to get to more complex things like generators. Some of these features are also critical for being able to standardize things like `AsyncWrite` and `AsyncRead`. And we now have an implementation of generators available in nightly.

                                                                                                                                                                                        (There's some debate about whether we want the complexity of fully general coroutines, or if we want to stop at generators.)

                                                                                                                                                                                        Some features have progressed slower than others; for instance, we still have a lot of discussion ongoing for how to design the AsyncIterator trait (sometimes also referred to as Stream). There have absolutely been features that stalled out. But there's a lot of active work going on.

                                                                                                                                                                                        I always find it amusing to see, simultaneously, people complaining that the language isn't moving fast enough and other people complaining that the language is moving too fast.

                                                                                                                                                                                        > Function traits (effects)

                                                                                                                                                                                        We had a huge design exploration of these quite recently, right before RustConf this year. There's a challenging balance here between usability (fully general effect systems are complicated) and power (not having to write multiple different versions of functions for combinations of async/try/etc). We're enthusiastic about shipping a solution in this area, though. I don't know if we'll end up shipping an extensible effect system, but I think we're very likely to ship a system that allows you to write e.g. one function accepting a closure that works for every combination of async, try, and possibly const.

                                                                                                                                                                                        > Compile-time Capabilities

                                                                                                                                                                                        Sandboxing against malicious crates is an out-of-scope problem. You can't do this at the language level; you need some combination of a verifier and runtime sandbox. WebAssembly components are a much more likely solution here. But there's lots of interest in having capabilities for other reasons, for things like "what allocator should I use" or "what async runtime should I use" or "can I assume the platform is 64-bit" or similar. And we do want sandboxing of things like proc macros, not because of malice but to allow accurate caching that knows everything the proc macro depends on - with a sandbox, you know (for instance) exactly what files the proc macro read, so you can avoid re-running it if those files haven't changed.

                                                                                                                                                                                        > Rust doesn't have syntax to mark a struct field as being in a borrowed state. And we can't express the lifetime of y.

                                                                                                                                                                                        > Lets just extend the borrow checker and fix that!

                                                                                                                                                                                        > I don't know what the ideal syntax would be, but I'm sure we can come up with something.

                                                                                                                                                                                        This has never been a problem of syntax. It's a remarkably hard problem to make the borrow checker able to handle self-referential structures. We've had a couple of iterations of the borrow checker, each of which made it capable of understanding more and more things. At this point, I think the experts in this area have ideas of how to make the borrow checker understand self-referential structures, but it's still going to take a substantial amount of effort.

                                                                                                                                                                                        > This syntax could also be adapted to support partial borrows

                                                                                                                                                                                        We've known how to do partial borrows for quite a while, and we already support partial borrows in closure captures. The main blocker for supporting partial borrows in public APIs has been how to expose that to the type system in a forwards-compatible way that supports maintaining stable semantic versioning:

                                                                                                                                                                                        If you have a struct with private fields, how can you say "this method and that method can borrow from the struct at the same time" without exposing details that might break if you add a new private field?

                                                                                                                                                                                        Right now, leading candidates include some idea of named "borrow groups", so that you can define your own subsets of your struct without exposing what private fields those correspond to, and so that you can change the fields as long as you don't change which combinations of methods can hold borrows at the same time.

                                                                                                                                                                                        > Comptime

                                                                                                                                                                                        We're actively working on this in many different ways. It's not trivial, but there are many things we can and will do better here.

                                                                                                                                                                                        I recently wrote two RFCs in this area, to make macro_rules more powerful so you don't need proc macros as often.

                                                                                                                                                                                        And we're already talking about how to go even further and do more programmatic parsing using something closer to Rust constant evaluation. That's a very hard problem, though, particularly if you want the same flexibility of macro_rules that lets you write a macro and use it in the same crate. (Proc macros, by contrast, require you to write a separate crate, for a variety of reasons.)

                                                                                                                                                                                        > impl<T: Copy> for Range<T>.

                                                                                                                                                                                        This is already in progress. This is tied to a backwards-incompatible change to the range types, so it can only occur over an edition. (It would be possible to do it without that, but having Range implement both Iterator and Copy leads to some easy programming mistakes.)

                                                                                                                                                                                        > Make if-let expressions support logical AND

                                                                                                                                                                                        We have an unstable feature for this already, and we're close to stabilizing it. We need to settle which one or both of two related features we want to ship, but otherwise, this is ready to go.

                                                                                                                                                                                            > But if I have a pointer, rust insists that I write (*myptr).x or, worse: (*(*myptr).p).y.
                                                                                                                                                                                        
                                                                                                                                                                                        We've had multiple syntax proposals to improve this, including a postfix dereference operator and an operator to navigate from "pointer to struct" to "pointer to field of that struct". We don't currently have someone championing one of those proposals, but many of us are fairly enthusiastic about seeing one of them happen.

                                                                                                                                                                                        That said, there's also a danger of spending too much language weirdness budget here to buy more ergonomics, versus having people continue using the less ergonomic but more straightforward raw-pointer syntaxes we currently have. It's an open question whether adding more language surface area here would on balance be a win or a loss.

                                                                                                                                                                                        > Unfortunately, most of these changes would be incompatible with existing rust.

                                                                                                                                                                                        One of the wonderful things about Rust editions is that there's very little we can't change, if we have a sufficiently compelling design that people will want to adopt over an edition.

                                                                                                                                                                                        > The rust "unstable book" lists 700 different unstable features - which presumably are all implemented, but which have yet to be enabled in stable rust.

                                                                                                                                                                                        This is absolutely an issue; one of the big open projects we need to work on is going through all the existing unstable features and removing many that aren't likely to ever reach stabilization (typically either because nobody is working on them anymore or because they've been superseded).

                                                                                                                                                                                        • xgb84j 9 months ago
                                                                                                                                                                                          What you describe is how development of basic packages that are part or on the level of the standard library should be done. The languages we are currently using will still be used decades from now. Slow good decisions now save much more time later on.
                                                                                                                                                                                          • agersant 9 months ago
                                                                                                                                                                                            Thanks for taking the time to write this reply. Happy to hear a lot of this is in motion!
                                                                                                                                                                                            • epage 9 months ago
                                                                                                                                                                                              > Sandboxing against malicious crates is an out-of-scope problem. You can't do this at the language level; you need some combination of a verifier and runtime sandbox. WebAssembly components are a much more likely solution here. But there's lots of interest in having capabilities for other reasons, for things like "what allocator should I use" or "what async runtime should I use" or "can I assume the platform is 64-bit" or similar. And we do want sandboxing of things like proc macros, not because of malice but to allow accurate caching that knows everything the proc macro depends on - with a sandbox, you know (for instance) exactly what files the proc macro read, so you can avoid re-running it if those files haven't changed.

                                                                                                                                                                                              We've had a lot of talk about sandboxing of proc-macros and build scripts. Of course, more declarative macros, delegating `-sys` crate logic to a shared library, and `cfg(version)` / `cfg(accessible)` will remove a lot of the need for user versions of these. However, that all ignores runtime. The more I think about it, the more cackle's "ACLs" [0] seem like the way to go as a way for extensible tracking of operations and auditing their use in your dependency tree, whether through a proc-macro, a build script, or runtime code.

                                                                                                                                                                                              I heard that `cargo-redpen` is developing into a tool to audit calls though I'm imagining something higher level like cackle.

                                                                                                                                                                                              [0]: https://github.com/cackle-rs/cackle

                                                                                                                                                                                              • josephg 9 months ago
                                                                                                                                                                                                Author here. Thanks for the in depth response. I appreciate hearing an insider's perspective.

                                                                                                                                                                                                > I always find it amusing to see, simultaneously, people complaining that the language isn't moving fast enough and other people complaining that the language is moving too fast.

                                                                                                                                                                                                I think people complain that rust is a big language, and they don't want it to be bigger. But keeping the current half-baked async implementation doesn't make the language smaller or simpler. It just makes the language worse.

                                                                                                                                                                                                > The main blocker for supporting partial borrows in public APIs has been how to expose that to the type system in a forwards-compatible way that supports maintaining stable semantic versioning

                                                                                                                                                                                                I'd love it if this feature shipped, even if it only works (for now) within a single crate. I've never had this be a problem in my crate's public API. But it comes up constantly while programming.

                                                                                                                                                                                                > Sandboxing against malicious crates is an out-of-scope problem. You can't do this at the language level; you need some combination of a verifier and runtime sandbox.

                                                                                                                                                                                                Why not?

                                                                                                                                                                                                If I call a function that contains no unsafe 3rd party code in its call tree, and which doesn't issue any syscalls, that function can already only access & interact with passed parameters, local variables and locally in-scope globals. Am I missing something? Because that already looks like a sandbox, of sorts, to me.

                                                                                                                                                                                                Is there any reason we couldn't harden the walls of that sandbox and make it usable as a security boundary? Most crates in my dependency tree are small, and made entirely of safe code. And the functions in those libraries I call don't issue any syscalls already anyway. Seems to me like adding some compile-time checks to enforce that going forward would be easy. And it would dramatically reduce the supply chain security risk.

                                                                                                                                                                                                Mind explaining your disagreement a little more? It seems like a clear win to me.

                                                                                                                                                                                                • dgroshev 9 months ago
                                                                                                                                                                                                  > But keeping the current half-baked async implementation doesn't make the language smaller or simpler. It just makes the language worse.

                                                                                                                                                                                                  I can't disagree more.

                                                                                                                                                                                                  In fact, I think that the current state of async Rust is the best implementation of async in any language.

                                                                                                                                                                                                  To get Pin stuff out of the way: it is indeed more complicated than it could be (because reverse compatibility etc), but when was the last time you needed to write a poll implementation manually? Between runtime (tokio/embassy) and utility crates, there is very little need to write raw futures. Combinators, task, and channels are more than enough for the overwhelming majority of problems, and even in their current state they give us more power than Python or JS ecosystems.

                                                                                                                                                                                                  But then there's everything else.

                                                                                                                                                                                                  Async Rust is correct and well-defined. The way cancellation, concurrent awaiting, and exceptions work in languages like JS and Python is incredibly messy (eg [1]) and there are very few people who even think about that. Rust in its typical fashion frontloads this complexity, which leads to more people thinking and talking about it, but that's a good thing.

                                                                                                                                                                                                  Async Rust is clearly separated from sync Rust (probably an extension of the previous point). This is good because it lets us reason about IO and write code that won't be preempted in an observable way, unlike with Go or Erlang. For example, having a sync function we can stuff things into thread locals and be sure that they won't leak into another future.

                                                                                                                                                                                                  Async Rust has already enabled incredibly performant systems. Cloudflare's Pingora runs on Tokio, processing a large fraction of internet traffic while being much safer and better defined than nginx-style async. Same abstractions work in Datadog's glommio, a completely different runtime architecture.

                                                                                                                                                                                                  Async Rust made Embassy possible, a genuine breakthrough in embedded programming. Zero overhead, safe, predictable async on microcontrollers is something that was almost impossible before and was solved with much heavier and more complex RTOSes.

                                                                                                                                                                                                  "Async Rust bad" feels like a meme at this point, a meme with not much behind it. Async Rust is already incredibly powerful and well-designed.

                                                                                                                                                                                                  [1]: https://neopythonic.blogspot.com/2022/10/reasoning-about-asy...

                                                                                                                                                                                                  • josephg 9 months ago
                                                                                                                                                                                                    > In fact, I think that the current state of async Rust is the best implementation of async in any language.

                                                                                                                                                                                                    Hahahaha hard disagree. Last year I implemented the braid protocol (a custom streaming protocol using HTTP) in javascript in less than an hour and about 30 lines of code. Then I spent 2 weeks trying to do the same thing in rust - writing hundreds of lines of code in the process and I couldn't get it to work. Eventually I gave up.

                                                                                                                                                                                                    I got it working recently - but only by borrowing some wild tricks from reading the source code of tokio, that I never would have thought of on my own.

                                                                                                                                                                                                    > To get Pin stuff out of the way: it is indeed more complicated than it could be (because reverse compatibility etc), but when was the last time you needed to write a poll implementation manually?

                                                                                                                                                                                                    Last week, while writing a simple networked database application. Again I needed to produce an async stream, and thats impossible using async fn.

                                                                                                                                                                                                  • lifthrasiir 9 months ago
                                                                                                                                                                                                    > Why not?

                                                                                                                                                                                                    I believe you are proposing a language-based security (langsec), which seemed very promising at first but the current consensus is that it still has to be accompanied with other measures. One big reason is that virtually no practical language implementation is fully specified.

                                                                                                                                                                                                    As an example, let's say that we only have fixed-size integer variables and simple functions with no other control constructs. Integers wrap around and division by zero yields zero, so no integer operation can trap. So it should be easy to check for the infinite recursion and declare that the program would never trap otherwise, right? No! A large enough number of nested but otherwise distinct function calls would eventually overflow the stack and cause a trap or anything else. But this notion of "stack" is highly specific to the implementation, so the provable safety essentially implies that you have formalized all such implementation-specific notions in advance. Possible but extremely difficult in practice.

                                                                                                                                                                                                    The "verifier and runtime sandbox" mentioned here is one solution to get around this difficulty. Instead of being able to understand the full language, the verifier is only able to understand a very reduced subset and the compiler is expected (but not guaranteed) to return something that would pass the verifier. A complex enough verifier would be able to guarantee that it is safe to execute even without a sandbox, but a verifier combined with a runtime sandbox is much simpler and more practical.

                                                                                                                                                                                                    • josephg 9 months ago
                                                                                                                                                                                                      > As an example, let's say that we only have fixed-size integer variables and simple functions with no other control constructs. Integers wrap around and division by zero yields zero, so no integer operation can trap. So it should be easy to check for the infinite recursion and declare that the program would never trap otherwise, right? No! A large enough number of nested but otherwise distinct function calls would eventually overflow the stack and cause a trap or anything else.

                                                                                                                                                                                                      So? Panics or traps from stack overflows don't allow 3rd party code to write to arbitrary files on my filesystem. Nor does integer overflow.

                                                                                                                                                                                                      Maybe there's some clever layered attack which could pull off something like that. But, fine! Right now the state is "anyone in any crate can trivially do anything to my computer". Limiting the granted permission to only allowing panics, infinite loops, integer overflows and stack overflows sounds like a big win to me!

                                                                                                                                                                                                      If people do figure out ways to turn a stack overflow in safe rust into RCE, well, that was already a soundness hole in the language. Lets fix it.

                                                                                                                                                                                                    • skavi 9 months ago
                                                                                                                                                                                                      You really should update your post wrt the Mutex changes.
                                                                                                                                                                                                      • mwcampbell 9 months ago
                                                                                                                                                                                                        Agreed. The statement that "they more or less gave up" is simply wrong. In addition to what JoshTriplett said, they landed const initialization of Mutex, RwLock, and Condvar in 1.63. That sounds like a complete success to me.
                                                                                                                                                                                                  • iTokio 9 months ago
                                                                                                                                                                                                    Rust mission was already a difficult mix between performance, safety and expressiveness, then the project lost its “founder mode” when Mozilla disengaged, and the original core team mostly left, so no wonder progress slowed down. I personally think that’s it’s better than going down the wrong path.
                                                                                                                                                                                                    • louismerlin 9 months ago
                                                                                                                                                                                                      If I were to rewrite Rust, I'd probably go the route of less features, not more.

                                                                                                                                                                                                      Make it 70% of Rust in 10% of the code, similarly to what QBE[0] is doing with LLVM.

                                                                                                                                                                                                      You'd probably be able to achieve that if you remove macros and some of the rarely-used features.

                                                                                                                                                                                                      [0]: https://c9x.me/compile/

                                                                                                                                                                                                      • lifthrasiir 9 months ago
                                                                                                                                                                                                        Not to downplay QBE, but the initial goal of QBE was to provide 90% of the performance in 10% of the code, until it was changed to 70%. You generally don't know how much of Rust (or anything else) is possible without actually trying.
                                                                                                                                                                                                        • chkhd 9 months ago
                                                                                                                                                                                                          I wonder how soon they will arrive at 80%/20%.
                                                                                                                                                                                                      • epage 9 months ago
                                                                                                                                                                                                        RE: Rust's pacing

                                                                                                                                                                                                        I've had a lot of talks with my management about that. For context, I'm on the Cargo team and have authored 11 RFCs (10 approved, 1 pending).

                                                                                                                                                                                                        I feel like a lot of the pacing feels slow because:

                                                                                                                                                                                                        - As the project matures, polishing whats there takes up a lot of effort

                                                                                                                                                                                                        - Conversely, hitting local maximas where things are "just good enough" that individuals and companies don't feel the need to put effort to doing the last leg of work.

                                                                                                                                                                                                        - Lack of coordinated teams (formerly Mozilla) doubling down on an idea to hash it out. Hopefully [Project Goals](https://rust-lang.github.io/rfcs/3614-project-goals.html) will help a little in this direction.

                                                                                                                                                                                                        - As the project has grown, we've specialized a lot more, making it harder to develop a cross-team feature. It takes finesse to recruit someone from another team to help you finish out a cross-team feature. It also doesn't help we've not done a good job developing the cross-team communication channels to make up for this specialization. Again, Project Goals are trying to improve this. In-person conferences starting back up has also been a big help.

                                                                                                                                                                                                        As for RFCs, we've been moving in the direction of choosing the level of process thats appropriate for a decision. Unsure how something will look? You just need approval from 2 members of the relevant team to start a nightly only experiment to flesh out the idea in preparation for an RFC. In Cargo, many decisions don't need wide input and are just team votes on an Issue. RFCs drag out when their isn't a someone from the team shepherding it through the process, the RFC covers too much and needs to be shrunk to better focus the conversation, too much is unknown and instead an experiment is needed, or its cross-team and you need to know how to navigate the process to get the vote done (we want to improve this). As for things being approved but not completed, thats a "we need more help" problem usually.

                                                                                                                                                                                                        • pdimitar 9 months ago
                                                                                                                                                                                                          > As for things being approved but not completed, thats a "we need more help" problem usually.

                                                                                                                                                                                                          You know, I would LOVE working on Rust (not just with Rust) and be a part of some of the core team(s).

                                                                                                                                                                                                          But my impression is that nobody truly has any powerful agency over things and even if you formulate a near-perfect and a PR to go with it, things would still end with several smarter people than me saying "Oh this looks really neat, we should ponder it more and test it further and merge it!" and then it never happens.

                                                                                                                                                                                                          That, plus I am not sure how is the job stability situation there.

                                                                                                                                                                                                        • jfyasdfwasdf 9 months ago
                                                                                                                                                                                                          Rust 2.0 wishlist:

                                                                                                                                                                                                            * Supports Unions (TypeScript, Flow, Scala3, Hare)
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Supports GADTs
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Capable of targeting both preemptive userland concurrency (go, erlang, concurrent Haskell, concurrent OCaml) and cooperative (tinygo, nodejs, async-python, async-rust) without code changes
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Easily build without libc (CGO_ENABLED=0)
                                                                                                                                                                                                          
                                                                                                                                                                                                            * No Backwards compatibility promise - This eliminates geriatrics
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Cleaner syntax, closer to Go, F#, or Python
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Graph-based Borrow Checker
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Add `try-finally` or `defer` support, `Drop` is too limiting, Async drop could help.
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Fix Remaining MIR Move Optimizations and Stack Efficiency
                                                                                                                                                                                                          
                                                                                                                                                                                                            * Culture for explicit allocator passing like Zig
                                                                                                                                                                                                          
                                                                                                                                                                                                            * `.unwrap()` is removed
                                                                                                                                                                                                          • conradludgate 9 months ago
                                                                                                                                                                                                            I muuuch prefer pin to any move trait. Pin is a place property, not a type property. I think this post covers it nicely. https://without.boats/blog/pinned-places/. It definitely should be more ergonomic though
                                                                                                                                                                                                            • simonask 9 months ago
                                                                                                                                                                                                              I don't know. In spite of Boats' great points, I think the programmer intuition definitely aligns more with it being a type property, in the sense that it enables the most interesting use case: self-referential values. All of that interacts badly with move semantics, and especially the lack of "guaranteed copy elision", but nevertheless...
                                                                                                                                                                                                              • josephg 9 months ago
                                                                                                                                                                                                                Author here. The first draft of this post spent a lot more time talking about Move. But I think the real question is: What syntax would let us author self-referential types. And, in a way that doesn't require Box-ing everything. (Rust's mantra is abstraction without overhead.)

                                                                                                                                                                                                                But then I thought about it more. Whatever you call it - Pin or Move - the point is to say "this struct contains a borrowed field". But we never needed Pin for local variables in functions - even when they're borrowed - because the borrow checker understands whats going on. The "Pin" is implicit. Pin also doesn't describe all the other semantics of a borrowed value correctly - like how borrowed values are immutable.

                                                                                                                                                                                                                I suspect if the borrow checker understood the semantics of borrowed struct fields (just like it does with local variables), then we might not need Pin or Move at all.

                                                                                                                                                                                                              • eterevsky 9 months ago
                                                                                                                                                                                                                I would gladly switch to a Rust fork without async. Even though this article is not about async per se, it’s clear that async makes most of the described problems worse.
                                                                                                                                                                                                                • josephg 9 months ago
                                                                                                                                                                                                                  Author here. I think async is a great feature to have - but I can't help but wonder if you're right. It might just be case of timing, but it seemed like once async was in the works, work on the rest of the language ceased. For awhile there all energy was poured into bikeshedding over how async would work. And I don't know if anyone is super happy with the result. Pin is a mess. Async functions still return anonymous objects - which cause all sorts of problems. And there still aren't coroutines in the language, even though async functions are implemented internally using coroutines anyway.

                                                                                                                                                                                                                  If we could go back in time and have the rust project decide to never implement async, I wonder what rust would look like today. There's a good chance the language & compiler would be much nicer as a result.

                                                                                                                                                                                                                  • mwcampbell 9 months ago
                                                                                                                                                                                                                    > If we could go back in time and have the rust project decide to never implement async, I wonder what rust would look like today.

                                                                                                                                                                                                                    If withoutboats is right [1], then Rust would never have received the industry backing to be as successful as it is now.

                                                                                                                                                                                                                    [1]: https://without.boats/blog/why-async-rust/ especially the section "Organizational considerations"

                                                                                                                                                                                                                    • josephg 9 months ago
                                                                                                                                                                                                                      "Pleasing to corporate sponsors" isn't what comes to mind when I think about great programming languages.
                                                                                                                                                                                                                    • simon_o 9 months ago
                                                                                                                                                                                                                      I think Rust's `async` has been a great success for commercial "sponsors" of Rust, because it increased the complexity of the language so much that it's hardly possible anymore to contribute to it without being full-time employed to do so.

                                                                                                                                                                                                                      The decision for `async` handed a lot of power to Amazon et al.

                                                                                                                                                                                                                    • lifthrasiir 9 months ago
                                                                                                                                                                                                                      Isn't that trivial? Just use Rust but reject any occurrence of `async` or `await` in your code or dependencies. Rust doesn't even force the use of async code for certain features in its standard library.
                                                                                                                                                                                                                      • simon_o 9 months ago
                                                                                                                                                                                                                        The problem is the ecosystem split and the decades of man hours of churn caused in libraries and user code – that's time and effort that could have been spent on making those dependencies better.

                                                                                                                                                                                                                        This applies to both suggestions ("fork" and "don't use it").

                                                                                                                                                                                                                        • lifthrasiir 9 months ago
                                                                                                                                                                                                                          So does forking, as the parent originally suggested.
                                                                                                                                                                                                                        • M4Luc 9 months ago
                                                                                                                                                                                                                          And use which first class libs? IO related libs are almost all based on Tokio. I mean I'm happy that at least there's some consent regarding the runtime. But you can't undo the decisions for going async (instead of green threads) that easily.
                                                                                                                                                                                                                      • hiimkeks 9 months ago
                                                                                                                                                                                                                        I think the first three items are "add effects, and do it right":

                                                                                                                                                                                                                        Capabilities to IO can be done by letting IO functions interrupt and call an effect handler, and the caller can specify the effect handler and do access control in there.

                                                                                                                                                                                                                        The whole Pin situation only exists because async/await was an afterthought and didn't work well with the existing language. async/await is an instance of effects.

                                                                                                                                                                                                                        I'm excited to start playing with a language that has a good effect system. I am hoping on Ante, but would also like to try Roc at some point.

                                                                                                                                                                                                                        • 9 months ago
                                                                                                                                                                                                                        • ephaeton 9 months ago
                                                                                                                                                                                                                          "Maybe I should fork the compiler and do it myself. Urgh. So many projects. If I could live a million lifetimes, I'd devote one to working on compilers."

                                                                                                                                                                                                                          -- Maybe you are living a million lifetimes in parallel right now and this one is the one devoted to working on compilers? Get to it! :-)

                                                                                                                                                                                                                          • alkonaut 9 months ago
                                                                                                                                                                                                                            > most uses of unsafe would also require explicit whitelisting.

                                                                                                                                                                                                                            I think this is probably where all proposed whitelist/capability proposal discussions end. It's going to be too many crates that are in that category for it to be useful.

                                                                                                                                                                                                                            A good first step (not sure if it's already taken tbh) would be to at least sandbox build execution. So that an attacker can't execute arbitrary code when your app is compiled.

                                                                                                                                                                                                                            • weinzierl 9 months ago
                                                                                                                                                                                                                              It's a good collection of the usual suspects, when it comes to suggested improvements for Rust.

                                                                                                                                                                                                                              The one point that stuck out for me is the comptime section. It approaches the topic from a security and supply-chain attacks angle, which is a way I never thought about it.

                                                                                                                                                                                                                              • rtpg 9 months ago
                                                                                                                                                                                                                                The function trait section reminded me about effect systems and Purescripts row polymorphism[0], which is a great little way to be able to encode properties of your functions.

                                                                                                                                                                                                                                I think Rust might quickly run into the “negative trait” problem trying to get that working, while embracing an effect system like Purescripts might get you the goods in a “principled” way. Though I haven’t thought about this deeply.

                                                                                                                                                                                                                                [0]: https://rtpg.co/2016/07/20/supercharged-types.html

                                                                                                                                                                                                                                • maverwa 9 months ago
                                                                                                                                                                                                                                  I think there are fair complaints and good ideas in this. But I also think thats a bit hypocritical: They complain that there is a gigantic backlog of features in progress (as in "not in stable yet"), and then goes on to propose a lot of additional, quite fundamental and far reaching featues they'd like to see.

                                                                                                                                                                                                                                  Don't get me wrong: I'd like coroutines and a lot of other unstable/hidden features done as well. Function traits sound great, and I'd also like the whole Pin stuff to be easier (or gone?).

                                                                                                                                                                                                                                  But please, "Lets just extend the borrow checker and fix that" sounds very demeaning. Like no one even tried? I am by far no expert, but I am very sure that its not something you "just" go do.

                                                                                                                                                                                                                                  I like most of the proposed features and improvements, I mostly share the critique on the language, but I do not thing the "why not just fix it?" attitude is helpful or warranted. Theres tons of work, and only so much people & time.

                                                                                                                                                                                                                                  • mathw 9 months ago
                                                                                                                                                                                                                                    I think the author also underestimates how incredibly difficult these things are to implement. We've seen how hard the async MVP was, and how progressing async support is so very difficult.

                                                                                                                                                                                                                                    There was a good blog post recently on Pin ergonomics, which I hope will lead somewhere good. It's not like they don't know that these things are difficult, and it's not like they're not trying to fix them, but generalised coroutines (for example) in the presence of lifetimes are absolutely monumentally difficult to get right, and they just can't afford to get it wrong. It's not like you can just nick the model from C#'s, because C# has a garbage collector.

                                                                                                                                                                                                                                    • Arch485 9 months ago
                                                                                                                                                                                                                                      > I am by far no expert, but I am very sure that its not something you "just" go do.

                                                                                                                                                                                                                                      As someone who has dabbled in compiler writing (i.e. I may be totally wrong), I believe that from a technical standpoint, modifying the borrow checker as proposed in the article (w.r.t. self-referential structs) is actually something you can "just do". The issues that come up are due to backwards compatibility and such, meaning it cannot be done in Rust without a new Rust edition (or by forking the compiler like in the article).

                                                                                                                                                                                                                                      • mathw 9 months ago
                                                                                                                                                                                                                                        Before you can "just do" a change to the borrow checker you have to be able to precisely describe how those new behaviours for the borrow checker actually work, how it interacts with the rest of the borrow checker's behaviour and how it doesn't lead to unsoundness problems. Otherwise, you might as well just not have a borrow checker.
                                                                                                                                                                                                                                        • Arch485 9 months ago
                                                                                                                                                                                                                                          Indeed. In the case of self-referential borrows, this is not allowed because Rust wants copying structures byte-for-byte (e.g. `memcpy`) to always be safe.

                                                                                                                                                                                                                                          The solution was `Pin<T>` et. al., which gives a way to make some value immovable in memory.

                                                                                                                                                                                                                                          An equivalent yet simpler version of this system could be integrated into the borrow checker (this was a proposed solution for Rust), but as I said before, it would not be backwards-compatible, hence the need for `Pin`.

                                                                                                                                                                                                                                    • uneekname 9 months ago
                                                                                                                                                                                                                                      I am relatively new to rust (only written a couple thousand lines, haven't fully grokked "idiomatic" rust, etc.) and I feel like I've run into these and similar warts many times. It is weird to lookup, say, coroutines in Rust to learn that everyone seems to agree they should exist, but they won't anytime soon. For a language focused on "correctness" and ergonomics, I think the rust community should consider some backwards-incompatible changes in the name of a better language.
                                                                                                                                                                                                                                      • mathw 9 months ago
                                                                                                                                                                                                                                        There have already been two sets of backwards-incompatible changes in Rust, and there's a third on the way in the 2024 Edition (unfortunately due out in early 2025). They tend to be relatively conservative, but that's because they want it to be easy to update your code, but there is stuff the team want to do that requires syntactic or semantic incompatibilities, so that's what that mechanism is for.

                                                                                                                                                                                                                                        It's a bit restricted on how much you can do because they do promise compatibility with older crates, but it seems to be working out pretty well and that compatibility promise is part of why it does work.

                                                                                                                                                                                                                                      • culebron21 9 months ago
                                                                                                                                                                                                                                        I think adding per-crate permissions to do undoable/unsafe things will lead us to permissions hell of devops in big deployments. Like Amazon S3 with gazillion options. I think it's time to do something radically different with 3rd party deps.

                                                                                                                                                                                                                                        Even if we put aside safety issues, each crate brings ~10 more dependencies by default (i.e. without any features turned on), which bloats compile times. Maybe it's better to be able to shard 3rd party crates, and not update them automatically at all?

                                                                                                                                                                                                                                        • hnlmorg 9 months ago
                                                                                                                                                                                                                                          That’s a solution people already use (vendering and / lock files) but it doesn’t solve this particular problem.

                                                                                                                                                                                                                                          The closest to a solution we have is dependency scanning against known CVEs.

                                                                                                                                                                                                                                          Having per-crate permissions is, I think, the only way languages can evolve past this hell hole we call supply chain attacks. It’s not a silver bullet, there will be edge cases that can be bypassed and new problems it creates. But if it reduces the scope of where supply chains can attack and what they can do, then that’s still a massive win.

                                                                                                                                                                                                                                          • josephg 9 months ago
                                                                                                                                                                                                                                            Author here. Yeah thats my thinking.

                                                                                                                                                                                                                                            I also think you probably only need to restrict your dependencies. If you have a dep tree like this:

                                                                                                                                                                                                                                                a
                                                                                                                                                                                                                                                |-b
                                                                                                                                                                                                                                                  |-c
                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                            Then if crate a decides b isn't trusted, c would inherit the same trust rules. This would allow crates to be refactored, but keep the list of rules needed in big projects to a minimum. You just have to add explicit rules for sub-crates which need more permissions. Thats probably not a big deal in most cases.

                                                                                                                                                                                                                                            (You might still, sometimes, want to be able to configure your project to allow privileged operations in c but not b. But thats an edge case. We'd just need to think through & add various options to Cargo.toml.)

                                                                                                                                                                                                                                            • culebron21 9 months ago
                                                                                                                                                                                                                                              What if dep tree is like this:

                                                                                                                                                                                                                                                  a
                                                                                                                                                                                                                                                  |-b
                                                                                                                                                                                                                                                  | |-c
                                                                                                                                                                                                                                                  |
                                                                                                                                                                                                                                                  |-c
                                                                                                                                                                                                                                                  |-d
                                                                                                                                                                                                                                                    |-c
                                                                                                                                                                                                                                              
                                                                                                                                                                                                                                              I may have read not carefully, but what happens if you allow crate X to write files, and it gets compromised? Should we set restrictions on per-call base instead?

                                                                                                                                                                                                                                              I see we may catch those situations when a crate starts reading/writing when it hadn't, or in an unexpected place, if we set restrictions per call, but this only limits the attack surface, not eliminates it.

                                                                                                                                                                                                                                              ...It may actually make 3rd party libraries such a big bureaucratic pain, that users will minimize their usage.

                                                                                                                                                                                                                                        • olivierduval 9 months ago
                                                                                                                                                                                                                                          > Most crates I use - like human-size or serde don't need any special capabilities to work. So we don't need to worry so much about their authors "turning evil" and adding malicious code to our software

                                                                                                                                                                                                                                          well... :-(

                                                                                                                                                                                                                                          Actually, it's obvious that some authors might "turn evil" dumbly, by abusing some kind of priviledged permissions. By chance, these kinds of supply-chain risks are "easily" identified because

                                                                                                                                                                                                                                          1) the permissions are an "easy" risk indicator, so you can priorize either to pin the version library (after validating it) or validate the new version

                                                                                                                                                                                                                                          2) not so many libraries will use these permissions so you "have time" to focus on them

                                                                                                                                                                                                                                          3) in these libraries, the permissions will tell you what system call/bad effects is possible, so will allow you to narrow even more the scope of investigation

                                                                                                                                                                                                                                          So, IMHO, permissions are not really the end of all but only a tiny step.

                                                                                                                                                                                                                                          The real problem is "how can human-size be used to subvert the program ?" For example: what is happening if the returned size "forget" or "add" 100 bytes to files bigger than 1 KB ? As a remininder, STUXNET was about some speed a tiny bit faster than planned and shown...

                                                                                                                                                                                                                                          • josephg 9 months ago
                                                                                                                                                                                                                                            Author here. Even if the permission system needs to be explicitly enabled and most people don't enable it, that would still have the effect of adding an early warning system for the entire rust ecosystem.

                                                                                                                                                                                                                                            > The real problem is "how can human-size be used to subvert the program ?" For example: what is happening if the returned size "forget" or "add" 100 bytes to files bigger than 1 KB ? As a remininder, STUXNET was about some speed a tiny bit faster than planned and shown...

                                                                                                                                                                                                                                            I read this argument in a similar vein to the argument against rust's unsafe blocks. "Look, C code will always need some amount of unsafe. So why bother sandboxing it?"

                                                                                                                                                                                                                                            But in practice, having explicit unsafe blocks has been a massive win for safety in the language. You can opt out of it at any time - but most people never need to!

                                                                                                                                                                                                                                            A 90% solution doesn't solve the problem entirely. But it does solve 90% of the problem. And thats pretty bloody good if you ask me! Sure - my safe rust decompression library could still maliciously inject code in files that it decompresses. But having checks like this would still reduce the security surface area by a huge amount.

                                                                                                                                                                                                                                            Less implicit trust in random crate authors is a good thing. I don't want thousands of crate authors to be allowed to execute totally arbitrary code on my machine! The current situation is ridiculous.

                                                                                                                                                                                                                                            • alkonaut 9 months ago
                                                                                                                                                                                                                                              Is there a known ratio of crates that use unsafe to ones that don't? It feels like most nontrivial crates would often need some unsafe. But a system like this might create a scenario where crates offload some of their unsafe code into separate crates so they need updating less frequently (Much like the blah-sys versus blah crates).
                                                                                                                                                                                                                                              • j-krieger 9 months ago
                                                                                                                                                                                                                                                > It feels like most nontrivial crates would often need some unsafe

                                                                                                                                                                                                                                                As a frequent contributor to a number of crates, this isn‘t really true. Also, most popular crates actively deny use of unsafe.

                                                                                                                                                                                                                                                • saghm 9 months ago
                                                                                                                                                                                                                                                  I suppose this depends on your definition of "nontrivial", but I don't think most would, unless you count the fact that some stuff in std is implemented with unsafe under the hood. The only times I've ever needed to use unsafe Rust code in 5~ years of writing it professionally was for interfacing with a vendor-specific C library, and that was only for the wrapper around it; the rest of the code didn't need to use unsafe.
                                                                                                                                                                                                                                                  • alkonaut 9 months ago
                                                                                                                                                                                                                                                    Yes I'm probably biased towards seeing more unsafe as a deal with a lot of wrapper libs (crates which in turn have -sys crates and so on). Looking at the dependency graph, if I use 10 deps directly and 5 have unsafe then that might be 50% of the direct dependencies, but probably just a small fraction of the total including transitive.
                                                                                                                                                                                                                                                  • dietr1ch 9 months ago
                                                                                                                                                                                                                                                    I think that you can delete files from safe code, but safe as it won't crash or deadlock (but may panic or trigger bugs on unsafe code).

                                                                                                                                                                                                                                                    It'd be good to track capabilities needed by libraries, so similarly to unsafe code, risky portions needing careful review are constrained and highlighted in some way.

                                                                                                                                                                                                                                                • tommiegannert 9 months ago
                                                                                                                                                                                                                                                  > Rust doesn't have syntax to mark a struct field as being in a borrowed state.

                                                                                                                                                                                                                                                  > ast_nodes: Vec<&'Self::source str>,

                                                                                                                                                                                                                                                  Oh, that would be neat to replace the https://github.com/tommie/incrstruct I wrote for two-phase initialization. Unlike Ouroboros and self_cell, it uses traits so the self-references can be recreated after a move. Whether it's a good idea, I don't know, but the magic Ouroboros applies to my struct feels wrong. But I say that as someone coming from C++.

                                                                                                                                                                                                                                                  > if let Some(x) = some_var && some_expr { }

                                                                                                                                                                                                                                                  Coming from Go, I was surprised that something like

                                                                                                                                                                                                                                                      if let Some(x) = some_var; expr(x) { }
                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                  isn't a thing.
                                                                                                                                                                                                                                                  • lifthrasiir 9 months ago
                                                                                                                                                                                                                                                    `if some_var.is_some_and(|x| some_expr)` is the current way to do that. It is less flexible and doesn't actually bind `x` into the conditional body (hence the proposal) but works today.
                                                                                                                                                                                                                                                    • tommiegannert 9 months ago
                                                                                                                                                                                                                                                      Thanks for the suggestion. It does avoid a nested if-statement, so agreed it's useful.
                                                                                                                                                                                                                                                      • josephg 9 months ago
                                                                                                                                                                                                                                                        Yeah, but I almost always want to pattern match out the value when I do that.

                                                                                                                                                                                                                                                        As I said in the post you can also write this:

                                                                                                                                                                                                                                                            if let (Some(x), true) = (my_option, expr) {
                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                        But then it doesn't short-circuit. (expr is evaluated in all cases, even when the optional is None).

                                                                                                                                                                                                                                                        Both approaches are also weird. It'd be much better to just fix the language to make the obvious thing work.

                                                                                                                                                                                                                                                        • lifthrasiir 9 months ago
                                                                                                                                                                                                                                                          I personally use two conditionals for such case. Yes, I might have written Rust too long to say this but it is more like a minor ergonomic fix and any solution should be generalizable into other use cases. The eventually accepted syntax, `if let PAT = EXPR {&& EXPR}` [1], is okay by itself but not (yet) generalized and that's my current complaint about it. The whole `{let PAT = EXPR &&} EXPR` should have been a valid expression in my opinion. (This exact suggestion is not in the RFC, the closest would be making `let PAT = EXPR` a boolean expression which really looks like a mistake.) Maybe I should check whether this was ever suggested...

                                                                                                                                                                                                                                                          [1] https://rust-lang.github.io/rfcs/2497-if-let-chains.html

                                                                                                                                                                                                                                                      • spacechild1 9 months ago
                                                                                                                                                                                                                                                        > Coming from Go, I was surprised that something like > > if let Some(x) = > some_var; expr(x) { } > > isn't a thing.

                                                                                                                                                                                                                                                        The same thing in C++17:

                                                                                                                                                                                                                                                            if (auto x = something();
                                                                                                                                                                                                                                                                expr1(x)) {}
                                                                                                                                                                                                                                                            else if (expr2(x)) {}
                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                        It's really neat to have the variable scoped to the if/else-clause.
                                                                                                                                                                                                                                                      • 9 months ago
                                                                                                                                                                                                                                                        • binary132 9 months ago
                                                                                                                                                                                                                                                          When I look at the way C++ has been developed and implemented over the years, I can’t help but think that a relatively small and questionably sustainable group of compiler engineers, no matter how passionate (and people do burn out) cannot possibly hope to sustain development of Rust indefinitely, especially as the project’s complexity and convolutions continue to further complicate and convolve. The only reason C++ has been able to is that it has very extensive industrial sustenance behind at least two of its major compilers, and presumably they also help keep GCC up to par. I don’t know, maybe GCC can somehow set the standard for what Rust can hope to do over the years, but it seems like a minor miracle from the outside.
                                                                                                                                                                                                                                                          • dietr1ch 9 months ago
                                                                                                                                                                                                                                                            Marking fixed stack size (and maybe even with an actual bound) would be helpful to ensure the tail-call optimisation is being done.

                                                                                                                                                                                                                                                            I don't think any language helps verifying that., and even in the ones that require it by spec, it's unclear if it's happening. Maybe you didn't really wrote a tail-recursive function because of a helper that you expected to be inlined. I guess it's easy to notice if you try to blow the stack in a unit test though.

                                                                                                                                                                                                                                                            • aapoalas 9 months ago
                                                                                                                                                                                                                                                              Guaranteed tail-calls with the `become` keyword have been moving forward recently.
                                                                                                                                                                                                                                                              • josephg 9 months ago
                                                                                                                                                                                                                                                                > Marking fixed stack size (and maybe even with an actual bound) would be helpful to ensure the tail-call optimisation is being done.

                                                                                                                                                                                                                                                                Yeah, it seems like a pretty easy feature to add. The compiler can pretty easily calculate the maximum stack size for every (bounded) call stack. It seems super useful to compute & expose that information - especially for embedded devices.

                                                                                                                                                                                                                                                              • FrustratedMonky 9 months ago
                                                                                                                                                                                                                                                                "the coroutines RFC has lasted longer than World War 1 or 2"

                                                                                                                                                                                                                                                                This sounds bad, but I wonder how many features have taken this long to include in other languages. Is this really as out of step as it sounds?

                                                                                                                                                                                                                                                                There is the move-fast-break-things mentality, but is that how you want to design a language?

                                                                                                                                                                                                                                                                Seems like we are missing some middle ground step, where there are good features, maybe even done, and stable, but they aren't getting worked into the main language.

                                                                                                                                                                                                                                                                Maybe a decision making problem.

                                                                                                                                                                                                                                                                • OnorioCatenacci 9 months ago
                                                                                                                                                                                                                                                                  From the examples he's mentioned, it sounds like there's quite a bit of [bike shedding] (https://en.wikipedia.org/wiki/Law_of_triviality) in the process for RFC's in Rust. That's a problem when you've got lots of smart people trying to help.
                                                                                                                                                                                                                                                                  • smolder 9 months ago
                                                                                                                                                                                                                                                                    I hate to say it since I'm generally against this kind of obstructive elitism, but I think that maybe one of the good things about rust is it's user-unfriendliness to amateurs. It has massive utility and ergonomy inherent to its design, but gatekeeping to keep away "left-pad" library authors and users is good for utility, too.
                                                                                                                                                                                                                                                                    • mwcampbell 9 months ago
                                                                                                                                                                                                                                                                      > a fully baked language - warts and all. Python 2.7 for life.

                                                                                                                                                                                                                                                                      I still wish the Python core team had abandoned the Python 3 experiment and gone with Python 2.x for life, warts and all. I learned to work with the warts, including the Unicode ones. I think a lot of us did.

                                                                                                                                                                                                                                                                      • bli940505 9 months ago
                                                                                                                                                                                                                                                                        >And I don't know if it will ever be there. Progress on the language has slowed so much. When I first started using it, every release seemed to add new, great features in stable rust. Now? Crickets.

                                                                                                                                                                                                                                                                        Is frustration with Rust on the rise? I just started using Rust few month ago and absolutely love it. I can't tell what's going on with the Rust foundation so I can only judge by reading sentiments. Nothing would kill my vibe harder than knowing smart people thinks the language isn't doing great :(

                                                                                                                                                                                                                                                                        • imron 9 months ago
                                                                                                                                                                                                                                                                          “There are only two kinds of languages: the ones people complain about and the ones nobody uses.” ― Bjarne Stroustrup
                                                                                                                                                                                                                                                                          • high_na_euv 9 months ago
                                                                                                                                                                                                                                                                            What about C#?

                                                                                                                                                                                                                                                                            Very popular lang that is actually very nicely designed and has very good ecosystem (compilers, tools like package manager, std lib)

                                                                                                                                                                                                                                                                            • tonyedgecombe 9 months ago
                                                                                                                                                                                                                                                                              Yeah, and C++ is morphing from one to the other.
                                                                                                                                                                                                                                                                            • culebron21 9 months ago
                                                                                                                                                                                                                                                                              I think every tech eventually is taken to its limits, no matter that it enabled you things that were earlier impossible. With Rust, I made projects I wouldn't dare to in Python or weren't ever able to in C. You may think what people can do with MS Excel that was impossible with a desktop/pocket calculator, but also look at how huge Excel books can get that it starts crashing. I'd say Rust delivers well on most promises, but as your projects grow, you start getting unexpected costs, like every dependency bringing a dozen of others, and compile times getting longer and longer.
                                                                                                                                                                                                                                                                              • teschmitt 9 months ago
                                                                                                                                                                                                                                                                                I wouldn't worry about it too much ... learning Rust will give you an edge on learning other languages and frameworks which is the more essential skill in the long run. On the other hand, smart people who have an unimaginably in-depth knowledge of a language and its compiler will also always have objections about its development and ideas on how to move forward. Being unsatisfied with the status-quo is a big part of why languages like Rust get developed in the first place.

                                                                                                                                                                                                                                                                                I know I used to crush hard on Python and also got worried when there were dissonances within the Python Foundation. But as you progress, I assume the goings-on in certain language communities will take a back-seat to thinking deeply about how to solve the problems you are professionally tasked with. At least that's my experience.

                                                                                                                                                                                                                                                                                As for Rust: It's gonna be around for a while. For the past months, I've been hearing a lot of chatter about how companies are using Rust for the first time in production settings and how their developers love it.

                                                                                                                                                                                                                                                                                • simonask 9 months ago
                                                                                                                                                                                                                                                                                  I think the language is doing great, not least _because_ it has slowed down a bit. To me it's an indication that is has found a decent plateau right now where people can get useful things done, and where the Rust language and compiler teams are eager to provide a stable product that doesn't break things willy-nilly.

                                                                                                                                                                                                                                                                                  A lot of the complaints I see are not super well thought through. For example, a lot of people complain about async being too explicit (having a different "color" than non-async functions), but don't consider what the ramifications of having implicit await points actually are.

                                                                                                                                                                                                                                                                                  Even in this otherwise fine article, some of those desired Fn traits are not decidable (halting problem). There's a bit of a need to manage expectations.

                                                                                                                                                                                                                                                                                  There are definitely legitimate things to be desired from the language. I would love a `Move` trait, for example, which would ostensibly be much easier to deal with than the `Pin` API. I would love specialization to land in some form or another. I would love Macros 2.0 to land, although I don't think the proc-macro situation is as bad as the author presents it.

                                                                                                                                                                                                                                                                                  The current big thing that is happening in the compiler is the new trait solver[0], which should solve multiple problems with the current solver, both cases where it is too conservative, and cases where it contains soundness bugs (though very difficult to accidentally trigger). This has been multiple years in the making, and as I understand it, has taken up a lot of the team's bandwidth.

                                                                                                                                                                                                                                                                                  I personally like to follow the progress and status of the compiler on https://releases.rs/. There's a lot of good stuff that happens each release, still.

                                                                                                                                                                                                                                                                                  [0]: https://rustc-dev-guide.rust-lang.org/solve/trait-solving.ht...

                                                                                                                                                                                                                                                                                  • moomin 9 months ago
                                                                                                                                                                                                                                                                                    I’ve said this before, but the whole function colour thing could be summarised as: “here’s a pain point easily addressed with monads, but I don’t want to consider monads, so let’s turn everything inside out to avoid thinking about monads.”

                                                                                                                                                                                                                                                                                    To which many sensible people respond “I don’t want to think about monads either, but is the pain point really that bad?”

                                                                                                                                                                                                                                                                                  • sznio 9 months ago
                                                                                                                                                                                                                                                                                    I just returned to Rust after a few years, and the syntax is even more unreadable. Half of my code is just type signatures. I don't remember it being like that back in 2016 -- it seems like the convention changed and any crate you import returns the wildest types.
                                                                                                                                                                                                                                                                                    • iknowstuff 9 months ago
                                                                                                                                                                                                                                                                                      On the contrary. Entire `where` blocks can now disappear thanks to notation like

                                                                                                                                                                                                                                                                                          arg: impl Iterator<Item: Debug>
                                                                                                                                                                                                                                                                                      • Maken 9 months ago
                                                                                                                                                                                                                                                                                        Which I honestly dislike. "where clauses" were already quite syntactically limited (there are lifetimes dependencies that the compiler understand which you cannot possibly express even using for<'a>), and now "impl Trait" is reinventing the wheel trying to catch up with where with new exotic syntax like the use<> clauses.
                                                                                                                                                                                                                                                                                      • BuckRogers 9 months ago
                                                                                                                                                                                                                                                                                        I use C# everyday and never want to switch languages. I just don’t understand the appeal to other things and I’ve certainly dabbled enough.

                                                                                                                                                                                                                                                                                        It would probably just be TS.

                                                                                                                                                                                                                                                                                      • dwattttt 9 months ago
                                                                                                                                                                                                                                                                                        The article doesn't go into detail about the unstable features, that's not just a list of features that haven't been released yet. Some are experiments whose result will be "can't or shouldn't be done".

                                                                                                                                                                                                                                                                                        Some are things that will never be stable, because they're not a feature; as an example, https://github.com/rust-lang/rust/issues/90418

                                                                                                                                                                                                                                                                                        • panick21_ 9 months ago
                                                                                                                                                                                                                                                                                          No language can continue to add freatures at speed, specially not a low level one. Rust development is going fine, crickets is just inaccurate. It just takes a while to add new stuff with zero overhead and backwards compadible.
                                                                                                                                                                                                                                                                                          • antonvs 9 months ago
                                                                                                                                                                                                                                                                                            > Rust development is going fine, crickets is just inaccurate.

                                                                                                                                                                                                                                                                                            Yeah. This is someone who's frustrated that he doesn't wake up to headlines that read "Hey babe, new Rust feature just dropped".

                                                                                                                                                                                                                                                                                            If that's what he's looking for, he should probably switch to the Javascript ecosystem.

                                                                                                                                                                                                                                                                                          • tonyedgecombe 9 months ago
                                                                                                                                                                                                                                                                                            >Nothing would kill my vibe harder than knowing smart people thinks the language isn't doing great :(

                                                                                                                                                                                                                                                                                            Smart people will always do that, I've found it's better to ignore the chatter and focus on your own experience.

                                                                                                                                                                                                                                                                                            • junon 9 months ago
                                                                                                                                                                                                                                                                                              Nah not really, just frustration a bit with how it's managed. But Rust is relatively young, and it's growing so fast that it'll take a while to reach an equilibrium with management etc.
                                                                                                                                                                                                                                                                                              • lionkor 9 months ago
                                                                                                                                                                                                                                                                                                Just look at the proposal to add an --only-dependencies flag to cargo-build.

                                                                                                                                                                                                                                                                                                https://github.com/rust-lang/cargo/issues/2644

                                                                                                                                                                                                                                                                                                Its a clusterfuck of people misdirecting the discussion, the maintainers completely missing the point, and in the end its still not even been allowed to start.

                                                                                                                                                                                                                                                                                                Cargo can download-only, it cant build only dependencies. If you, for whatever reason (ignoring the misleading docker examples) want to build your dependencies separately from your main project build, you are sol unless you want to use a third party dependency to do so.

                                                                                                                                                                                                                                                                                                • keybored 9 months ago
                                                                                                                                                                                                                                                                                                  I don’t know. But Rust FUD is at a stable high level. (Not referring to the article btw.)
                                                                                                                                                                                                                                                                                                • csomar 9 months ago
                                                                                                                                                                                                                                                                                                  > You can't tell that something is borrowed until you try to compile your program. (Aside: I wish Rust IDEs made this state visible while programming!)

                                                                                                                                                                                                                                                                                                  I am not sure what the OP is using, but with LSP I do get the error message in my editor (nvim) before any compiling (though am pretty sure some checking in happening in the background).

                                                                                                                                                                                                                                                                                                  > Compile-time Capabilities

                                                                                                                                                                                                                                                                                                  Not sure how this makes any sense when Rust compiles to multiple targets. Should all libraries become aware of all the "capabilities" out there. Also, this already can be implemented using features and keep things minimal.

                                                                                                                                                                                                                                                                                                  > Comptime

                                                                                                                                                                                                                                                                                                  I can't make sense of what the OP issue is here.

                                                                                                                                                                                                                                                                                                  > Make if-let expressions support logical AND. Its so simple, so obvious, and so useful. This should work: if let Some(x) = some_var && some_expr { }

                                                                                                                                                                                                                                                                                                  The example makes no sense.

                                                                                                                                                                                                                                                                                                  • johan_felisaz 9 months ago
                                                                                                                                                                                                                                                                                                    The section on comp time is written in a way which makes you think that zig invented the concept. It slightly irritated the lisper in me...

                                                                                                                                                                                                                                                                                                    Great article apart from that.

                                                                                                                                                                                                                                                                                                    • josephg 9 months ago
                                                                                                                                                                                                                                                                                                      Author here. Plagiarism is the most sincere form of flattery. I've never used lisp, but its nice to know that good ideas do, sometimes, eventually make their way into mainstream languages.
                                                                                                                                                                                                                                                                                                      • lispm 9 months ago
                                                                                                                                                                                                                                                                                                        it's similar, but Lisp was rarely "batch first" or "batch only", it was already coming from 100% interactivity and then adding compilation as subsystem. So running code during compilation is the default, for example with Lisp macros, which are normal functions. The software being compiled can add arbitrary code to the compilation environment.

                                                                                                                                                                                                                                                                                                        The traditional idea "compiled language" usually means a language designed for mostly batch compilation -> the compiler is not a part of the (potential) execution runtime. "compile time" and "run time" are not the same. In Lisp it is allowed to be the same.

                                                                                                                                                                                                                                                                                                    • gavinhoward 9 months ago
                                                                                                                                                                                                                                                                                                      I explain how Rust missed the mark in [1].

                                                                                                                                                                                                                                                                                                      [1]: https://gavinhoward.com/2024/05/what-rust-got-wrong-on-forma...

                                                                                                                                                                                                                                                                                                      • tskulbru 9 months ago
                                                                                                                                                                                                                                                                                                        Article aside, that page background messed with eyes while reading
                                                                                                                                                                                                                                                                                                        • TheChaplain 9 months ago
                                                                                                                                                                                                                                                                                                          Try Reader View in Firefox, has helped me with this article and many others.
                                                                                                                                                                                                                                                                                                          • selcuka 9 months ago
                                                                                                                                                                                                                                                                                                            I use a bookmarklet I found ages ago which is less invasive as it doesn't change the layout:

                                                                                                                                                                                                                                                                                                                javascript:(function(){var newSS, styles='* { background: white ! important; color: black !important } :link, :link * { color: #0000EE%20!important%20}%20:visited,%20:visited%20*%20{%20color:%20#551A8B%20!important%20}';%20if(document.createStyleSheet)%20{%20document.createStyleSheet("javascript:'"+styles+"'");%20}%20else%20{%20newSS=document.createElement('link');%20newSS.rel='stylesheet';%20newSS.href='data:text/css,'+escape(styles);%20document.getElementsByTagName("head")[0].appendChild(newSS);%20}%20})();
                                                                                                                                                                                                                                                                                                          • josephg 9 months ago
                                                                                                                                                                                                                                                                                                            Author here. Thanks for the feedback.
                                                                                                                                                                                                                                                                                                            • lagniappe 9 months ago
                                                                                                                                                                                                                                                                                                              That is a user responsibility.
                                                                                                                                                                                                                                                                                                            • Avi-D-coder 9 months ago
                                                                                                                                                                                                                                                                                                              yep,i agree on all of this and suspect a large portion of long timers do too.

                                                                                                                                                                                                                                                                                                              Some one just has to do it.

                                                                                                                                                                                                                                                                                                              • nikolay 9 months ago
                                                                                                                                                                                                                                                                                                                If functions are "fn", then coroutines should be "co". In terms of verbosity, Rust turned into Java.
                                                                                                                                                                                                                                                                                                                • adastra22 9 months ago
                                                                                                                                                                                                                                                                                                                  Do it! I’d use this language.
                                                                                                                                                                                                                                                                                                                  • sam0x17 9 months ago
                                                                                                                                                                                                                                                                                                                    These are actually great and I would gladly welcome these changes if they were implemented in stable.

                                                                                                                                                                                                                                                                                                                    My wishlist:

                                                                                                                                                                                                                                                                                                                    * allow const fns in traits

                                                                                                                                                                                                                                                                                                                    * allow the usage of traits in const exprs. This would allow things like using iterators and From impls in const exprs, which right now is a huge limitation.

                                                                                                                                                                                                                                                                                                                    * allow defining associated type defaults in traits. This can already be worked around using macros somewhat effectively (see my supertrait crate) but real support would be preferable.

                                                                                                                                                                                                                                                                                                                    * allow eager expanding of proc macro and attribute macro input, perhaps by opting in with something like `#[proc_macro::expand(tokens)]` on the macro definition. Several core "macros" already take advantage of eager expansion, we peasants simply aren't allowed to write that sort of thing. As a side note, eager expansion is already possible for proc and attribute macros designed to work _within proc macro crates_, for example this which I believe is the first time this behavior was seen in the wild: https://github.com/paritytech/substrate/blob/0cbea5805e0f4ed...

                                                                                                                                                                                                                                                                                                                    * give build.rs full access to the arguments that were passed to cargo for the current build. Right now we can't even tell if it is a `cargo build` or a `cargo doc` or a `cargo test` and this ruins all sorts of opportunities to do useful things with build scripts

                                                                                                                                                                                                                                                                                                                    * we really need a `[doc-dependencies]` section in `Cargo.toml`

                                                                                                                                                                                                                                                                                                                    * give proc macros reliable access to the span / module / path of the macro invocation. Right now there are all sorts of projects that hack around this anyway by attempting to locate the invocation in the file system which is a terrible pattern.

                                                                                                                                                                                                                                                                                                                    * allow creating custom inner attributes. Right now core has plenty of inner attributes like `#![cfg(..)]` etc, and we have the syntax to define these, we simply aren't allowed to use custom attribute macros in that position

                                                                                                                                                                                                                                                                                                                    * revamp how proc macro crates are defined: remove the `lib.proc-macro = true` restriction, allowing any crate to export proc macros. Facilitate this by adding a `[proc-macro-dependencies]` section to `Cargo.toml` that separately handles proc-macro-specific dependencies. Proc macros themselves would have access to regular `[dependencies]` as well as `[proc-macro-dependencies]`, allowing proc macro crates to optionally export their parsing logic in case other proc macro crates wish to use this logic. This would also unblock allowing the use of the `$crate` keyword within proc macro expansions, solving the age old problem of "how do I make my proc macro reliably refer to a path from my crate when it is used downstream?"

                                                                                                                                                                                                                                                                                                                    * change macro_rules such that `#[macro_export]` exports the macro as an item at the current path so we can escape from this ridiculousness. Still allow the old "it exports from the root of the current crate" behavior, just deprecate it.

                                                                                                                                                                                                                                                                                                                    • bilekas 9 months ago
                                                                                                                                                                                                                                                                                                                      Seems rust has come full circle. Rewriting everything in rust.. Why not Rust! /s
                                                                                                                                                                                                                                                                                                                      • dloranc 9 months ago
                                                                                                                                                                                                                                                                                                                        But Rust is written in Rust :)
                                                                                                                                                                                                                                                                                                                      • raverbashing 9 months ago
                                                                                                                                                                                                                                                                                                                        You know, I agree

                                                                                                                                                                                                                                                                                                                        And there's a lot of things that are weird or clunky

                                                                                                                                                                                                                                                                                                                        I honestly don't "get" the "no classes, just struct methods thing" and while, sure, C++ is kinda like that, but the ergonomics are weird. I'd much rather have the class/methods declaration as most languages do

                                                                                                                                                                                                                                                                                                                        Lifetimes are good but the implementation is meh. Most cases could do with a default lifetime.

                                                                                                                                                                                                                                                                                                                        Copy/borrow strictness is good to think about but in most cases we don't care? Copy should probably the default and then you borrow in special cases

                                                                                                                                                                                                                                                                                                                        • LetMeLogin 9 months ago
                                                                                                                                                                                                                                                                                                                          I stopped reading at "Like the first iPhone - which was amazing by the way."

                                                                                                                                                                                                                                                                                                                          That phone couldn't even send MMS.... You had to jailbreak it to be able to do normal stuff that the phones could do for ages back then.

                                                                                                                                                                                                                                                                                                                          • Havoc 9 months ago
                                                                                                                                                                                                                                                                                                                            The drama around rust leadership and also in kernel has me more spooked tbh. It’s more of a threat to the long term viability of the lang. Flaws in a language are to some extent expected and can be worked around.

                                                                                                                                                                                                                                                                                                                            Languages like C++ and python are wildly successful and don’t think anyone would call them perfect.

                                                                                                                                                                                                                                                                                                                            The dependence point is valid but not sure that is easily solvable in general. Doesn’t seem like a rust issue. See npm and python pip - blind trust is par for the course except in very rigorous environments