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.
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.
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.
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 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.
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.
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).
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.
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.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.
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.
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).
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.