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.

  • beeb@lemm.ee
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    2 hours 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>
            >
          >
        >
      >
    >
    
  • calcopiritus@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    3 hours 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!”

  • Solemarc@lemmy.world
    link
    fedilink
    arrow-up
    23
    arrow-down
    1
    ·
    edit-2
    1 day 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.

        • nous@programming.dev
          link
          fedilink
          English
          arrow-up
          2
          ·
          4 hours ago

          I thought they both had to stop the world at some point. And the advancements were about running more of the GC steps in the background to minimize the time needed in the stop the world phase.

          • Solemarc@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            3 hours ago

            Just looked it up, looks like you’re right. The Go GC has to pause when it sweeps and it looks like the JVM has multiple GC implementations but all of them have to pause for sweeps. I don’t really use either language so I didn’t know how the magic worked.

    • Flipper@feddit.org
      link
      fedilink
      arrow-up
      3
      ·
      18 hours 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
      4
      ·
      16 hours 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
        3
        ·
        edit-2
        14 hours 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.

    • cybergazer@sh.itjust.worksOP
      link
      fedilink
      arrow-up
      1
      arrow-down
      3
      ·
      17 hours 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

      • GetOffMyLan@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        16 hours ago

        Tbh as an experienced programmer I knew exactly what it was straight away. And I don’t know rust. I would imagine the others are similar.

        The reason that example is simpler is because JSON is literally JavaScript Object Notation.

        It’s also not the same thing. HashMap have type parameters. So you can only add strings to that HashMap whereas you can add anything in js. Does that code even compile?

        You can also do “text”.to_string() which simplifies it more.

        I feel you’re quite inexperienced and once you do more in different languages you’ll begin to realise why things are like this.

        Rust is a compiled language with static typing so these things are required for the compiler to do its job.

        It’s also a performance focused language and would blow ts/js out of the water completely on that metric.

        Languages are just tools and they all have advantages and disadvantages. You use the right tool for the job.

  • orclev@lemmy.world
    link
    fedilink
    arrow-up
    41
    ·
    2 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.

  • SavvyWolf@pawb.social
    link
    fedilink
    English
    arrow-up
    33
    arrow-down
    1
    ·
    edit-2
    1 day ago

    (Wow, 14 posts in 2 hours on Lemmy… The old wisdom that the best way to start a discussion is to loudly complain about something rings true :P)

    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.

    It’s still a build system; most (good) build systems also manage downloading and resolving dependencies. Having them all as part of the same tool makes everything slot together nicely.

    Syntax is very confusing for no reason.

    It’s not no reason; dealing with ownership is a complicated problem. It’s just that most languages tend to hide it and let the programmer tangle themselves in knots.

    You keep talking about it being obvious what the code does but… Using :: over . helps clarify, at the call site, that you are using a “static” function rather than having to make the programmer look up the definition of the lhs.

    Js is way more readable.

    Pop quiz: Is this a copy or a reference?

    let a = b;
    

    You can just look at it and immediately know what the code is doing even if you’ve never coded before.

    You can’t really… The JSON map object syntax isn’t actually intuitive to non-programmers. I’d argue that the rust version is more intuitive, since they can probably make a good guess based on the word “insert”.

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

    These are distinct types with distinct meanings. JS and TS sacrifice some performance to make them seem like the same type, which may or may not be justified in your project.

    i32 i64 i8 f8 f16 f32 instead of a single unified “number” type like in typescript.

    JavaScript has three number types, ints, floats and BigInts. The former two are both called “number”.

    Even in C you can just write “int” and be done with it so it’s not really a “low level” issue.

    No you can’t. int is different sizes on different platforms. (EDIT: I was thinking about long. If you need more than 32 bits (which you do to store a pointer), that’s where the problem lies)

    yet you literally can’t write code without [tokio].

    I’ve never actually used Tokio. :D

    Why is it so bloated?

    Are you compiling at the same optimisation level, stripping debug info and statically linking libcurl in both cases?

    Another major issue I’ve encountered is libraries in Rust, or lack thereof.

    This is a big problem, I agree. Though to be fair, I’ve also encountered it with both NPM and PIP. Perhaps worse so there, because the compiler isn’t backwards compatible.

    They’re invulnerable to memory issues unless you write infinite while loop and suitable for 99% of applications.

    No they aren’t~ It’s easy to write code that hitches every few seconds (which kills games). And you also overlook the fact that a garbage collector is, quite frankly, a miracle of optimising compilers. I remember back in university being warned to remove the “next” pointer of graph nodes because otherwise memory would leak.

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

    I develop professionally in C and C++. No they aren’t. At all. C and C++ are so loaded with footguns it’s a surprise people can get anything done in them without triggering UB.

    Also, any program you write should be extensively tested before release

    True. But nobody does that. And even if they did… Why not use a language that makes testing easier and faster?

    you’d catch those memory errors if you aren’t being lazy

    Not in any sufficiently large codebase.

    that’s enough for the entire programming space to rank it year after year the greatest language

    If you find that everyone in the world except you seems to be involved in some elaborate conspiracy, please check your reasoning.

    And the thing is, that’s fine, the issue I have is people lying and saying Rust is a drop in replacement for js

    Ehh… I don’t think it is. I think people interested in stepping up their programming game should give it a go, but branding it as a “noob friendly” programming language is going to put people off programming.

    Typescript is therefore better at making things quick

    Thing is, these “quick” programs tend to spiral out into huge megaliths of software that span several servers and support millions of users. And then the only person who knows what everything does gets hit by a bus, and so you have to figure out what thousands of lines of Typescript, PHP and Python code does.

    Python, JS and php are good for firing out quick solutions, but once you get to the point where maintenance starts becoming more important than new features, it falls off hard. There just isn’t enough structure in the language to make it easy to figure out what code is doing.

    I’m about to just give up and move on

    Honestly, I bounced off of Rust the first time I tried it as well. I got frustrated about code not working, and just… Stopped using it. I then tried it again a few years later and everything finally “clicked”. Perhaps it’s the same with you? Give it a break for a bit, but don’t write it off yet. Come back to it later to give it another go.

    Rust isn’t an easy language to wrap your head around if you aren’t familiar with the problems it’s trying to solve, but it’s not trying to be. Think of it as the drill sergeant that makes you stand up straight and become a better programmer.

  • bunitor@lemmy.eco.br
    link
    fedilink
    arrow-up
    31
    ·
    2 days ago

    rust is a systems/low overhead programming language. really not much of a point comparing js/ts and rust, since js is much higher level. you should be comparing it with c, c++, zig, maybe nim, etc

    you also imply it’s pointless to have a language geared towards performance because computers are better now, but 1) programs run on more than just personal computers and you wouldn’t run js in an embedded system and 2) just because your computer can put up with poor performance and resource waste doesn’t mean that it’s sensible to do so (hello electron)

    also, rust does more than just cosmetic improvements. it adds a layer of statically guaranteed memory safety that no other commercially viable programming language that i know of has. even if its syntax looked like ancient eldritch runes, it would still be an attractive language. the fact that it manages to do more than other languages while still having a decent syntax is amazing

    you can dislike rust if you want that’s fine but you don’t need to try to shit on it just bc it’s not your cup of tea

  • SorteKanin@feddit.dk
    link
    fedilink
    arrow-up
    25
    arrow-down
    1
    ·
    2 days ago

    Frankly, all of your points sound quite ignorant. Syntax is literally just a matter of getting used to it. Comparing HashMap ergonomics doesn’t make sense, you should rather compare to struct construction. There are many good reasons for different string types and number types. There are good reasons not to bake in async. Rust documentation is in the code for a very good reason and it’s actually really nice to read docs like that (obviously read it on docs.rs, not in the code itself).

    I could go on but there are answers to all of your specific qualms if you just bothered to look for yourself.

      • snaggen@programming.dev
        link
        fedilink
        arrow-up
        10
        ·
        edit-2
        1 day ago

        Which is kind of surprising, since it basically just is a bunch of “I’m cannot understand why … is needed”, “I cannot learn…” and “I think that is ugly”. And since the OP is coming from TypeScript, and how the OPs understanding of programming, it is clear it is a junior web developer trying rust and failing. Nothing to see here… well, the OP clearly have some kind of grandios ego, thinking that the OPs inability to learn something, must be because it is bad (I mean, there is clearly no other possiblities)… but not even that is worth responding to. And don’t read this wrong, there is plenty to complain about with Rust, however, nothing of that is in OP which is basically just as insightful as a baby crying.

    • FizzyOrange@programming.dev
      link
      fedilink
      arrow-up
      8
      ·
      1 day ago

      LLMs don’t usually make trivial language mistakes like supposively.

      I think this is just a really inexperienced or unskilled developer. Or possibly a very dedicated troll.

  • TaldenNZ@lemmy.nz
    link
    fedilink
    English
    arrow-up
    16
    ·
    1 day 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.

    Coming from Java where you have no standard tool and two current defacto standards (Maven and Gradle) which do similar things in a less clean or standardised way, I think Cargo is one of the least contentious parts of the Rust experience.

    Supposively bad typescript

    Correct. Bad Typescript. You haven’t provided any of the type information to make this a TypeScript construct (this is just JavaScript)

    It should be something like…

    interface Person {
        name: string,
        age: number,
    }
    
    const person: Person = {
      name: "joe",
      age: 23,
    }
    

    And the Rust equivalent being something like

    struct Person {
        name: String,
        age: u8,
    }
    
    let person = Person {
        name: "joe".to_string(),
        age: 23,
    };
    

    i32 i64 i8 f8 f16 f32 instead of a single unified “number” type like in typescript.

    Those all have different sizes and capabilities. The lack of these requires the JS JIT compiler to try and guess (and deoptimise when it’s wrong).

    Even in C you can just write “int” and be done with it so it’s not really a “low level” issue.

    No, you can’t - https://en.wikipedia.org/wiki/C_data_types

    • Similarly, Async code starts to look really ugly and overengineered in rust.
    • 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 agree the Rust Async experience feels a little messy, and the lack of an opinionated default makes even the foothills a steeper climb than we might hope. However given all that it’s trying to achieve (in terms of Rust drives for efficiency and safety) I don’t have any better ideas right now.

    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 know how you’re getting to 32MB. A release build of the most basic form of a get request is not that bad.

    A simple chatgpt generated one app to get the content of an HTTPS URL, using reqwest and tokio is 4MB. I expect this can be reduced with options.

    However yes, the default Rust build (with all of the panic machinery and more) is bigger than C. But Rust doesn’t have to be the best choice for every niche, to be an excellent choice for several. With that reasoning your return to TypeScript is equally flawed.

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

    Coming from Java, Rust’s young ecosystem is definitely noticeable. It’s taking a while for it to grow, to mature, and for clearly dominant frameworks to emerge for various problem-spaces.

    Java, like Rust, is not opinionated about the frameworks, but the size and age of the community means that clearly dominating frameworks emerge with huge contributor bases - Rust just isn’t quite there yet.

    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.

    Again, coming from Java (which has a number of excellent GC implementations), Rust takes this a lot further (an alternative to null, protection against aliasing bugs). While I’m still fundamentally a Java developer, what Rust achieves here is significant.

    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?

    Tell me you don’t pay to run anything large on cloud infrastructure without telling you don’t pay to run anything large on cloud infrastructure. There’s a cost to CPU and RAM. Java does okay on the first, but has a long history of doing poorly on the second (c’mon Valhalla - a Java enhancement project that will help here).

    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.

    Of your post, this is very nearly the only part I can somewhat agree with. Our industry primarily has more of a need for ‘solution now please’ than ‘optimal solution later’. Engineering time matters. The learning curve and cycle time of Rust are barriers.

    Also, while Rust is a very safe language to refactor in, it’s not quick to refactor in. The less ceremony and strictness there is, the easier it is to experiment and then refactor. This is, in part, why I think Python does so well in the ML/Data-science space - that niche is more R than D in the R&D balance of software development.

    So again, Rust suits some development needs better than others, now. However as it matures I think we will see it grab little pieces of the niches previously occupied by other languages. As it’s tools and libraries get better, and as the pool of familiar developers increases, Rust’s strength are going to translate more easily into dollars without costing time.

     

    I’m not ready to switch to Rust fully. But neither am I putting it aside - and I look forward to its continued improvements in libraries, language, tooling and adoption in more and more places.

    (I can say that I’m not planning on using TypeScript for any more than our front-end development though)

  • nous@programming.dev
    link
    fedilink
    English
    arrow-up
    18
    ·
    2 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.

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    15
    ·
    2 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.

  • orizuru@mastodon.world
    link
    fedilink
    arrow-up
    17
    ·
    2 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
      1
      arrow-down
      14
      ·
      2 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.

      • orclev@lemmy.world
        link
        fedilink
        arrow-up
        18
        ·
        2 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
          1
          arrow-down
          2
          ·
          17 hours ago

          Stuff a solo dev usually isn’t gonna be coding. Plus nowadays if you’re serious about gaming it looks like Godot + Gdscript or C# is the best option, there’s no real point in coding an entire engine nowadays for most games.

        • cybergazer@sh.itjust.worksOP
          link
          fedilink
          arrow-up
          1
          arrow-down
          2
          ·
          17 hours 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?

          • Doom4535@lemmy.sdf.org
            link
            fedilink
            arrow-up
            1
            ·
            10 hours ago

            They could then potentially end up spending more time testing every possible combination of input then they would spending compiling with a strongly typed language that prevents the invalid syntax from compiling to begin with…