I’m making this post after endless frustrations with learning Rust and am about to just go back to TypeScript. Looking at Rust from the outside, you’d think it was the greatest thing ever created. Everyone loves this language to a point of being a literal cult and its popularity is skyrocketing. It’s the most loved language on Stackoverflow for years on end. Yet I can’t stand working in it, it gets in my way all the time for pointless reasons mostly due to bad ergonomics of the language. Below are most of the issues I’ve encountered:

  • Cargo is doing too many things at once. It’s a build system but also a package manager but also manages dependencies? Idk what to even call it.

  • Syntax is very confusing for no reason. You can’t just look at rust code and immediately know what it does. Having to pollute your code &, ? and .clone() everywhere to deal with ownership, using :: to refer to static methods instead of a “static” keyword. Rust syntax is badly designed compared to most other languages I used. In a massive codebase with tons of functions and moving parts this is unreadable. Let’s take a look at hashmaps vs json

let mut scores = HashMap::new();
scores.insert(String::from("Name"), Joe);
scores.insert(String::from("Age"), 23);

Supposively bad typescript

const person = {
  name: "joe",
  age: 23
}

Js is way more readable. You can just look at it and immediately know what the code is doing even if you’ve never coded before. That’s good design, so why do people love rust and dislike typescript then?

  • Similarly, Async code starts to look really ugly and overengineered in rust.

  • Multiple string types like &str, String, str, instead of just one “str” function

  • i32 i64 i8 f8 f16 f32 instead of a single unified “number” type like in typescript. Even in C you can just write “int” and be done with it so it’s not really a “low level” issue.

  • Having to use #[tokio:main] to make the main function async (which should just be inbuilt functionality, btw tokio adds insane bloat to your program) yet you literally can’t write code without it. Also what’s the point of making the main function async other than 3rd party libraries requiring it?

  • Speaking of bloat, a basic get request in a low level language shouldn’t be 32mb, it’s around 16kb with C and libcurl, despite the C program being more lines of code. Why is it so bloated? This makes using rust for serious embedded systems unfeasible and C a much better option.

  • With cargo you literally have to compile everything instead of them shipping proper binaries. Why??? This is just a way to fry your cpu and makes larger libraries impossible to write. It should be on the part of the maintainer to build the package beforehand and add the binary. Note that i don’t mean dependencies, I mean scripts with cargo install. There is no reason a script shouldn’t be compiled beforehand.

Another major issue I’ve encountered is libraries in Rust, or lack thereof. Every single library in rust is half-baked. Axum doesn’t even have a home page and its docs are literally a readme file in cargo, how’s that gonna compare to express or dotnet with serious industry backing? If you write an entire codebase in Axum and then the 1 dev maintaining it decides to quit due to no funding then what do you do? No GUI framework is as stable as something like Qt or GTK, literally every rust project has like 1 dev maintaining it in his free time and has “expect breaking changes” in the readme. Nothing is stable or enterprise ready with a serious team with money backing it.

As for “memory safety”, it’s a buzzword. Just use a garbage collector. They’re invulnerable to memory issues unless you write infinite while loop and suitable for 99% of applications.

“But muh performance, garbage collectors are slow!”

Then use C or C++ if you really need performance. Both of them are way better designed than Rust. In most cases though it’s just bikeshedding. We’re not in 1997 where we have 10mb of ram to work with, 9/10 times you don’t need to put yourself through hell to save a few megabyes of a bundle size of a web app. There are apps with billions of users that run fine on php. Also, any program you write should be extensively tested before release, so you’d catch those memory errors if you aren’t being lazy and shipping broken software to the public. So literally, what is the point of Rust?

From the outside looking in, Rust is the most overwhelming proof possible to me that programmers are inheritly hobbists who like tinkering rather than actually making real world apps that solve problems. Because it’s a hard language, it’s complicated and it’s got one frivelous thing it can market “memory safety!”, and if you master it you’re better than everyone else because you learned something hard, and that’s enough for the entire programming space to rank it year after year the greatest language while rewriting minimal c programs in rust quadrupling the memory usage of them. And the thing is, that’s fine, the issue I have is people lying and saying Rust is a drop in replacement for js and is the single greatest language ever created, like come on it’s not. Its syntax and poor 3rd party library support prove that better than I ever can

