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

(page 2) 48 comments
sorted by: hot top controversial new old
[-] ExperimentalGuy@programming.dev 19 points 1 week ago

I think one thing to mention is that Rust is highly specific in what it does. In most of the examples you mentioned, string types, tokio::main, you can essentially just say that rust is more explicit. When initializing an integer variable in C using int, it's not specified what use the integer is or whether it's signed or not. i32, uint16_t you can see how it's specified. Using tokio::main before your main function just specifies that you're using the tokio asynchronous executor for your async code. In the case of string types, they all have different implementations which just help with being specific.

The reason I like Rust is because I know what's happening when I read it. Did I have to read the whole async book to understand how the tokio::main stuff works? Yes. But now I understand exactly how it works. The problem I have with using Javascript is that it doesn't have that high amount of explicitness(is that a word?). At the end of the day, if you're using it for a personal project or you're arguing for language supremacy, it really just comes down to personal preference.

[-] Valmond@lemmy.world -4 points 1 week ago* (last edited 1 week ago)

When is an int not 32bits nowadays, and, seriously, not signed??

I mean on some obscure platform it might be 16 bits, but unsigned??!

Edit: OMG yes there are different sized datatypes I know that lol! Default types are not unsigned 11 bit things though. SMH.

[-] Doom4535@lemmy.sdf.org 15 points 1 week ago* (last edited 1 week ago)

Enter embedded programming, believe it or not there is a ton of low level C code being written; also, try adding a new protocol for networking, there are many cases where bitstructure matters, I recently wrote a small bit of code for a project that used bit packing so that we could fit inside of a single Ethernet frame so that we didn't have to deal with fragmentation and the networking overhead it caused.

For context, what is your past programming background and what are you trying to do? While rust is a great language, it may not be the right tool for what you're trying to do if these are things that you view as unnecessary

[-] Valmond@lemmy.world 0 points 1 week ago

I have done low level dev, and put stuff in wan frames (576 bytes IIRC) and meddling with ethernet frames (1500 bytes), now you tell me where on earth you find a not totally obscure int thats unsigned by default.

That was my statement you know.

For rust, it feels like someone fell in love with c++ template meta programming (you know the ... variadic template and all that) and wanted a better language for that. Good gor them if they like it.

load more comments (1 replies)
[-] bamboo@lemm.ee 10 points 1 week ago

I do systems programming work, sometimes with constrained memory scenarios. We always want to use the smallest types we can for any task, and unless negative numbers are a necessary, always prefer unsigned. That means a lot of u8 and u16 unless we know a value is likely to need more bits to be represented. Probably doesn’t matter as much in we programming but that’s not Rust’s niche (or well not its original niche).

[-] Valmond@lemmy.world 0 points 1 week ago

Well where are those unsigned default 'int' I said doesn't exist, and that everyone seems to not think I'm right about?

Don't get me wrong, unsigned integers are useful, that's why we hate java btw, but it was not really the question.

Also, if you're using like 16 bits ints because you have memory constraints then you are doing it wrong. All modern compilers can handle any kind of bits as long as it's less than the base size, so you can have a 3bit int, another 3bit int and 2 1 bit ints, nicely #packed into a byte. You use the :3 syntax.

[-] bamboo@lemm.ee 2 points 1 week ago

Your default types for that are i32 or u32. It’s the exact same number of characters yet encodes more precise information.

I’m aware of packing, but for my specific niche the main bottleneck is CPU, and it’s important to minimize the amount of memory usage to improve data locality, increasing cache hit rates, ultimately increasing cpu throughout. Any gains we would make by packing such small values would likely be eliminated by the cost of unpacking them, unless it’s a flags-like value where we are primarily comparing individual bits.

[-] Valmond@lemmy.world 0 points 1 week ago

So not default??

For the packing/unpacking, sure it all depends on where you want the cost.

load more comments (1 replies)
[-] taaz@biglemmowski.win 9 points 1 week ago

When is an int not 32bits nowadays

C standard does not actually define the exact sizes of long/int and so on, it's just what is now most popular (it does have some limitations and requirements on these types though)

[-] bamboo@lemm.ee 3 points 1 week ago

It does define minimum sizes for different types. An int for example is at least two bytes, whatever size those might be!

[-] Valmond@lemmy.world 0 points 1 week ago

