dejected_warp_core

joined 2 years ago
[–] dejected_warp_core@lemmy.world 3 points 1 hour ago (1 children)

So... which one of you is going to ask Randall Munroe if this is plausible or not? Disregarding the the obvious frozen-butt problem, of course.

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.

[–] dejected_warp_core@lemmy.world 1 points 5 hours ago* (last edited 5 hours ago)

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.

The fact that this probably doesn't even optimize to a lookup table just gives me pain.

[–] dejected_warp_core@lemmy.world 9 points 6 hours ago* (last edited 6 hours ago)

It's basically the UI equivalent of this:

Yes, it's a fully-functional date picker and also deviously, wildly, uncomfortably outside of aesthetic norms. Also, there's a lots of fun, invalid combinations of input outside of the usual "February 30th" shenanigans.

Why yes, that's my birthday: the 32nd of Septunepril. What's the problem?

[–] dejected_warp_core@lemmy.world 6 points 6 hours ago (1 children)

Thanks. I hate it.

Do we really want "The time my AI bang-maid turned out to be a lethal combat robot" as a light novel? Because this is how that happens. (assuming it hasn't already)

The picture is really tiny, but Kate is definitely sending "AI-generated" vibes with that photo.

Well, Temporal Investigations only cares if you move at a negative speed. And causality just flippin' breaks down and ends the universe if you move instantaneously. Everything else seems to be fair game. So... mostly nobody?

::cue Spongebob music::

340 million years later

[–] dejected_warp_core@lemmy.world 12 points 1 day ago (4 children)

I was going to reply to this with yet more Nick Cage overreactions, but the man is just a font of stuff like this. There's literally too much to pick from.

 

I used to really enjoy sites like this. I know there's joke accounts on Twitter and other sites here and there, but I haven't seen anything lately that has the whole site as one big running gag.

https://en.wikipedia.org/wiki/Q%26A_comedy_website

A Q&A website is a website where the site creators use the images of pop culture icons, historical figures, fictional characters, or even inanimate objects or abstract concepts to answer input from the site's visitors, usually in question/answer format. This format of website, most popular in the early 2000s, evolved from the much older Internet Oracle. The original progenitor of this type of site was the now-defunct Forum 2000. The Forum 2000 claimed to have run the site by means of artificial intelligence, and the personalities on the website were called SOMADs, or "State Of Mind Adjointness pairs". However, later Q&A sites usually dispensed with this pretense, with the most extreme example being Jerk Squad!, on which the administrators of the site provide many of the answers.

 

FTA:

Two Democratic legislators are introducing a bill on Wednesday aimed at Mr. Musk and the so-called Buffalo Billion project, in which the state spent $959 million to build and equip a plant that Mr. Musk’s company leases for $1 a year to operate a solar panel and auto component factory.

The bill would require an audit of the state subsidy deal to “identify waste, fraud and abuse committed by private parties to the contract.” It would determine whether the company, Tesla, was meeting job creation targets, making promised investments, paying enough rent and honoring job training commitments.

If Tesla was found to be not in compliance, the state could claw back state benefits, impose penalties or terminate contracts.

view more: next ›