3
lorentz
60d

I'm hurtling down the Dunning Kruger slope in Rust datastructure design. The orchidlang crate has a struct that attempts to wrap and replicate a slice for no reason other than to attach some domain-specific methods and a custom Display implementation. I came up with 4 different representations for a file URI as provided by the language client. The most recent one holds a singular string in an Arc. I know that these are bad ideas but I don't know why I keep coming up with them.

Comments
  • 0
    @jestdotty I identified three fundamental components to learning building software

    1. learn tools and understand what they do to acquire new puzzle pieces by reading docs and tech publications

    2. read existing code that has a reputation for being either pleasant or powerful to pick up new ways to combine the puzzle pieces that might not have been obvious

    3. have a peer read and criticize your code, welcome all criticism even if you disagree or it's overly harsh. If you listen long enough, you'll eventually hear things you agree with but didn't already know

    As far as I'm aware, none of these teach how to write good code, that is, code that lends itself to likely modifications. The only way I've ever been able to grow in that area is by writing a lot of code and then editing it and noticing what's easy and what's hard.
  • 1
    I can memorize all the Core Guidelines and read every "modern C++" book published between 2008 and today, but my C++ will suck until I'd edited a million lines written by myself and understood the invisible weights attached to every piece of wisdom.

    Luckily, I'm not likely to have to write C++ any time soon so it'll probably suck forever.
  • 2
    That being said, I do wish there was more literature on Rust. I find clever patterns left and right and it bugs me that I can't refer to an authoritative source written by more experienced people for pitfalls. The only way I can evaluate any of them is by using it until it breaks.
  • 2
    yeah I do the puzzle pieces but even that is hard in rust

    I've taken to just interrogating chatGPT for syntax variations

    my experience with peers has been lacklustre and a waste of time. I'll give code to someone and they just say everything is good, then I'm in an interview with a guy and it's the exact same language and he ends up telling me i'm a junior and sending me a stupid newbie mailing list as a recommendation when he can't even make a bullet point list properly in his emails
    nor do I trust people to know things. I've moonlit in discord programmer chats and answered questions in servers and everyone says everything is impossible when it is not.

    I think it's easier to learn by doing and other people are just noise

    prediction of modifications I've been heralded for being able to do oddly enough, and it had nothing to do with code. I just predicted how the personalities who were in charge of the product would evolve over time in their preferences and needs (tech blindspots)
  • 1
    @jestdotty The key difference between structs/C++ classes and Java/C# classes is that a struct is free performance-wise, so most datastructures are built from a crazy lot of them and that's fine.

    Wrappers on the other hand are expensive in terms of maintenance burden, because a good wrapper passes through a lot of things. My current struggle is identifying what exactly a wrapper needs to do, and what use cases justify them.
  • 1
    @jestdotty In Java, a class incurs at a minimum

    - allocation overhead

    - dynamic dispatch for methods

    - GC or refcounting if you're very careful

    - pointer resolution for data

    - synchronization (I'm not sure when but in a multithreaded system at least destruction)

    In Rust, these are counted separately.

    - dyn costs dynamic dispatch

    - Box, Rc and co costs a pointer resolution and allocation overhead

    - Arc costs synchronization on cloning or destruction.

    - Any reference costs a pointer resolution but that's by far the cheapest of the bunch.

    If you have none of these, any amount of type voodoo is free at runtime.
Add Comment