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.
(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)
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.
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.Pop quiz: Is this a copy or a reference?
let a = b;
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â.
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.
JavaScript has three number types, ints, floats and BigInts. The former two are both called ânumberâ.
No you canât.
int
is different sizes on different platforms. (EDIT: I was thinking aboutlong
. If you need more than 32 bits (which you do to store a pointer), thatâs where the problem lies)Iâve never actually used Tokio. :D
Are you compiling at the same optimisation level, stripping debug info and statically linking libcurl in both cases?
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.
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.
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.
True. But nobody does that. And even if they did⊠Why not use a language that makes testing easier and faster?
Not in any sufficiently large codebase.
If you find that everyone in the world except you seems to be involved in some elaborate conspiracy, please check your reasoning.
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.
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.
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.
The way you parrot undefined behavior is a telltale sign you do not work with either C or C++. If you had any cursory first-hand professional experience with either one of those languages, youâd understand what UB is, why writing your code by laying unfounded expectations on UB is actually either a bug or design error on your behalf, youâd know that for a decade or so there are tooling that throws warnings and errors if you inadvertently use it, and above all UB only means frameworks are ultimately responsible to specify the behavior that is left purposely undefined.