Duh I know, it's just that it's now the standard that your 'int' is signed, you know as I said 'show me otherwise'. It's also wildly most common 32 bits.

[-] dngrs@chaos.social 3 points 1 week ago
[-] Valmond@lemmy.world 0 points 1 week ago

Thanks!

Is there an "int" to use the default int with?

[-] dngrs@chaos.social 0 points 1 week ago

@Valmond what do you mean by default int? (Either way, probably not; there's usize though)

[-] Valmond@lemmy.world 0 points 1 week ago

Downvote all you want, even tho gs you dont understand lol

In 99% of C/C++ compilers, if you write "int" then it is treated as a signed 32 bit data type. If you want something else you need to specify it. Like unsigned char for example is a non signed 16bit data tupe (again,on 99% of C/C++ compilers). Thus int defaults to a signed 32 bit data type which makes 'int' a default value. I don't know how to better explain that better to a developer. If you don't understand, please do tell.

[-] dngrs@chaos.social 0 points 1 week ago

@Valmond I'm aware of that, but that's for different languages. C/C++ don't get to define if programming in general has a "default int"

[-] Valmond@lemmy.world 0 points 1 week ago

In C/C++ the default int definitely exists, and is a signed 32bit in the most overwhelming cases, what are you talking about?

[-] dngrs@chaos.social 0 points 1 week ago

@Valmond the conversation used to be about Rust. You asked about "default int", a concept from C/C++. I am talking about this not being a *universal* concept. It is specific to those languages.

[-] Valmond@lemmy.world 1 points 1 week ago

You told me the i32 was a default int, which it isn't though, not more than i16, right?

But well the discussion has become a bit sterile I feel.

[-] FizzyOrange@programming.dev 2 points 1 week ago* (last edited 1 week ago)

On Arduino it's 16 bits. (At least the original ATMEL ones; I dunno if they've finally moved to ARM yet.)

This lost me quite a lot of time when I tried to use their SD card library on a 32-bit Arduino and it hung due to some code assuming int was 16 bits.

[-] Valmond@lemmy.world -1 points 1 week ago

Unsigned ?

I mean the nintendo ds math library was 16 bits too, it happens, but unsigned? Never heard of it.

[-] Diva@lemmy.ml 1 points 1 week ago

I use unsigned and fixed point sub-16 bit integers (you can make them almost any size you want) in gateware you can optimize things and one of those is not using a ton of huge numbers to do math when you don't need to.

[-] Valmond@lemmy.world 0 points 1 week ago

Default unsigned?

I think you misunderstood.

[-] Diva@lemmy.ml -2 points 1 week ago

Maybe translation issue? I just meant for fpga work int is 32 signed by default, but it's way more common to use logic variables which are unsigned and arbitrary length (>=1)

[-] Valmond@lemmy.world 0 points 1 week ago* (last edited 1 week ago)

C/C++ compilers. Not FPGA.

Anyways, int is s32 very very very often, that's all my point was. C, gpgpu, c#, java, ...

[-] Diva@lemmy.ml -1 points 1 week ago

Makes sense, I keep hearing people using rust for microcontroller, even had someone telling me that it could be use for fpga code, but I'm skeptical of the utility

[-] Valmond@lemmy.world 2 points 1 week ago

Lets see if it's the new miracle language or not in the coming years :-)

load more comments (1 replies)
[-] orizuru@mastodon.world 18 points 1 week 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.

[-] solrize@lemmy.world 18 points 1 week ago* (last edited 1 week ago)

I'll try to post a longer answer later but Rust is really for systems programming and its choices follow from that. I liked this article:

https://chrisdone.com/posts/rust/

[-] Max_P@lemmy.max-p.me 16 points 1 week 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.

[-] taldennz@lemmy.nz 16 points 1 week 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)

[-] bamboo@lemm.ee 16 points 1 week ago

Cargo being an all-in-one tool is actually one of my favorite things about the rust ecosystem. It’s many things, and it does it all seamlessly.

Regarding comparing to C or C++, how can you argue either is designed better? C, while standing the test of time, predates so many modern programming concepts or standards and writing C code is extremely error prone. C++ improves on many of C’s shortfalls, but it wasn’t designed. It’s the result of different things being loosely bolted on to C over the course of 30 years. And it’s still error prone, for example while there are smart pointers and other types that can make writing memory safe code possible, they’re not default and they aren’t always fully supported in the standard library, let alone anything else.

