• 1 Post
  • 8 Comments
Joined 4 months ago
cake
Cake day: July 19th, 2024

help-circle

  • I don’t believe you, show me this project. As a personal project I have made a monolithic web server, that handles api calls, webpage calls etc, it uses axum, tokio and serde and when I run cargo build --release it compiles down to a 1.9mb binary. The only way I can see this happening is if you’re not using a release build, which is a concept you should understand as a JS dev.

    I mean if you run a basic get request with the reqwest library and compile it, 32mb. In C is a few KB. You can have chatgpt generate for you if you wanna try it yourself but not write the code. This is because rust doesn’t do proper tree shaking of code and bundles everything into it even if it’s not necessary.

    What are you building where the end user doesn’t care if the app performs well? Not caring about resource usage results in poor performance which results in dissatisfied users/customers which stop doing business with you. Have you heard about the unending war in JS land against bundle size?

    Yes but again with Rust it’s bikeshedding. Websites with hundreds of millions of users run on php just fine, a high level dynamic language. So why are the complexities of Rust worth it to save like 10ms loading a website? Not that as a language I like php that much due to no typing, but performance for a web app really isn’t that important.

    Rust again isn’t that good for embedded either due to the large binary size. Maybe it would be good for writing a game engine or something very complex but why not just use Godot or something premade

    This argument has happened a few times that I know of. This is done for security purposes. If someone ships a binary blob you have to trust it to run, as a community, it was decided that we shouldnt do this.

    I get where you’re going with this but it’s not scalable. If you have to compile a large app with a lot of moving parts compiling everything from scratch wears out the CPU and takes forever. This is why oses just ship binaries for most things.

    This can also be solved with a file hash. When you compile the app, ensure the compiled file hash matches the hash of the binary in cargo. So you can get the best of both worlds

    No one is required to like every programming language, If you don’t like rust, stop using it.

    Yes but the fact is rust is growing immensely in popularity so I made this post to understand what exactly I’m missing about it