Collecting downvotes since before forums even had thank you’s.

  • 1 Post
  • 43 Comments
Joined 3 years ago
cake
Cake day: July 6th, 2023

help-circle



  • Remember that this has no runtime cost and is fully type-safe.

    For the sake of maximal accuracy, enum size overhead can become relevant sometimes. But a work-around exists (boxing the huge variant), and with or without boxing, the performance would still beat whatever other languages have to offer.

    Otherwise, good post (I would have to say that since it mostly rehashes points I made in previous comments 😉).


  • Who is even the target audience of this post? Beginners (which included all of us once) ask for all sorts of things. But these features didn’t happen in Rust for a reason.

    Named parameters are not needed in the age of LSP hints, where this exists as an editor feature (including (neo)vim).

    But if you really want named parameters AND optionals/defaults, rust always allowed the args struct pattern:

    struct Args<'a> {
      a: &'a str,
      b: u64,
      c: Option<u64>,
    }
    
    impl<'a> Default for Args<'a> {
      fn default() -> Self {
        Self {
           a: "hi", // default
           b: 3, // default
           c: None, // optional default
        }
      }
    }
    
    takes_args(Args{a: "not hi", ..Args::default()})
    

    The builder pattern is more about valid initialization, but does interact with the arg struct pattern when you have non-default (forced) arguments, although even then, you can not use it by having:

    struct Args<'a> {
      forced_arg1: &'a str,
      forced_arg2: u8,
      defaults: DefaultArgs, // implements Default
    }
    

    So mentioning the builder pattern is out of place.

    Overloading is not used because we have traits (and the sound subset of specialization for when that’s needed).

    So all in all, those “features” didn’t make it to Rust not because of the backlog, or for simplicity’s sake, but because idiomatic Rust (and even modern tooling in general, a la LSP) have alternatives that give you what you want and more.

    Everything mentioned above should be known by anyone who knew Rust for more than a month.



  • I’ve been watching the number of failing UI tests shrinking fast with excitement.

    Would you expect the backend to be fully ready by the end of the year? Or are there big/complicated blockers that remain, or LLVM-isms that make full or nearly full parity impossible?

    Relatedly, cranelift cg early struggles had to do, in part, with intrinsics support. I remember talk of somehow solving the problem systemically and not having to implement all of them in the backends directly? Where did things end up regarding that, and how does this backend deal with this problem?

    And finally, using evcxr with :timing enabled, and switching between backends with :codegen_backend, I notice that gcc is the slowest when it comes to compile time. Is that because more IR is given to gcc to generate from, or is gcc/libgccjit itself slower now?


  • Regarding the rust-glancer announcement itself, I hope the author is aware that lspmux (formerly ra-multiplex) exists, and zram. If lspmux didn’t exist, then yes, editor restarts would have been annoying, but that has been a solved problem for a few years already.

    Also, I’m not sure hitting SSD storage too much is good strategy in general, but maybe that’s an overstated concern.

    Otherwise, yes, RA could do better in memory consumption and some other aspects. And yes, the LSP protocol itself is not ideal.

    In any case, introducing new ideas and approaches is always good, especially when there is no “fragmentation” concerns, which I think is the case here.




  • It appears I wasn’t hit, though I easily could have been, as I installed some Rust-based Python packages recently.

    I easily could have been

    If you’re using good projects that have Cargo.lock checked in (should be about everyone nowadays), an do the right thing using --locked with cargo install, then not really, It wouldn’t have been easy.

    Unless both an upstream (auto-)merging a bot PR updating to the malicious version (bad), and you installing that upstream (spectacularly unlucky), happened to coincide within that 86 minutes the malicious crate was up (39 minutes if advisory-db was hit at any step), which is almost impossible, but more importantly, fully traceable and investigable at the ecosystem level. And if we are talking released versions only, then the upstream would have had to cut a release and publish it also within that window.

    But yes, this is a historic first, a malicious publishing of a real crate with real dependants.


    Edit: I checked all arrayref dependants, and no crate published within the compromised window. No crate explicitly depends on >=0.3.10 (forcing the malicious version). And no crate published after the incident (potentially indicating fixing an earlier mistake) except for a couple of no-name blockchain crates that don’t even have source repos.






  • great article!

    Is it?

    I didn’t read past the first sentence:

    The Arc type is Rust’s thread-safe smart pointer

    This is horrible in my view. All types that implement Deref and/or DerefMut can be called smart pointers, and everything is “thread-safe” in safe Rust.

    If I had to call something “Rust’s thread-safe smart pointer”, it would be the actual references &T/&mut T where T: Send + Sync.


    Digression: All the traits involved like the 4 mentioned above point to the C++ centric concept of smart pointer not mapping cleanly to Rust semantics imho. But that’s a long lost battle.


    Let’s see what the official Arc docs say:

    A thread-safe reference-counting pointer.

    Will you look at that! An actually accurate short description that is already available.


    While not widespread, there is already a small myth out there that paints Rust as if it’s Swift-like, a ref-counting centric language.