• 24 Posts
  • 1.13K Comments
Joined 6 years ago
cake
Cake day: May 31st, 2020

help-circle
  • In many cases, you don’t need an equivalent to finally, because the cleanup is automatically handled via the Drop trait, which runs cleanup code when the object is freed from memory (similar to “destructors” in some other languages).
    Because of Rust’s whole ownership thingamabob, it’s generally entirely deterministic when this code will run (at the closing brace for the scope in which the object is defined, unless you pass that object outside of that scope).

    In other cases, you don’t need a finally, because nothing forces you to bubble up errors instantly. You can make a call which fails, store the error in a variable, run your cleanup steps and then return the error at the end of you function.

    Sometimes, however, you do want to bubble up errors right away (via ? or early return), typically so you can group them together and handle them all the same.
    In that case, you can run the cleanup code in the calling function. If you don’t to want to make it the responsibility of the caller, then pull out a small function within your function, so that you become the caller of that small function and can do the cleanup steps at the end of your function, while you do the bubbling within the smaller function.
    There’s also ways to make that less invasive via closures (which also serve as a boundary to which you can bubble errors), but those are somewhat complex in Rust, due to the whole ownership thingamabob.

    I will say, I do sometimes feel like Rust could use a better way to handle doing something before the error bubbles up. But generally speaking, I don’t feel like a finally is missing.


  • You can use the anyhow crate for something quite similar to exceptions: https://crates.io/crates/anyhow

    In terms of how it actually fits into Rust, you want to use anyhow for application code. If you’re writing a library, then anyhow is a no-go, because users cannot match on different error classes with it. (Much like you would want custom exception classes, so that users can catch them in different catch branches and handle them differently.)

    Every so often, you will also need matchable error classes within your application code, then you would have to replace anyhow with a custom error type there, too, of course.

    I will also say, IMHO it is fine to use anyhow even while you’re learning Rust. It is so easy that you kind of skip learning error handling, which you will need to learn at some point, but you can still do that when you actually need it.





  • We deployed a client software in a Docker container on Windows 10. It could not connect to the backend, even though we saw SYN packages originating from it.
    So, we ran WireShark on the Windows host and saw that the SYN-ACK packages from the backend were arriving there, too, but no ACK came through to complete the TCP handshake.

    Eventually, we rolled out a network debugging container on that Windows host and then could see in the tcpdump, that the SYN-ACK packages, which arrived on the Windows host, just did not show up in the container. Hyper-V or something was quietly dropping them.

    Other network connections were working fine, just the SYN-ACK from our backend triggered this.






  • I feel like this isn’t really a new development. Back when LAN parties and local multiplayer were still a thing, games like TeeWorlds, Worms etc. were popular, because they ran on potatoes and you could often get them for free.

    The actual fun then came from dicking around with or competing against your friends. The game itself does not need to be ground-breaking for that.

    Hell, it technically started even earlier than that, with physical card games and board games and such. Just play them with friends and it’s fun.




  • I also always find that outsourcing is risky, whether it’s to other devs or to some AI, because it requires that you understand the problem in whole upfront. In 99% of cases, when I’m implementing something myself, I will run into some edge case I had not considered before and where an important decision has to be made. And well, a junior or LLM is unlikely to see all these edge cases and to make larger decisions, that might affect the whole codebase.

    I can try to spend more time upfront to come up with all these corner cases without starting on the implementation, but that quickly stops being economic, because it takes me more time than when I can look at the code.




  • I mean, I don’t have a ton of skin in the game here, as I don’t care much for horror games either way.
    But yeah, I just assume that they say they’re cautious to calm the fans, but they actually can’t be cautious, since well, they can only really delay by a whole year at a time, and if they do that, then they have two games in the year afterwards.

    They did only pre-plan a handful of years, so maybe they can just delay the following games by a year each, too.

    But yeah, it still just sounds like the decision-making here isn’t driven by logic or what allows publishing good games, but rather by
    Mr. Krabs meme, where he says "Hello, I like money!".




  • Large shared codebases never reflect a single design, but are always in some intermediate state between different software designs. How the codebase will hang together after an individual change is thus way more important than what ideal “north star” you’re driving towards.

    Yeah, learned this the hard way. Came up with an architecture to strive for 1½ years ago. We shipped the last remaining refactorings two weeks ago. It has been a ride. Mostly a ride of perpetually being low-priority, because refactorings always are.

    In retrospect, it would’ve likely been better to go for a half-assed architecture that requires less of a diff, while still enabling us to ship similar features. It’s not like the new architecture is a flawless fit either, after 1½ years of evolving requirements.

    And ultimately, architecture needs to serve the team. What does not serve the team is 1½ years of architectural limbo.