Live data from Hacker News

Was Rust Worth It?

jsoverson.medium.com

171–180 of 736 posts

Re: Was Rust Worth It?

#171
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…

Beyond memory safety, Rust's other advantages over C++ are simply that it has a far better type system (by nature of ADTs), cleaner and more consistent syntax, cleaner tooling overall, and a far better module/modularity story.

That, and the borrowing/safety aspects of Rust also shake out into threading/concurrency, where the compiler does a pretty good job of forcing you to adopt better practices in regards to state sharing, locking, concurrency.

Cargo, though... I am coming around to thinking isn't great -- workspace support remains half-assed, especially... and crates.io is amateur-hour for reasons many people have pointed out elsewhere on this post. I have been tempted to switch my personal projects to bazel, with 3rd-party deps checked in/submoduled.

Re: Was Rust Worth It?

#172

It's only mentioned off hand in one sentence at the end, but have people found that Rust is hard to hire for? In my experience it's relatively easy to filter for good candidates when you're hiring for Rust, whereas, just as a point of contrast, I've noticed it's more difficult to find frontend developers who are good at TypeScript (since a lot of frontend developers just use plain JavaScript).

I don't think it is unusually difficult to find Rust programmers. The challenge is finding Rust programmers who also have expertise in systems software development. Rust was designed to be a systems language but ironically it primarily seems to attract developers that do not have expertise in systems software.

This isn't necessarily a problem. C++ and Rust can coexist pretty well in practice, and Rust is a good entry point for learning how to write systems software.

Re: Was Rust Worth It?

#173

As an outsider, I often hear about async Rust being less than ideal. Perhaps I don't understand, because I haven't dipped my toes in the water yet... but I do most of my work in Kotlin with Coroutines, and concurrency is everywhere in the UI. I can't imagine working in a language having a major deficit in this space. Are there any efforts to overhaul or completely rethink this?

For me I am working on a side project in Rust and had very few issues, Rust felt quite straight forward up until the point where I had to mess around with async. For my domain I need to use a framework that expects you to set up a shared mutable state for the connection pooling in an opinionated way. Suddenly I encountered arc and mutex and very cryptic trait error messages for code doing way too much magic. All I wa…

You would run into the same issues if you tried to do it with threads and rust too.

Any kind of shared resource is a tedious experience, that's basically it's selling point.

It is frustrating becasue if you go look for help, people are always condescending about global shared resources like that but there really isn't a better way.

Re: Was Rust Worth It?

#174
post #95

I'm learning Rust because it seems clear that it's going to be important professionally. I wish I loved it, I really do. I see the benefits. But, at least so far, it's one of the most unpleasant languages I've used. I keep hoping that as I gain proficiency, I'll stop disliking it, but as I climb higher on the learning curve, I'm not really warming to it. It's fine. It won't be the only language I'll be proficient in…

Well, what do you dislike about it?

Re: Was Rust Worth It?

#175
post #20
post #2

Perhaps my biggest critique is that crates.io has no namespacing. Anyone can just claim a global and generic package name and we mostly have to deal with it (unless you avoid using the crates.io repository, but then you'll probably have more problems...). Some of these globally-claimed generic packages are not really the best package to use. Maybe it was a reaction against the Java-style reverse DNS notation, which i…

This needs to be resolved by every damned language. Just make signed dependencies a universal default, point to an https page for the package vendor and use the signing key from there. Neither node nor maven ever bothered to solve this, so we end up wandering the Wild West wondering when it will be that HR, or legal, or architecture comes knocking on the door to ask what we were thinking having a dependency on a dyna…

Maven has signing and you can check the signatures on your dependencies if you care to. Most don't, sadly.

Re: Was Rust Worth It?

#176
post #142
post #113

Earlier quoted context omitted.

The problem that I am running into at the moment is that a few things like the rhai Engine aren't Send and I am trying to use them in an async closure. What GPT-4 suggested was creating a tokio Runtime inside the thread and then block_on(). I will try it tomorrow. (This is the first significant Rust project for me.)

The answer here is almost certainly one of these: 1. Fix rhai::Engine so it is Send (if !Send is unintentional) 2. Use tokio::spawn_blocking or normal threads to run the rhai::Engine bits 3. Don't hold the rhai::Engine across an await point. Which one depends on rhai Engine details and what you want to accomplish. Doing a block on inside a new thread seems unlikely to do anything useful (unless there's some undisclos…

1. Not applicable unless it is absolutely required, and not something I will consider until I have exhausted other options, since there is a reason they have not made it Send already. It will likely be quite complex and enlarge the scope.

2. I am using a normal thread but when I make it async the compiler wants Send.

3. The await point is in code that uses the engine. I am not sure there is another good option, since I need to use an API that has several libraries all of which are async.

The block_on is to allow the tokio Runtime created in that thread to execute/poll it

So, thank you for your input, I will test out the suggestion that I mentioned above, and then maybe look into spawn_blocking if that doesn't work.

Re: Was Rust Worth It?

#177

Earlier quoted context omitted.

There's a secret effort in the Rust community to supplant Crates.io and create an entirely new package ecosystem with proper namespacing, security, and much better community. Not naming names, but I know several people working to put Crates.io out to pasture. There's a level of playing nice with them for the time being (eg. build reproducibility), but it's only KTLO. Crates.io needs to die for Rust to thrive. They're…

How secret is it now that you've posted on HN about it?

It's an open secret.

Re: Was Rust Worth It?

#178

I never programmed in Rust, but I had enough experience in C programming to know that segmentation faults are annoying to debug. I heard Rust prevents memory management problems at compilation level, so it forces you to create safer program. Given this, I want to ask Rust programmers here: For people who have no experience in managing memory at coding stage (basically programmer who have no experience in C-like langu…

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.

Wait, reference counting everything all the time is faster than normal garbage collection?

Re: Was Rust Worth It?

#179
post #126

Earlier quoted context omitted.

Maven and Java really don’t get enough credit for how well it’s dependency management works. So many inferior dependency management systems for other languages have come along later, and learned nothing from those that came before it.

Is this a joke?

Not even remotely a joke.

The inverse-style domain name thing does a really good job of removing the whole issue of squatting from the ecosystem. You have to demonstrate some level of commitment and identity through control of a domain name in order to publish.

I would also say that this puts just enough friction so that people don't publish dogshit.

crates.io demonstrates quite clearly that you either have to go all the way and take responsibility for curation or you have to get completely out of the way. There is no inbetween.

Re: Was Rust Worth It?

#180

I never programmed in Rust, but I had enough experience in C programming to know that segmentation faults are annoying to debug. I heard Rust prevents memory management problems at compilation level, so it forces you to create safer program. Given this, I want to ask Rust programmers here: For people who have no experience in managing memory at coding stage (basically programmer who have no experience in C-like langu…

For people who've never written C or C++, Rust's biggest selling point is usually performance. Porting code from Python to Rust for example often gives 10-100x speedups right off the bat. You could get the same speedups by porting to C too, but Rust lets you do that without giving up the memory safety and package management convenience that you're used to. Even when you don't care about performance, another issue tha…

>> Porting code from Python to Rust for example often gives 10-100x speedups right off the bat.

As long as you don't do a couple of things that, while easy to remember not to do once you know them, a programmer used to languages like Python and Javascript might be oblivious to. Things like:

* Forgetting to use buffered IO wrappers

* Using println!() for high-volume console printing rather than locking stdout and writing to it manually

Post reply on HN