Live data from Hacker News

Was Rust Worth It?

jsoverson.medium.com

551–560 of 736 posts

Re: Was Rust Worth It?

#551
post #53

Do you need memory safety? Then why use Rust when you could use Java, JS, Python, etc? You can't "disable" memory safety in those languages. Do you need bare metal performance? Then why use Rust when you could use C or C++, which have much larger ecosystems, platform support, more mature tooling, etc. Do you need BOTH memory safety and baremetal performance at the same time? Then there really aren't many other option…

In addition to memory safety and performance, Rust offers something that, as far as I'm aware, no other mainstream languages offer: protection from data races.

And it offers those things along with a fantastic type system, and great tooling.

Re: Was Rust Worth It?

#552
I've tried it a few times and it has great features on paper but to use it gets in your way too much. I can spin up a C# dotnet project write and test the code 10 times faster than in Rust. It might not perform as fast but the hot code can be written in a small C library using code/runtime analysis tools to catch any memory safety issues.

Re: Was Rust Worth It?

#553

Earlier quoted context omitted.

I’m not sure. Looking through different Rust libraries, I tend to see three different styles, depending on previous programming experience. Each mimics the prior experience, with benefits. * Everything is a struct with concrete types. This is closest to C. It benefits from the improved memory safety, without sacrificing speed. * Everything is a Box >. This is closest to dynamic garbage-collected languages, but with v…

> Everything is a Box >. This is closest to dynamic garbage-collected languages, but with vastly improved performance. Why the `Box`?

Mostly to mimic the data structures allowed in languages where objects are held by reference. In Python, I could write a tree structure as `namedtuple(“node”, [“lhs”, “rhs”])`. If I tried to write a similar structure in Rust as `enum Node{Leaf, Branch(Node, Node)}`, the compiler rightfully complains that it would have an infinite size. But the indirection introduced by Box would let it be stored as `enum Node{Leaf, Branch(Box, Box)}`.

Re: Was Rust Worth It?

#554
post #533

Earlier quoted context omitted.

Maybe because you want to keep the dependency tree under control and bringing in tokio suddenly adds fifty crates you never asked for. Every crate is a potential liability!

Tokio is developed very carefully (they’ve even developed their own thread race checker for it – loom). Adding it to your project probably increases the average code quality:)

I don't doubt the code quality but most of the additional crates are not tokio's. Also statistically, any added complexity incurs more risk.

Re: Was Rust Worth It?

#555
post #286

Earlier quoted context omitted.

> but the ergonomic is really bad. Every time I write some rust I feel limited. > But I do not think it is a good general purpose language. Remember that this is not a sentiment that's shared by everyone. I use Rust for tasks that need anything more complicated than a shell script. Even my window manager is controlled from a Rust program. I say this as someone who has been programming in Python for nearly two decades…

> At this point, I'm about as fast in Rust as I am in Python. This is factually impossible. For anything larger than (very) small programs, Rust requires an upfront design stage, due to ownership, that it's not required when developing in GC'ed languages. This is not even considering more local complexities, like data structures with cyclical references.

I disagree. I have similar observation. With modern editors and Language Server that are giving immediate feedback writing strongly typed languages doesn't differ than writing python.

Re: Was Rust Worth It?

#556
post #416

Earlier quoted context omitted.

> Surprisingly, I am faster in Rust than any other language. Not really surprising, given that you have C and C++ background. That's what I was trying to highlight. Rust isn't a confusing or unproductive language as many project it to be - if you have the conceptual understanding of what happens on the hardware. Especially about stack frames and RAII. If you know those, the borrow checker complaints will immediately…

I'd add that if you have some understanding of how memory ownership should be such that you don't end up with memory leaks, you are fine. The borrow checker just verifies that your mental model is correct, and removes some of the cognitive load from you.

> if you have some understanding of how memory ownership

What reading materials will help me level up my understanding of this?

Re: Was Rust Worth It?

#557

Earlier quoted context omitted.

Having tried Java and other languages, no, it's not a joke. Other than XML Maven got a lot of things right.

What the hell is that XML hate Whats the diff between changing lib version in xml and json?

I have no problem with XML in general and even think it's still the better format for many things. But it's not really appropriate for a build config. Thankfully Maven now offers polyglot but I've seen no use of it in the wild.

Re: Was Rust Worth It?

#558
post #463

Earlier quoted context omitted.

> While the Rust devs believe such cyclic references are rare - They are. I have not had to use cyclic references ever, except once doing experiments with fully connected graphs, that was very unusual If you're doing a lot cyclic references Rust is not the right choice. Horses for courses But are you sure you're using the best algorithm?

Maybe for you it's unusual - in my previous work all the apps contained graphs, and I just joined a company where almost all the apps also contain graphs

I don't write Rust, but I never understood why graphs meant you need circular references.

Doesn't it just come down to the question of who owns the node?

If it's a tree, and parents are never removed before children, just make the child owned by the parent and keep a weak reference to the parent.

If it's a general graph, and vertices can exist or not exist regardless of edges, keep a list of them independent of the edges, and keep weak references in the edges.

If it's a graph where a one or a few roots exist, and nodes exist as long as there's a path from a root node to them, that sounds like a classic use case for Rc.

Is there a common use case I'm missing?

Re: Was Rust Worth It?

#559
post #231

I wrote a lot of rust, but after some years it still feels unproductive. I do a lot of zig now and I am like 10 times more productive with it. I can just concentrate on what I want to code and I never have to wonder what tool or what library to use. I know rust gives memory safety and how important that is, but the ergonomic is really bad. Every time I write some rust I feel limited. I always have to search libraries…

I agree. I feel far more productive in C and C++ than in Rust at that point. Rust feels like totally missing the sweet spot for me. It's way too pedantic about low level stuff for writing higher level applications, but way too complicated for embedded or writing an OS. In the former case I would rather take a C++, Java, Haskell, OCaml or even Go, and maybe sprinkle some C, and in the latter case C in macroassembly mo…

I gave Rust a few chances, and always came out hating its complexity. I needed a systems programming language to develop a hobby OS[1], and Nim hit the sweet spot of being very ergonomic, optional GC, and great interop with C. I can drop down to assembly any time I want, or write a piece of C code to do something exotic, but the rest of the system is pure Nim. It's also quite fast.

[1] https://github.com/khaledh/axiom

Re: Was Rust Worth It?

#560

Earlier quoted context omitted.

This. I have exactly the same experience, I can't believe how much I was able to ship with Zig and the code mostly feels like "done". You can always improve it, but there's no need to. With Rust, I was never happy, even after 5 years, I was still thinking about better abstractions and implementing more traits, making it more generic, etc.

Why is there no need to improve Zig code but there is for Rust code? You'd need the same abstractions in Zig as well, no?

Can't speak for why Zig doesn't have a problem but Rust is cursed by its success: it lowers the barrier for improvement enough to entice you to always improve it.
Post reply on HN