[-] samus7070@programming.dev 14 points 1 week 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.

load more comments (1 replies)
[-] lolcatnip@reddthat.com 13 points 1 week ago* (last edited 1 week ago)

Then use C or C++ if you really need performance.

And that's where I stopped. I'm a real working programmer who's done tons of work in C++, so I know firsthand that it absolutely sucks compared to Rust. Go back to Typescript if you hate Rust so much.

[-] ProtonBadger@lemmy.ca 9 points 1 week ago

Same, I've done C and C++ for several decades and I've spent too much time of that hunting obscure memory issus triggered by rare race conditions. No matter how hard we try to use safe patterns we are all too human. The most experienced C++ devs I know are the first to admit this.

In Rust once it compiles much less time is spent debugging and a whole big category of bugs are gone from the production code.

And C++ aient pretty but maybe that's subjective.

[-] BB_C@programming.dev 12 points 1 week ago

Your LLM of choice needs better training.

[-] copacetic@discuss.tchncs.de 10 points 1 week ago

Looking at all the responses here, it is a quite successful troll post.

[-] snaggen@programming.dev 11 points 1 week ago* (last edited 1 week 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 8 points 1 week 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.

[-] ericjmorey@programming.dev 11 points 1 week ago

I get the sense that you might appreciate golang.

[-] QaspR@lemmy.world 10 points 1 week ago

I would very much like to address some of these points, since I don't think you are making a good argument here.

I shall preface this by saying that comparing Rust to TypeScript is a bad idea. They are meant for fundamentally different things and you should not regard Rust as a TypeScript replacement. I will do my best to show why Rust took the paths it did whilst being as brief as possible, but if TypeScript is your measuring stick, you should stick to it.

First of all, cargo does a lot of stuff. This is true, but you are comparing Rust to TypeScript here, and therefore you should compare cargo to npm, npm is the same thing. It does everything all at once, and everyone loves it. Cargo doing everything it does is meant to be a convenient way to interact with Rust projects. That being said, if you don't like Cargo, you can use rustc directly. You can compile Rust code much the same way you would C/C++, with a Makefile.

Multiple string types: As compared to TypeScript, this would seem like an unnecessary complication, but let's compare it to C++ for a second. In C++ you have two string types as well, namely const char * and std::string. These are 'basically' the same as &str and String respectively. It comes down to whether or not you want your string to be heap allocated or not. Allocation is not something you get any control over in TypeScript and for that reason it is possible to have a single unified string type. Also, TypeScript hides the internal representation of strings from you, which is convenient, but can be a real pain in the butt if you're trying to do low-level manipulations.

I would agree that Rust's syntax can be quite terse, but this is due in part to it being a strongly typed language, unlike TypeScript, which is very weakly typed and can therefore simplify a lot of things.

Async code looks ugly in rust. Yeah, it does. Mostly because it's not doing the same thing that it would be in TypeScript. TypeScript async code and Rust async code are fundamentally different. If you have a look at async code in modern C++ you will see a lot of the same complexity as you do in Rust, since it's more closely related to what Rust does.

You say that rust has many different integer types, yet in C you can 'just write int and be done with it'. This is patently false. Here is a catalog of Rust integer types and their C/C++ equivalents:

  • i8 -> char
  • u8 -> unsigned char
  • i16 -> short
  • u16 -> unsigned short
  • i32 -> int (This is the only one you would get if you just write int.)
  • u32 -> unsigned int
  • i64 -> long long
  • u64 -> unsigned long long

In TypeScript you have just number, that's true, but it's a managed language. Again, this hides the complexity from you, but it comes at a steep cost. If you actually want to do low-level manipulations, you have to drop down to something like a Uint32Array type, which is exactly equivalent to [u32] in Rust.

Having to use #[tokio::main] to make an async main. This makes me think you don't understand how async code works. The reason you can just write async code in TypeScript is because there is a runtime. Your code doesn't just run. You need a browser or a Node.JS server or something similar. That is what tokio is (kind of). This also addresses the bloat argument for tokio. Rust does not have a runtime, and therefore when you want to write async code, you need to add one. In TypeScript land, you just get the runtime whether you want it or not.

As for GET requests being 32MB, I don't understand what you mean here. The request itself will never be that large. If you are complaining about the binary size, though, you are likely compiling in debug mode. Switch to release mode and add -C opt-level=3 to the compiler flags and you'll get a binary that's way smaller.

About the libraries, Rust is a young language. Libraries can be hard to find for specific purposes, but that will change over time. Axum doesn't have a home page, btw, because the docs.rs page is more than good enough.

Memory safety is not a buzzword. In mission-critical software (which you would never write in TypeScript, because it's buggy as all hell), memory safety is something you have to have. If you are using C/C++, your memory safety is 'trust me bro'. 'Just use a garbage collector' is not an argument. When people want memory safety, it's exactly because they don't want a garbage collector. I won't go into the specific details, but you are pigeon-holing Rust in with languages like TypeScript and Java, which are designed for different use-cases. Again, Rust is not a 'better TypeScript' and you should not use it if TypeScript is what you need.

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.

Not true. Most memory errors that end up being exploited don't cause any bugs and are extremely hard to predict and test for. Rust provides a way for you to write robust software that has some strong guarantees about what the memory of your program looks like. If done correctly, it eliminates the risk that you may have forgotten a scenario in which your program would not be memory safe.

'Just use C/C++': No. C++, for starters, tends to be much slower than Rust and C is way too low-level to get anything useful done without first having to re-invent the wheel. Rust is a modern language, C and C++ are relics of the past. They are rife with problems and technical debt and the fact that they are designed by committee is the reason for that.

If you don't see any reason to continue with Rust, then don't. People like Rust for reasons that would not make any sense to you as a TypeScript programmer. Rust is a good programming language, TypeScript is a patch on top of a broken language. TypeScript is meant to be easy to use and is therefore hard to use for anything other than what it was designed to do.

[-] nous@programming.dev 5 points 1 week ago

When people want memory safety, it’s exactly because they don’t want a garbage collector.

Everyone should want memory safety and garbage collection is a form of memory safety. A form that enforces the safety at runtime and comes with a steep cost there. People use unsafe languages not because of their lack of safety but because they don't want to pay the costs involved.

Even rust has a cost - but that is on the compiler and developer instead of at runtime. Rusts memory safety makes the compiler and language a bit more complex so is a bit more to learn to get a program to compile - which is a cost to the developer. Though IMO it does make it easier to write correct code.

Memory safety without a runtime cost is what rust is selling.

[-] aubeynarf@lemmynsfw.com 6 points 1 week ago* (last edited 1 week ago)

Try Scala. It has all the functional goodness, all the OOP goodness, all the imperative goodness, clean syntax like python or like typescript, really well thought out libraries like ZIO, Akka, Tapir, Caliban and access to all Java libraries. Very mature runtime with best-in-class high performance concurrent GC and a green thread implementation that can handle 10s of millions of concurrent operations.

[-] Doom4535@lemmy.sdf.org 5 points 1 week ago* (last edited 1 week ago)

A reason to not distribute a library as a binary is for cross platform support, this allows a library to technically be compiled and used in some other platform; with that said, there are assumptions about having the same system calls (or that the library only handles abstract things that don’t hook into a specific architecture), with that said, making cargo smarter and adding in the option to bundle some prebuilt libraries to be pulled for compatible platforms could speed some compile time (at the likely cost of build size, etc).

Distributing a library as source isn't some weird rust paradigm, take BOOST for example, which is a large library for C++, and is usually distributed as source (but Linux distros may bundle prebuilt binaries; it is generally intended that you will compile it and use it as a shared library), actually a lot of compiled languages distribute their libraries as source, it also allows you to read their source if you need to see exactly how they're doing something). I don't believe there is anything preventing someone from using shared libraries in rust, although they do seem to be less common. Another reason to distribute a library as source is for licensing.

The unstable versioning..... Ya, that is definitely annoying, and likely tied to the limited resources available for sustainment for various projects. With that said, compared to C/C++ many of these libraries are something that one might role their own or use in house libraries. Now for Tokio... You don't have to use it for async, although you probably will want to (see: https://blog.poespas.me/posts/2024/05/24/rust-async-std-and-tokio-comparison/), I do wish there was a nice way to depend on a library and substitute some of its dependencies (aka Tokio); with that said, part of the cargo idea is that you don't view these libraries as part of your source code for review (although, auditors would likely disagree, so acrediting with the inclusion of many in accredited libraries would probably not be fun)

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

Rust

5876 readers
115 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