• 0 Posts
  • 13 Comments
Joined 3 years ago
cake
Cake day: June 21st, 2023

help-circle
  • id like to investigate about rewriting my “decentralized p2p encrypted messaging app” in Rust. if you are familiar with any of the details, id like to hear your opnions on the approach.

    For learning purposes? If you actually intend to create a service people are supposed to use, then use something that already exists like Matrix or Signal. No encryption is secure if it isn’t peer reviewed and extensively tested.

    If it’s just for personal learning, then that doesn’t matter.

    the core reason behind investigating rust is that it has better tooling for things like formal-verification.

    You can do formal verification in any language, but it’s mostly used for languages with certified compilers (and you’d have to use one of those compilers). For that, you’d want to look at something like Ferrocene, but that costs money.

    Instead, the core reason behind using Rust should be the ability to use constant-time algorithms. This can help defend against timing attacks.

    Rust also has a great crypto ecosystem, so a lot of the tools you’ll want are already built for you. Use them.

    things like audits and formal-proofs/verification are fundamentally invalid because i used AI to create it.

    Correct. An audit depends on someone’s reputation, and formal verification requires review.


    Anyway, learning Rust will take some time. For backend, the ecosystem goto is usually axum, and Rust has a built-in TCP client/server but you might want to see what tokio offers if you’re using async.



  • While interesting, this entire article works with a static MyStruct. This means the type already is Any, and if you define MyTrait: 'static, then you can do the downcast by first casting to an Arc<dyn Any> and using one of the downcast methods.

    For non-'static types, downcasting soundly is incredibly difficult. You need to somehow get the correct lifetime back from the trait. You’re better off using unsafe at that point anyway. If the trait itself holds the lifetime (impl<'a> MyTrait<'a> for MyStruct<'a>), then that can help with it, though I’m not really sure how lifetime variance plays into the soundness of a downcast here.

    Finally, at the end, I’d rather just use an assert! over an unchecked assertion. I know the goal is to look at the assembly with that assertion in place, so it makes sense why they used it here. In practice, an actual assertion is a lot better because the compiler gets the same information from it and you get validation at runtime that the information is correct.

    Anyway, great article! The goal was to explore how Arc casting works, and I think it does a great job at showing and explaining that.




  • Does your function need to accept &mut self? If you can redesign that function just to take the slice of game objects (fn update(objs: &mut [T])) then you don’t need to worry about the aliasing at all. You can pass an index as well if you want to operate on them one at a time.

    This is actually closer to the strategy you’d see with ECS. You’d operate not on individual objects, but on all relevant objects at once.



  • Zig’s features don’t map 1:1 to Rust’s features, so translating line-by-line (or file-by-file) doesn’t even make much sense. What are you supposed to do with a crazy comptime function full of reflection when translating that? What about custom pointer types (which Bun had to create for Rust), lifetimes, differences in ecosystem library APIs, etc?

    The author actually mentions the challenges they ran into due to breaking the code up across multiple crates. They needed to break cyclic dependencies for it all to compile.

    I agree. 1 year is an underestimate.



  • TehPers@beehaw.orgtoRust@programming.dev•Rewriting Bun in Rust
    link
    fedilink
    English
    arrow-up
    16
    ·
    3 months ago

    There are a lot of ways to do a terrible job of this. For example, prompting Claude “Rewrite Bun in Rust. Don’t make any mistakes.” and then praying it would work is not [sic] what I did.

    Adversarial workflows seems like an awesome strategy for burning tokens if your workplace uses a token leaderboard. I’m glad to see that someone discovered a way to game the system!

    I’m really hoping that Boa can compete soon. I’d love an embeddable, Rust-based JS engine that isn’t just AI generated unsafe everywhere. I don’t think they plan to really fit into the same space as node/deno/bun, but we already have node for that, and an easier to use JS runtime from within Rust would be awesome.




  • AI is used to various extents:

    • Some projects do not use AI. The quality of the project is a direct output of the skill and experience of its developers.
    • Some projects use AI lightly. Where AI is used, developers review the output, and it’s not trusted to produce large features or even code at all in some cases.
    • Some projects use AI heavily. These projects generally adopt “move fast and break things” mentality which naturally means they both move fast and break things.
    • Some projects are pretty much entirely AI generated. These projects adopt the “break things” mentality. It’s like watching someone jogging in place fall over and break both of their legs, and in the process crush someone’s pet.

    For a file manager, I would be careful how much I trust AI output.