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

help-circle
  • It pushes your code to be very tree-shaped

    This is basically where my learning took me. I had to develop this notion that there was a preferred directionality to ownership and data flow, like “grain” in a piece of wood. Everything is easier if you go with the grain. “Tree-shaped” works too, since it basically is the call graph of a (single threaded) program.

    The point where I realized all this was when I tried to do a very Python/JS-brained thing: return a closure from a function. The moment you try to “curry” values into the closure, you have to “move” them to solve for ownership, lest you bring timelines into the picture. Which isn’t always what you want in a generic and reusable function. And sure enough, the standard lib and other popular libraries want you to pass a closure to functions instead.


  • This was my experience too, until I learned a few things.

    • If you’re coming from another programming language, the equivalent capabilities you’re probably used to are Box, dyn, and Rc.
    • Dynamic dispatch (dyn) isn’t really necessary a lot of the time. Identify where you absolutely need it and solve everything else through other means.
    • You wind up with lifetime specifier problems if you try to do a lot with references (&). Instead, try to re-think your structs and functions using composition and clone/copy instead. It’s less efficient, but it’s easier to optimize a running program, too.
    • Rust enum, match, if let, and ? are weird, but are where you get the most leverage in the language. Try to master them.
    • derive[...] is a first-class feature with a lot of standard lib support. Always use this to make your custom types mesh with the standard lib more seamlessly.
    • If you are experienced with the “Design Patterns” book, you absolutely need this: https://rust-unofficial.github.io/patterns/intro.html
    • Macros are an advanced feature, but help get you around limitations in generics and the type system in general. it really is worth knowing, and like the preprocessor in C/C++, isn’t avoidable at the intermediate level.
    • The compiler digs deep into your code to figure out types where they’re not explicitly declared. I’ve seen it reach into the return type, call-spec, and function calls within that function, to figure out types for things. This is very hard to observe without an IDE that’s checking syntax on the fly. Lean into both of those for more readable and maintainable code.
    • if and match are expressions, not statements! You can use either block to evaluate to a single value, useful in composite expressions like let. Example; let x=if y>20 { y } else { 0 }; Or use them to return values from functions (w/o need of a return statement).

  • I will say this: for me, learning rust was 80% un-learning habits from other languages.

    People tend to not like it when they have to change habits, especially if those took a long (and painful) time to acquire.

    In this particular case, this is the same complaint Go faced with its form of explicit error handling. And Java, for that matter.

    Honestly, Rust does a killer job of avoiding checked exceptions and verbose error hooks by way of the ? operator, and requiring all possible match branches to be accounted for. If you embrace errors fully, by using Result<> and custom Error types, your program gets a massive boost in robustness for not a lot of fuss. I recently learned that it gets even better if you embrace enum as a way to define error values, and make sure it implements useful traits like From and Display. With that, error handling code gets a lot more succinct, permitting one to more easily sift through different error values after a call (should you need to). All of that capability far exceeds any perception of clunkyness, IMO.




  • Yup. Learned that one back in the 3rd grade. This stuff is hard if you’re not experienced enough to know how people work.

    On the upside, I learned that one cannot buy their way into other’s good graces, especially if they’re going to require you to modify your behavior to get there; they’re lying and that was never the issue. On the downside: holy shit that hurts once it goes wrong the first time.

    As an adult I can also appreciate that there are situations where you can “buy your way in” to a club or status of some sort. IMO, those situations are generally not worth it to begin with, requiring an never-ending stream of cash to keep up appearances. Plus, it surrounds you with other people that also believe, and are invested, in the program. It’s a recipe for elitism at best, and a big 'ol grift at worst. Better friends and relationships can be had for $0 everywhere else.


  • I was introduced to flyweight RPGs a few years back and I absolutely love what they can do in the hands of a creative group.

    Roll for Shoes is about as minimal as it gets. You will need one D6, and something to track player inventory. The game world is best started by the GM in the abstract, letting the players fill in the world’s details through creative use of questions that prompt die rolls. This is fantastic for players that want to stretch their improv skills.

    Lasers & Feelings has a tad more structure. Everyone has exactly one stat that sits on a spectrum of “lasers” to “feelings”. The difficulty of challenges in the game sit on the same spectrum. Depending on the nature of the challenge and what the player’s stat is, a single D6 roll decides the outcome. Everything else is role-playing in what is encouraged to be a Trek-like setting.

    In my experience, Roll for Shoes usually turns into a cartoon-esque “let’s see what else is in my backpack” affair, that usually ends with everything on fire (because of course it does). Lasers & Feelings typically devolves into Lower Decks. All of these are positives in my book - I’d play again in a heartbeat.


  • It’s sister setting, Earthdawn, also had a lot going for it on top of the typical D&D formula. Weaving, instead of casting magic, was a much more involved process for the player/character which did a lot to ground such awesome power. At the same time, fighters of all stripes were also more or less magic users, which unified the whole rule system in a nice way. The setting itself was a fantasy post-apocalypse, troubled by evil horrors that dominated the landscape in the centuries before. In fact, much of the lore was intertwined with how people survived those times.

    And like Shadowrun, there were lots of dice thanks to the “step table” system. It could be a huge PITA to sum all the rolls on high steps, but then when else do you get to roll entire fists full of dice all at once?


  • Whoa, you are not kidding. The toilet is powered (not so unusual for bidet toilets), but it looks like there’s no mechanical override. Just a ‘remote’ control panel with a flush button (among many other features). That I’m sure is hygienic.

    The video is about how to bluetooth pair the remote to the toilet. There are so many points of possible failure here, I can’t even.


  • Watching people repair old electronics on Youtube has opened my eyes to the realities of real-world electrical engineering. In short: it’s all about tolerances.

    A power supply may have a nominal voltage of 5V, but anything from 4.8 to 5.2 is a-okay. Why? Because your TTL components downstream of that can tolerate that. Components that do 5V logic can define logic zero as anything between 0 and 0.8 volts, and logic one as low as 2 volts. That’s important since the whole voltage rail can fluctuate a lot when devices use more power, or draw power simultaneously. While you can slap capacitors all over the place to smooth that out, there’s still peaks and dips over time.

    Meanwhile, some assembly lines have figured out how to aggressively cost-reduce goods by removing whole components from some circuits. Just watch some Big Clive videos. Here, the tendency is to lean heavily into those tolerances and just run parts hot, under/over powered, or just completely outside the published spec because the real-deal can take it (for a while). After all, everything is a resistor if you give it enough voltage, an inductor if the wire’s long enough, a capacitor if the board layout is a mess, and a heatsink if it’s touching the case.



  • dejected_warp_core@lemmy.worldtoScience Memes@mander.xyzMoon Dust
    link
    fedilink
    English
    arrow-up
    82
    ·
    edit-2
    21 days ago

    IMO (not a scientist), moon dust is basically pulverized glass, only without the benefits of weathering and erosion. So think of lots of microscopic sharp, abrasive, shards of finely pulverized volcanic rock and obsidian. Get that stuff anywhere near a mucous membrane - eyes, nose, mouth, throat - and it’s going to irritate you. At the same time, it’s pretty much intert; well, at least the parts that don’t instantly react to oxygen or humidity that is. My guess is that Schmidt is just a little more sensitive to the physical sensation of it, or perhaps he rubbed his eyes with a glove by accident, giving him an extra big dose.

    And for the uninitiated, it’s well documented that everyone in the lander was physically exposed to moon dust. There was no airlock on the lander, so every excursion resulted in bringing whatever was on the suits right into the cabin. They reported that it “smelled” like burned gunpowder, so they were at least all inhaling the stuff.