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.
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.
(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 aboutlong
. 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.
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.
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.
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
(…) rust, since js is much higher level. you should be comparing it with c, c++, zig, maybe nim, etc
Obvious troll.
what