“Oh but in rust you learn more about computers/low level concepts, you’re just not good at coding”

Who cares? Coding is a tool to get shit done and I think devs forget this way too often, like if one works easier than the other why does learning lower level stuff matter? It’s useless knowledge unless you specifically go into a field where you need lower level coding. Typescript is easy, rust is not. Typescript is therefore better at making things quick, the resourse usage doesn’t matter to 99% of people and the apps look good and function good.

So at this point I’m seeing very little reason to continue. I shouldn’t have to fight a programming language, mostly for issues that are caused by lack of financial backing in 3rd party libraries or badly designed syntax and I’m about to just give up and move on, but I’m in the minority here. Apparently everyone loves dealing with hours and hours of debugging basic problems because it makes you a better programmer, or there’s some information I’m just missing. Imo tho think rust devs need to understand there’s serious value in actually making things with code, the ergonomics/good clean design of the language, and having serious 3rd party support/widespread usage of libraries. When you’re running a company you don’t have time to mess around with syntax quirks, you need thinks done, stable and out the door and I just don’t see that happening with Rust.

If anyone makes a serious comment/counterargument to any of my claims here I will respond to it.

  • Solemarc@lemmy.world
    link
    fedilink
    arrow-up
    27
    arrow-down
    1
    ·
    edit-2
    1 month ago

    Ok, I’m going to just assume this isn’t a troll.

    Cargo is doing too many things at once. It’s a build system but also a package manager but also manages dependencies? Idk what to even call it.

    I dont even understand your issue? It’s like npm or deno which can run your code, manage your dependencies, etc. How can a JS/TS dev possibly not understand this?

    Syntax is very confusing for no reason. You can’t just look at rust code and immediately know what it does. Having to pollute your code &, ? and .clone() everywhere to deal with ownership, using :: to refer to static methods instead of a “static” keyword. Rust syntax is badly designed compared to most other languages I used. In a massive codebase with tons of functions and moving parts this is unreadable.

    I dislike ? because I think you should be handling errors as they come instead of sending them up the stack. I also like the explicit .clone() but if you dont want to use it, you can also add Copy to your derive’s and this will make it happen automatically. module::function() generally pollutes code much less then static module.function() or static function() doesn’t it?

    Let’s take a look at hashmaps vs json

    I hate all of this code, why arent you using struct’s here? In rust its: struct Person {name String, age i32} and in typescript its type Person = {name: string age: number}

    Similarly, Async code starts to look really ugly and overengineered in rust.

    Sure

    Multiple string types like &str, String, str, instead of just one “str” function

    I know of &str and String, i’ve never heard of str though so you probably dont need it. &str is a string slice, aka a borrowed String. I generally say you shouldnt be using &str because generally if you get a lifetime error from using it, its because you’re doing it wrong, just use String while you’re learning the only real difference is that String is more verbose then ""

    i32 i64 i8 f8 f16 f32 instead of a single unified “number” type like in typescript. Even in C you can just write “int” and be done with it so it’s not really a “low level” issue.

    “int” from C is i32, these are int’s and float’s of various bit sizes. i32 = int 32bit, i62 = int 64 bit, f32 = float 32, u32 = unsigned (only positive) int32. but you dont usually need to specify this, rust has type inference. Also speaking of C, what about double, long, short, long long, unsigned long long, unsigned short…

    Having to use #[tokio:main] to make the main function async (which should just be inbuilt functionality, btw tokio adds insane bloat to your program) yet you literally can’t write code without it. Also what’s the point of making the main function async other than 3rd party libraries requiring it?

    I kind of agree? When async was initially designed it was done as a stackless minimal thing where we could build our own runners (like tokio) but no one really builds their own runners, they just use tokio.

    Speaking of bloat, a basic get request in a low level language shouldn’t be 32mb, it’s around 16kb with C and libcurl, despite the C program being more lines of code. Why is it so bloated? This makes using rust for serious embedded systems unfeasible and C a much better option.

    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.

    With cargo you literally have to compile everything instead of them shipping proper binaries. Why??? This is just a way to fry your cpu and makes larger libraries impossible to write. It should be on the part of the maintainer to build the package beforehand and add the binary. Note that i don’t mean dependencies, I mean scripts with cargo install. There is no reason a script shouldn’t be compiled beforehand.

    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.

    Another major issue I’ve encountered is libraries in Rust, or lack thereof. Every single library in rust is half-baked.

    I kinda also agree with this one, a lot of rust libraries are still in 0.x, I wouldnt call them all “half baked” though. If you search youtube you can find plenty of people using these libraries in prod.

    “expect breaking changes” in the readme.

    This is not specifically a rust problem this happens with every popular language & framework.

    As for “memory safety”, it’s a buzzword. Just use a garbage collector. They’re invulnerable to memory issues unless you write infinite while loop and suitable for 99% of applications.

    A garbage collector “freezes” you’re program when it runs usually. There are plenty of cases of people benchmarking rust against go, js, c#, java, etc rust performs vastly better.

    Then use C or C++ if you really need performance. Both of them are way better designed than Rust.

    Microsoft and Google came out and said that “~70% of their security flaws are a result of memory issues” or something like that. C and C++ are fundamentally flawed, which is why both of those companies have adopted rust.

    There are apps with billions of users that run fine on php

    True, but the number is going down, which implies a growing number of people choose to stop using PHP, we’re even doing it at work.

    Rust is the most overwhelming proof possible to me that programmers are inheritly hobbists who like tinkering rather than actually making real world apps that solve problems

    These are fighting words lol. I already mentioned Google and Microsoft have adopted rust for Windows, Chrome and Android. Other companies solving real world problems with rust include, Cloudflare, Dropbox, NPM, Yelp, Discord, Mozilla, Coursera, Figma, Facebook/Meta and Amazon.

    Typescript is easy, rust is not. Typescript is therefore better at making things quick, the resourse usage doesn’t matter to 99% of people and the apps look good and function good.

    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?

    So at this point I’m seeing very little reason to continue. I shouldn’t have to fight a programming language

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

    • Flipper
      link
      fedilink
      arrow-up
      3
      ·
      1 month ago

      I mostly agree with you, just two nitpicks.

      Int is either i16 or i32 in C/C++.

      The async runtime in embedded is mostly embassy from what I can tell. It makes different tradeoffs and is a lot smaller but can only run on one core. It also takes care to put the core to sleep when there is nothing to execute.

    • cybergazer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      6
      ·
      1 month ago

      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

      • Solemarc@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        1 month ago

        This is because rust doesn’t do proper tree shaking of code and bundles everything into it even if it’s not necessary.

        This isn’t true. a simple:fn main() { println!("Hello World!); } compiles into the same size binary as:

        fn main() { println!(hello_world()); }

        fn hello_world() -> String { String::from("Hello World!") }

        fn another_function() -> String { String::from("Completely unused function") }

        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.

        if the amount of rust, c and c++ in web infrastructure doesnt convince you that performance is important then I guess we’ll have to agree to disagree here.

        Rust again isn’t that good for embedded either due to the large binary size

        I’m not sure about this one, I’ve never worked on embedded but I’m not convinced. There’s an embedded rust book and their target hardware is a device with 256kb of flash memory, and 48kb of RAM.

        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

        This doesn’t address security at all, the only thing a hash does is tell you that the file you download was the file that was uploaded. If I upload malware in my library to cargo, cargo generates a hash for my library, then you download my library. The only thing the hash tells you is that you did indeed download my malware. It’s also harder to audit my library because cargo has a binary blob instead of my code, you have to go to my repo in order to find the malware, and you better hope I haven’t done something clever like add the malware in locally instead of in the repo, so it’s only there when I build to upload to cargo.