this post was submitted on 29 Feb 2024
171 points (100.0% liked)

technology

22835 readers
1 users here now

On the road to fully automated luxury gay space communism.

Spreading Linux propaganda since 2020

Rules:

founded 4 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 9 points 8 months ago* (last edited 8 months ago) (7 children)

Real question for the techies, is Rust worth hacking around with? It’s just “C++ - Director’s Cut” right?

[–] [email protected] 11 points 8 months ago (1 children)

For balance I’d like to say that I found Rust obnoxious. I can see the advantage if you are developing commercial grade drivers or an OS kernel, but otherwise lifetimes and the borrow checker only ever prevent me from doing things I can trivially see are safe, which is annoying.

I’m sure this will piss people off but it’s my experience.

[–] [email protected] 6 points 8 months ago

same experience here. I already know my program is safe and I don't like wasting time having to prove it to the compiler

[–] [email protected] 9 points 8 months ago

A lot of the syntax is fun, especially pattern matching and error handling. I’m convinced that the way Rust handles traits is the way all languages should handle polymorphism (Allowing you to add methods onto builtin types without polluting the global state? Yes please). The borrow checker is frustrating at times because the set of safe programs is larger than the set of programs written in rust without the use of unsafe. So there can be things you know will work in theory that just won’t compile. But it’s ultimately a fun language to learn.

[–] [email protected] 8 points 8 months ago (2 children)

Not sure exactly what you mean, but Rust is a pleasure to use and it'll change the way you think about coding (even in other languages). It's worth giving it a shot.

[–] [email protected] 7 points 8 months ago (1 children)

Well. That sounds convincing enough to me. I'll check out the official site and create my typical test of a language, creating a basic dice rolling console program.

[–] [email protected] 3 points 8 months ago

Good luck! That's a really good starter project because you'll need to use a separate crate for RNG, so it'll teach you how to use Cargo and set up properly. I can't recommend using the Rust book enough, the first 2 chapters should suffice for your test.

[–] [email protected] 4 points 8 months ago (1 children)

Can I become a better python script kiddy of I start asking chatgpt for rust code?

[–] [email protected] 3 points 8 months ago

Hmm, probably not? Unless you just use an LLM to help you with the Rust syntax while putting in your own effort to understand how to maneuver around the borrowing system and the type system.

[–] [email protected] 7 points 8 months ago* (last edited 8 months ago)

As somebody who grew up hacking with C++ (on game engines like Doom and Quake) and has also fucked around a bit with Rust (early Hexbear days), Rust is very cool. There are no redundant header files to write. You don't need to install Gentoo to have proper dependency management. The type system is lightyears ahead of what the drunken 90s stupor over object-oriented programming produced in C++. You don't need to add an extensive non-standard library like Boost to make it usable. Basic shit like iterators work a lot better. Errors can be handled elegantly without having exceptions unwind the stack every time an unexpected result occurs. It has its own learning curve, but whenever it incurs pain it is fairly clear why, and what problems you are circumventing.

The downsides are that compilation units are much larger, incremental compilation is slower, and support for obscure platforms is nowhere close in comparison to C/C++.

[–] [email protected] 7 points 8 months ago

I found rust to be a pain in the ass. All the same inconsistent, counter-intuitive, and bloated syntax of C++, but at least some of the bloat is going towards memory safety.

[–] [email protected] 6 points 8 months ago

Rust is the future. The website you're on right now is written in Rust. Rust is love, rust is life. My gravestone will be written in Rust. Rust is everything. I love Rust.

[–] [email protected] 6 points 8 months ago

I always liked writing C but never really had a reason to learn C++ super deeply. I wrote some for a project for a bit but was moved onto something else. I had previously learned C# and go and wasn't a huge fan of either. C# mostly because windows, Go because they don't let you do weird fun things.

Rust is a neat language because you can do a lot of weird functional stuff in the middle of some dry systems code. Because the compiler is such a stickler, you end up fixing most dumb mistakes from the get go, which means you get this feeling like your code always works the first or second try.

I found it overall a really fun language that gives me the "functional-lite" vibes of python without the typeless hell of python. There are some common paradigms that are a huge pain to do in rust, but overall I found the language engaging and the documentation is incredibly consistent and high quality so it really helps when learning.

I recently did a small IOT project on an ESP32 in rust, and it was a joy compared to dealing with json in C. I was able to write a simple protocol library, test it on my workstation, then use the same code without any changes and call it from the esp code. Rust literally made the project faster and easier. Especially due to the "it just werks" effect of the annoying compiler, far less weird runtime errors on an embedded device is just a delight.