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.

  • orclev@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    14 days ago

    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.

    Somewhat agreed, but it’s a very difficult problem to solve. No language has yet come up with the perfect build tool. JS is on what, like the 12th build tool in as many years now? Some serious throwing stones in glass houses vibes here.

    Syntax is very confusing for no reason. You can’t just look at rust code and immediately know what it does.

    Strongly disagree on this point. Those extra glyphs in Rust are not just cosmetic, each one means something very specific and conveys very important information.

    Having to pollute your code &, ? and .clone() everywhere to deal with ownership

    You don’t “deal with” ownership, it’s an incredibly powerful tool you use. This just sounds like you haven’t really understood what the borrow checker is actually doing and the hundreds of problems it solves for you. I can not count how many times now I’ve been working in another language and had the thought “I could solve this with the borrow checker”

    Js is way more readable.

    JS is not more readable, JS is just far less detailed. It omits a vast swath of information such that you have almost no idea what it’s actually doing. It feels easier to you because you don’t care about any of the details, but those details become vitally important when things stop working and you’re trying to figure out why. This sounds to me like you’ve never had to write any actually complicated code. If all you’re trying to do is chain together a series of HTTP calls and maybe parse a tiny bit of JSON, yeah, Rust is like using a nuke to kill an ant.

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

    A little bit, but mostly because doing async right is really complicated. Once again no language has a really great solution to this problem yet, they all involve tradeoffs.

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

    Once again it seems you don’t really understand the difference between owned and borrowed values or stack vs. heap allocation and why it matters. Really there’s only one type of String which is String, the others are just different ways of borrowing a String (with different tradeoffs).

    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

    If all you want is a “int” you can just use i64 for everything and “be done with it” as you say, you’ll just be adding a ton of wasted memory and needless overhead for no good reason. Seems like you just don’t like strong typing. I’m surprised you even bother with TypeScript instead of just using JavaScript.

    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.

    You absolutely can write code without using #[tokio:main], you can even use tokio without that, it just saves you having to write a bunch of boilerplate to initialize tokios executer and pass your async functions to it. You can even use async functions without tokio, you just need to provide your own executor. Async in Rust is still pretty new and some of the rough edges are still being worked out, it will get smoother, but honestly the things you’re complaining about aren’t even the annoying parts about 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.

    I have no idea what you’re doing to generate code sizes like that, but I guarantee you could get a significantly smaller program in Rust that does exactly what the C code is doing. As for embedded this is patently false. I personally use Rust regularly on embedded devices that don’t even have 32mb of RAM on them.

    With cargo you literally have to compile everything instead of them shipping proper binaries. Why???

    This isn’t a cargo thing, this is a Rust compiler thing. The Rust ABI hasn’t been standardized which means currently there’s no guarantee that Rust code compiled by one version of the compiler can successfully link against code compiled by a different version. Until not that long ago C++ actually had the same problem. This will eventually get fixed, but the language team feels things are still moving too fast to define a concrete standard yet.

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

    Rust is still pretty new, so a lot of libraries are still in active development, but there are already many excellent and very well documented libraries. Axum is literally one of the newest web frameworks in Rust and didn’t even exist that long ago. I’ve seen far worse documentation for JS libraries (and don’t even mention C, the gold standard there is practically a man page that’s just a glorified header file).

    As for “memory safety”, it’s a buzzword. Just use a garbage collector.

    Memory safety is not “just a buzzword”, there’s a reason all the top vulnerabilities for decades now are all memory safety issues. As for a garbage collector, good luck with that when writing embedded software or a kernel.

    The rest of your rant basically boils down to “my particular simple use case doesn’t see much value from what Rust provides”, which is fine. If you don’t need the power of Rust, use something weaker, not every problem needs the nuclear option, sometimes you just need something quick and dirty that will run a few times before it falls over. Hell, sometimes a quick Perl script is the right solution. I mean, not often, but it does sometimes happen. When you do find a problem that your quick and dirty approach isn’t working on then you’ll see the value in Rust.

  • calcopiritus@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    12 days ago

    This entire post is so ignorant it can be summed up in a one paragraph analogy:

    “Why do everyone love screwdrivers so much? I drove in nails perfectly with my hammer, but the screwdrivers are so bad at it! Who even designed them? What a horrible design!”

  • little_ferris@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    8 days ago

    All your arguments can be applied when comparing ts to js. You can just use the succinct and readable js. Why waste time dealing with this type is implicitly any?

    Get things done with js and chill.

  • BatmanAoD@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    13 days ago

    … the issue I have is people lying and saying Rust is a drop in replacement for js

    I am genuinely curious whether you’ve actually seen this claim before, or if you badly misunderstood or are simply exaggerating a claim about Rust being a good language for web servers, or if you simply made this up as a straw-man. I can’t imagine anyone who knows what they’re talking about using those words I that order.

    • kersplomp@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      12 days ago

      In OP’s defense I have heard this said unironically by several engineers at my last job.

      “Rust is going to replace JavaScript thanks to webassembly, so we should be moving all of our code to that.”

      “Our client should be in the same language as our backend, just like in GWT”

    • Doom4535@lemmy.sdf.org
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      13 days ago

      Honestly, this is maybe the most telling about where OP is coming from… If not straight up flame baiting; that or they mistook /r/rustcirclejerk as a serious subreddit

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    14 days ago

    Rust syntax is badly designed compared to most other languages I used

    It really isn’t badly designed. Yeah there are more symbols than you are used to from JS/Typescript world. But more symbols does not mean bad syntax. It makes things more explicit which IMO makes things easier to read and understand what is going on. Rather than all the implicit behavior in JS/TS.

    Let’s take a look at hashmaps vs json

    What is the point of this? Lets compare two different things to prove no point! Look I can do it to:

    let person = Person {
      name: "joe".to_string(),
      age: 23
    }
    
    const scores = new Map();
    
    scores.set('Name', Joe);
    scores.set('Age', 23);
    
    

    Why would you construct a map like this? That is not what maps are for in either JS or rust. But either way all these examples are easy to read and can tell what they are doing even if you have not coded the language before. Now you do need more of an understanding of rust code to read some rust code but not these examples given.

    Every single library in rust is half-baked.

    That is just hyperbole. Many rust libraries are very mature now. Not having a website is not a sign of maturity and the docs for axum are very good in rust docs site. If you really want a webserver with a website then you have actix-web. Many rust projects do have sites like this or even books on how to use them. And if you look at the JS ecosystem, how many libraries do you use there that have nothing more then a readme on their github page? IMO I tend to find far worst documentation for JS libraries then I do for rust ones - if you look beyond the big things like react.

    No GUI framework is as stable as something like Qt or GTK

    This is true of basically all languages but C/C++ and maybe JS. Most languages just lean on these for good UIs, but there is a lot of effort ATM in getting nicer GUI support in native rust. It will come with time but a GUI library is a complex thing to make.

    literally every rust project has like 1 dev maintaining it in his free time and has “expect breaking changes” in the readme

    This is just more untrue hyperbole.

    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.

    One of the things I love about rust is I don’t need to spend hours and hours debugging basic problems because the language is explicit and makes me think better about things upfront. Rather then spending hours wondering why something is producing weird output at runtime because something somewhere else got a "1" instead of a 1. It takes a bit more effort to get something to compile, but I find vastly fewer surprises at runtime then I do in other languages. And it is those runtime bugs that take the most amount of time to solve.

    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

    You also don’t want things to break in production and have to spend hours and hours debugging some weird edge case.

  • lolcatnip@reddthat.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    14 days ago

    Then use C or C++ if you really need performance.

    And that’s where I stopped. I’m a real working programmer who’s done tons of work in C++, so I know firsthand that it absolutely sucks compared to Rust. Go back to Typescript if you hate Rust so much.

  • kersplomp@programming.dev
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    edit-2
    12 days ago

    Even though most of the specifics you point to are wrong, it’s a good point overall:

    Rust, being #1, should be better than all other languages. The fact that it’s just decent makes it seem overhyped, and all the downvotes on haters make it look like a cult.

    Back when it was small, the cult-like following was OK. But now that the language is becoming more mainstream I think the Rust evangelizers need to tone it down a bit or they risk pushing people away.

    On your point, TypeScript is a decent language too. There can be two good things.

  • beeb@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    12 days ago

    OP: “typescript is easy and rust is ugly”

    Typescript :

    export type PayloadActionCreator<
      P = void,
      T extends string = string,
      PA extends PrepareAction<P> | void = void
    > = IfPrepareActionMethodProvided<
      PA,
      _ActionCreatorWithPreparedPayload<PA, T>,
      // else
      IsAny<
        P,
        ActionCreatorWithPayload<any, T>,
        IsUnknownOrNonInferrable<
          P,
          ActionCreatorWithNonInferrablePayload<T>,
          // else
          IfVoid<
            P,
            ActionCreatorWithoutPayload<T>,
            // else
            IfMaybeUndefined<
              P,
              ActionCreatorWithOptionalPayload<P, T>,
              // else
              ActionCreatorWithPayload<P, T>
            >
          >
        >
      >
    >
    
    • kersplomp@programming.dev
      link
      fedilink
      arrow-up
      0
      ·
      12 days ago

      Did you inline all those types just to make it ugly? Normally each of those subtypes would have been in a separate typedef, each with documentation.

  • orizuru@mastodon.world
    link
    fedilink
    arrow-up
    1
    ·
    14 days ago

    @cybergazer
    > Syntax is very confusing for no reason.

    This comment alone (followed by your examples) tells me you don’t understand what problems Rust is trying to solve.

    • cybergazer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      14 days ago

      What is it trying to solve?

      I’ve seen a lot about how it solves “memory safety” but it’s not an issue if you use a garbage collector which is perfectly suitable unless you write low level embedded systems or oses, and even if you use something like C or C++ where you manually allocate or deallocate, if the app is properly tested memory issues won’t happen.

        • cybergazer@sh.itjust.worksOP
          link
          fedilink
          arrow-up
          0
          arrow-down
          1
          ·
          13 days ago

          That sounds like they’re not testing their app properly then. If they don’t test every scenario then yeah there’s gonna be issues. Plus doesn’t Android use the JVM?

      • orclev@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        14 days ago

        if you use a garbage collector which is perfectly suitable unless you write low level embedded systems or oses

        Or games, or realtime systems, or high reliability/mission critical systems, or high performace systems. There’s a long list of programs that GC isn’t suitable for for one reason or another.

        and even if you use something like C or C++ where you manually allocate or deallocate, if the app is properly tested memory issues won’t happen.

        There’s about four decades of security vulnerabilities in extensively tested and widely used software that says this is absolutely false.

    • cybergazer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      13 days ago

      It’s still less intuitive though, like someone looking at it doesn’t know what a hashmap or String::from is and it’s more code for the same thing. Once you start getting into Futures and Generics that’s where the real unreadability starts

  • ExperimentalGuy@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    14 days ago

    I think one thing to mention is that Rust is highly specific in what it does. In most of the examples you mentioned, string types, tokio::main, you can essentially just say that rust is more explicit. When initializing an integer variable in C using int, it’s not specified what use the integer is or whether it’s signed or not. i32, uint16_t you can see how it’s specified. Using tokio::main before your main function just specifies that you’re using the tokio asynchronous executor for your async code. In the case of string types, they all have different implementations which just help with being specific.

    The reason I like Rust is because I know what’s happening when I read it. Did I have to read the whole async book to understand how the tokio::main stuff works? Yes. But now I understand exactly how it works. The problem I have with using Javascript is that it doesn’t have that high amount of explicitness(is that a word?). At the end of the day, if you’re using it for a personal project or you’re arguing for language supremacy, it really just comes down to personal preference.

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    1
    ·
    14 days ago

    You have to keep in mind, when you write JavaScript, there’s an entire runtime written in C++ to run it under the hood, with some crazy optimizations to make it reasonably performant. What type of languages do you use to write that runtime? A systems programming language like Rust and C++.

    You don’t have to use Rust if you don’t like it. Not everything must be written in Rust. The whole pick a language also involves a lot of picking your tradeoffs. Picking a interpreted/JIT language for speed of development is a perfectly valid tradeoff, but not one you can universally make. Sometimes the performance cost becomes really expensive currency-wise, where you can save thousands of dollars on server costs by simply having a more efficient application that only needs a fraction of the hardware to run it. Even in JavaScript, a fair chunk of libraries you use end up calling to C++ native code because it would be too slow in pure JavaScript. Sometimes the tradeoff is pick the popular language so it’s easier to hire for cheaper.

    Even at the dawn of time, most computers shipped with a variant of BASIC so people could write simple applications easily. But if you wanted to squeeze out every bit of power in your Apple II or C64, you sure did reach for assembly. Assembly sucks so we made C, then C++. Rust is still a language that’s made to eventually compile to assembly/binary and have the same performance as if you wrote it in assembly.

    And low spec hardware still exists: the regular Pis have gotten pretty fast but if you run on an RP2040 then suddenly, you’re back in like 300MHz dual core land with pitiful amounts of memory, so you do need to write optimized and fast code for those.

    Rust’s type system is actually really, really good. Most of the time, if it compiles it runs. It eliminates a ton of errors other than memory safety: the system is so powerful you can straight up make invalid state unrepresentable. You can’t forget to close a connection, you can’t pass the wrong data, you can’t forget to unlock a lock. It does a lot more to enforce correctness of a program well beyond memory safety.

  • onlinepersona@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    13 days ago

    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?

    This is pure junior energy. Or trolling, I honestly can’t tell.

    Anti Commercial-AI license

      • onlinepersona@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        13 days ago

        Your post is nearly the epitome of Chesterton’s Fence. You don’t seem to understand why Rust looks the way it does, works the way it does, why it exists, what it’s used for, and what problems it solves, but you’re very happy (or not, which is probably why you wrote this post) to trash it.

        There are many responses to your comments that explain things quite well, yet, from what I see, you do not seem to concentrate on those.

        And what I quoted is just the icing on top. It looks very much like you have one style of programming and approaching problems (the PHP style of “if it runs, it’s good”) and apply it to every problem. You have used a hammer your whole life and every problem looks like a nail. You can build a good many things with duct tape, nails, and a hammer. It might all do the job well enough for your standards or purposes and at times it might even be the perfect tool for a task.
        But now you’ve discovered a screw driver, tried to hammer in a nail, and gotten quite frustrated that it didn’t work well. Instead of considering using a screw, you have tossed aside the screwdriver and decided to yell expletives into the ether.

        The ether has responded with explanations, but you have chosen to ignore them all and staunchly hold on to your “screwdrivers are shit” conclusion. Had you said “I’m just blowing off steam, don’t take this seriously”, that’s what it would’ve been. However, you seem quite serious. Or, as I said before, you’re just trolling.

        Anti Commercial-AI license

  • bamboo@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    14 days ago

    Cargo being an all-in-one tool is actually one of my favorite things about the rust ecosystem. It’s many things, and it does it all seamlessly.

    Regarding comparing to C or C++, how can you argue either is designed better? C, while standing the test of time, predates so many modern programming concepts or standards and writing C code is extremely error prone. C++ improves on many of C’s shortfalls, but it wasn’t designed. It’s the result of different things being loosely bolted on to C over the course of 30 years. And it’s still error prone, for example while there are smart pointers and other types that can make writing memory safe code possible, they’re not default and they aren’t always fully supported in the standard library, let alone anything else.

    • cybergazer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      0
      arrow-down
      2
      ·
      14 days ago

      What I mean is that Rust has overly verbose and often confusing syntax. It’s difficult to look at the code and know what it does without having a ton of prior knowledge about how Rust’s syntax works, so there’s a massive upfront learning cost mostly due to syntax quirks

      • bamboo@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        13 days ago

        I’ll be honest if that’s your complaint, I have a hard time believing you would find the equivalent C or C++ code to be better.