-47

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.

top 50 comments
sorted by: hot top controversial new old
[-] little_ferris@programming.dev 1 points 2 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.

[-] calcopiritus@lemmy.world 14 points 6 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!"

[-] onlinepersona@programming.dev 13 points 6 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

[-] lysdexic@programming.dev 1 points 4 days ago

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

OP makes a valid point, and a strong one to boot.

Other than name calling, do you have anything to add?

[-] cybergazer@sh.itjust.works -4 points 6 days ago

But is there an actual counterargument to my point though other than just calling me a junior?

[-] onlinepersona@programming.dev 15 points 6 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

[-] beeb@lemm.ee 7 points 6 days ago* (last edited 6 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 2 points 5 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.

[-] beeb@lemm.ee 2 points 5 days ago

Literally copy pasted from a random repo as an illustration

[-] kersplomp@programming.dev 2 points 5 days ago

Well there's your problem :P every language has bad code examples

[-] beeb@lemm.ee 1 points 3 days ago

That was my point exactly :) glad you got it

[-] samus7070@programming.dev 14 points 6 days ago

If your primary exposure to programming is only typescript or JavaScript maybe you shouldn’t be jumping straight into something like rust. JS is a high level language and rust is aimed at the lower levels where things can’t be as automatic. There are many languages out there like C#, Kotlin and Swift that will help you get used to the idea of strong types and immutability.

[-] lysdexic@programming.dev 2 points 3 days ago

If your primary exposure to programming is only typescript or JavaScript maybe you shouldn’t be jumping straight into something like rust.

That completely contradicts any claim that Rust is user-friendly and provides a decent user experience.

[-] JackbyDev@programming.dev 11 points 6 days ago
[-] kersplomp@programming.dev 5 points 5 days ago* (last edited 5 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.

[-] AsudoxDev@programming.dev 1 points 4 days ago

Welcome to compiled systems programming languages? What'd you expect?

[-] GetOffMyLan@programming.dev 5 points 6 days ago* (last edited 6 days ago)

That example is so insanely readable lol

Absolutely standard looking code for many languages.

[-] cybergazer@sh.itjust.works -2 points 6 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

[-] GetOffMyLan@programming.dev 7 points 6 days ago* (last edited 6 days 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.

[-] AVincentInSpace@pawb.social -1 points 5 days ago* (last edited 5 days ago)

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?

You're kidding, right? You do actually understand that languages that aren't JavaScript don't have built in async runtimes and they need to be provided by a library, right? You're not actually writing a post about how much the programming language you have two days experience in made different design decisions and is therefore good at different things than the programming language you have five years experience in and therefore it sucks, right?

There are plenty of slimmer async runtimes for Rust. Pollster comes to mind, although it doesn't provide any I/O functionality. (That's where the "bloat" that's in Tokio comes from -- it's providing functionality the Javascript runtime has built in. You see, Rust, unlike Typescript and Java that have compilers that emit source code for an interpreter, is actually a compiled language, and Rust programs compile to self-contained executables that don't need any external dependencies to run. If you included the size of the node binary in your Javascript app, Rust would win the filesize war no contest.)

As for "performance doesn't matter" -- I'd like to tell you a personal story about a Rust program I'm working on. There's an imageboard I'm a fan of, and it runs some booru-like software, meaning when you upload an image you give it a few dozen tags, and then people can search for images by their tags. The tag search functionality on the website I thought was missing a few features, so I downloaded a copy of the entire post database on that site (including URLs and tag lists of every post) and wrote my own search algorithm in Rust. I wrote a function that accepts a search query and a list of tags and returns a boolean, and searching the posts was as simple as vec_of_posts.iter().filter(|post| matches(search_query, post)).collect(). I then downloaded the rayon crate, and, with a sngle line change to vec_of_posts.par_iter().filter(|post matches(search_query, post).collect(), I was running the search in parallel on all CPU cores. Running a full search of all four million posts takes about 50 milliseconds on my laptop, or 3 seconds running the search locally on an Android phone. Try that in an interpreted language.

(So help me God, if you respond to that last point by saying "cloud computing", I am going to shoot you in the head.)

[-] lysdexic@programming.dev 0 points 4 days ago

You do actually understand that languages that aren’t JavaScript don’t have built in async runtimes and they need to be provided by a library, right?

How do you explain C#?

[-] AVincentInSpace@pawb.social 1 points 4 days ago

please tell me your argument is not "other language also does this thing, therefore it's dumb for rust to not do it"

load more comments
view more: next ›
this post was submitted on 10 Oct 2024
-47 points (30.6% liked)

Rust

5876 readers
117 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS