• 2 Posts
  • 117 Comments
Joined 1 year ago
cake
Cake day: July 6th, 2023

help-circle
  • that’s not what I’m looking for when I’m looking at a backtrace. I don’t mind plain unwraps or assertions without messages.

    You’re assuming the PoV of a developer in an at least partially controlled environment.

    Don’t underestimate the power of (preferably specific/unique) text. Text a user (who is more likely to be experiencing a partially broken environment) can put in a search engine after copying it or memorizing it. The backtrace itself at this point is maybe gone because the user didn’t care, or couldn’t copy it anyway.



  • But why can’t we fight to make Rust better and be that “good enough” tool for the next generation of plasma physicists, biotech researchers, and AI engineers?

    Because to best realize and appreciate Rust’s added value, one has to to be aware, and hindered by, the problems Rust tries to fix.

    Because Rust expects good software engineering practices to be put front and center, while in some fields, they are a footnote at best.

    Because the idea of a uni-language (uni- anything really) is unattainable, not because the blasé egalitarian “best tool for the job” mantra is true, but because “best tool” from a productive PoV is primarily a question of who’s going to use it, not the job itself.

    Even if a uni-language was the best at everything, that doesn’t mean every person who will theoretically use it will be fit, now or ever, to maximize its potential. If a person is able to do more with an assumed worse tool than he does with a better one, that doesn’t necessarily invalidate the assumption, nor is it necessarily the fault of the assumed better tool.

    Rust’s success is not a technical feat, but rather a social one

    fighting the urge to close tab

    Projects like Rust-Analyzer, rustfmt, cargo, miri, rustdoc, mdbook, etc are all social byproduct’s of Rust’s success.

    fighting much harder

    LogLog’s post makes it clear we need to start pushing the language forward.

    One man’s pushing the language forward is another man’s pushing the language backward.

    A quick table of contents

    Stopped here after all the marketing talk inserted in the middle.
    May come back later.


    Side Note: I don’t know what part of the webshit stack may have caused this, but selecting text (e.g. by triple-clicking on a paragraph) after the page is loaded for a while is broken for me on Firefox. A lot of errors getting printed in the JS console too. Doesn’t happen in a Blinktwice browser.


  • From my experience, when people say “don’t unwrap in production code” they really mean “don’t call panic! in production code.” And that’s a bad take.

    What should be a non-absolutest mantra can be bad if applied absolutely. Yes.

    Annotating unreachable branches with a panic is the right thing to do; mucking up your interfaces to propagate errors that can’t actually happen is the wrong thing to do.

    What should be a non-absolutest mantra can be bad if applied absolutely.


  • (DISCLAIMER: I haven’t read the post yet.)

    For example, if you know you’re popping from a non-empty vector, unwrap is totally the right too(l) for the job.

    That would/should be .expect(). You register your assumption once, at the source level, and at the panic level if the assumption ever gets broken. And it’s not necessarily a (local) logical error that may cause this. It could be a logical error somewhere else, or a broken running environment where sound logic is broken by hardware or external system issues.

    If you would be writing comments around your .unwrap()s anyway (which you should be), then .expect() is a strictly superior choice.

    One could say .unwrap() was a mistake. It’s not even that short of a shortcut (typing wise). And the maximumly lazy could have always written .expect("") instead anyway.






  • start a process within a specific veth

    That sentence doesn’t make any sense.

    Processes run in network namespaces (netns), and that’s exactly what ip netns exec does.

    A newly created netns via ip netns add has no network connectivity at all. Even (private) localhost is down and you have to run ip link set lo up to bring it up.

    You use veth pairs to connect a virtual device in a network namespace, with a virtual device in the default namespace (or another namespace with internet connectivity).

    You route the VPN server address via the netns veth device and nothing else. Then you run wireguard/OpenVPN inside netns.

    Avoid using systemd since it runs in the default netns by default, even if called from a process running in another netns.

    The way I do it is:

    1. A script for all the network setup:
    ns_con AA
    
    1. A script to run a process in a netns (basically a wrapper around ip netns exec):
    ns_run AA <cmd>
    
    1. Run a termnal app using 2.
    2. Run a tmux session on a separate socket inside terminal app. e.g.
    export DISPLAY=:0 # for X11
    export XDG_RUNTIME_DIR=/run/user/1000 # to connect to already running pipewire...
    # double check this is running in AA ns
    tmux -f -f <alternative_config_file_if_needed> -L NS_AA
    

    I have this in my tmux config:

    set-option -g status-left "[#{b:socket_path}:#I] "
    

    So I always know which socket a tmux session is running on. You can include network info there if you’re still not confident in your setup.

    Now, I can detach that tmux session. Reattaching with tmux -L NS_AA attach from anywhere will give me the session still running in AA.




  • Is your browser Firefox?
    What kind of storage devices do you have? NVMe?
    Did you check with tools like iotop to see if something is going on IO wise?

    You assumed that the problem is caused by the CPU being utilized at 100%.
    This may not be the case.

    A lot of us don’t run a DE at all. I myself use Awesome WM.
    For non-tilers, Openbox with some toolbar would be the ideal setup.

    I mention this because we (non-DE users) would have no experience with some funky stuff like a possible KDE indexer running in the background killing IO performance and thrashing buffered/cached memory.

    Also, some of us run firefox with eatmydata because we hate fsync 🤨

    Neither KDE nor Gnome is peak Desktop Linux experience.
    Ubuntu and its flavors is not peak distro experience either.

    If you want to try Desktop Linux for real, you will need to dip your toes a little bit deeper.








  • A generic impl is impossible.

    Imagine you want to turn a Into<String> to Some(val.into()) and Option<Into<String>> to val.map(Into::into).

    Now, what if there is a type T where impl From <Option<T>> for String is implemented?
    Then we would have a conflict.

    If you only need this for &str and String, then you can add a wrapper type OptionStringWrapper(Option<String>) and implement From<T> for OptionStringWrapper for all concrete type cases you want to support, and go from there.