• 0 Posts
  • 145 Comments
Joined 2 years ago
cake
Cake day: November 13th, 2023

help-circle


  • NGL, writing pure functions in Rust is fantastic. Writing responsible code that handles all the error conditions turns the “happy path” into hamburger. Even with the ergonomics of Result, Option, and even ?, code just sprawls and becomes a readability tradeoff. I’m only a few months into Rust at this point, and I have a lot to learn, but it’s tempting to just .unwrap() and .expect() where I think it’s unlikely to fail.












  • Well, I did have the older version on the left as a kind of rosetta stone for this. Plus, this kind of “init and/or return” pattern shows up a bunch of places, so it makes sense someone would want a quick version that’s harder to screw up or has fewer side-effects.

    I’ve also spent years investigating better ways to do things through various versions of C++, D, Rust, Go, and TypeScript. After a while, the big-picture patterns start to emerge and you see different camps start to converge on the same kinds of things. Stuff like these weird features start to feel like learning a new slang term for something you’ve felt, but could never say so succinctly.

    In the case of ??= it’s a more formalized Python x = x or y or x = x || y in JavaScript. The catch is that not all languages treat assignments like expressions that can be returned, so you get a clunky return as a separate statement; return (x = x or y) doesn’t always fly. That friction is all over the place, and it’s natural to want a shorthand for this very thing.

    Sure enough, after searching a bit, ??= shows up in JS, PHP, and even Ruby has a version.

    Edit: more context.



  • Eh, I haven’t touched C# since 2001. I agree that the more verbose style is more explicit, and so more readable. That said, I can figure most of the new style out from context.

    • => is clearly a closure declaration operator, similar to JavaScript.
    • x ??= y is shorthand for “assign y to x if x is not set, and return x” which is kind of nice.

    There must also be some shorthand going on for getter properties being the same as methods w/o an arglist (or even a ()).

    The only part that has me stumped is the unary question-mark operator: private static Singleton? _instance = null; I can think of a half-dozen things that could be, but I cannot decide what it’s doing that the original question-mark-free version isn’t.





  • not to become a walking surveillance device / info mine.

    This is really where everyone should nope the fuck out. Sadly, it probably won’t pan out like that.

    Gibson was so incredibly close to prescient on this one. With this kind of tech, we’ll have actual “gargoyles”, but all the data makes a pit-stop at a corpo database where it can be mined for value, before it ships off to the CIA:

    Gargoyles represent the embarrassing side of the Central Intelligence Corporation. Instead of using laptops, they wear their computers on their bodies, broken up into separate modules that hang on the waist, on the back, on the headset. They serve as human surveillance devices, recording everything that happens around them. Nothing looks stupider; there getups are the modern-day equivalent of the slide-rule scabbard or the calculater pouch on the belt, marking the user as belonging to a class that is at once above and far below human society. They are a boon to Hiro because they embody the worst stereotype of the CIC stringer. They draw all of the attention. The payoff for this self-imposed ostracism is that you can be in the Metaverse all the time, and gather intelligence all the time.

    https://cyberartsweb.org/cpace/cyborg/kawstretch.html