Live data from Hacker News

Was Rust Worth It?

jsoverson.medium.com

231–240 of 736 posts

Re: Was Rust Worth It?

#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 and how to do things. I cannot just "type the code".

Also the type system can get out of control, it can be very hard to actually know what method you can call on a struct.

I still think rust is a great tool, and that it solves tons of problem. But I do not think it is a good general purpose language.

Re: Was Rust Worth It?

#232

Earlier quoted context omitted.

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

Wait I thought only I could read the secret

yes, HN hides secrets automatically

******* is my password, but you can't see it. Type your password back, and I won't be able to see it. Try it!

Re: Was Rust Worth It?

#233

Earlier quoted context omitted.

It does support inline assembly [1]. However, it's different than the way GCC supports inline assembly. It seems nicer, TBH. [1]: https://learn.microsoft.com/en-us/cpp/assembler/inline/inlin...

From that source: > Inline assembly is not supported on the ARM and x64 processors.

Oh, my bad. I should have read the source more closely. I hadn't realized only 32-bit x86 processors were supported.

Re: Was Rust Worth It?

#234

> After two decades of JavaScript and decent experience with Go, this is the most significant source of frustration and friction with Rust. It’s not an insurmountable problem, but you must always be ready to deal with the async monster when it rears its head. In other languages, async is almost invisible. I am a former C and C++ programmer who lived calling into pthread almost every week for a decade. I use async rus…

Can you please elaborate on this? What's an example of a seemingly single threaded simple task where you would turn to async? Does "use async rust everywhere now" imply "use tokio everywhere now?" Honest question.

The way closures made it easy to encapsulate code and state in an object you can run at any time, async encapsulates code and state for ability to run and pause or cancel at any time.

This is handy for I/O that can be interleaved and cancelled. You can (ab)use it for other things like generators or various DIY multitasking operations. It can also be a state machine generator (e.g. AI of actors in a game).

But I think OP just meant async for typical networking and DB interfaces. And yes, this usually implies the Tokio dependency.

Re: Was Rust Worth It?

#235
>> I started writing tests in Rust as I would in any other language but found that I was writing tests that couldn’t fail.

I'm curious if this is other's experience as well. I've only dabbled in Rust but it isn't clear to me how it would ensure that the code is correct.

Re: Was Rust Worth It?

#236

"Want to use an async library? There’s a chance you can’t use it outside of a specific async runtime." I complained about this here[1]. I'm told "Tokio won, it's not a problem anymore." Wrong. It's still a problem and it's a killer. [1] https://news.ycombinator.com/item?id=37892655

Yeah those are terrible responses. Tokio monoculture is a serious problem.

On the supposed "monoculture":

First, I have to wonder whether any of this can be legitimately elevated to the level of a "culture." Right now, according to GitHub "insights," tokio-rs has approximately 2.0 regular, every day contributors. And that's the most widely used Rust async runtime. Everything else is likely even more thin.

Second, Tokio has a lot of share because it was early and aggressive in actually delivering usable async documentation and code. I recall, years ago, reading Tokio documentation on how futures worked and grasping these concepts all the way from file descriptors one might epoll() in C, up to the Rust abstractions, and thinking "hell, I could write an executor from first principles based on this." Tokio earned the advocates it has, as oblivious to the real state of things as some of them might be.

I think the real problem is that async Rust is incomplete. As I said elsewhere, async Rust syntax is fine. The implications of async Rust exposed some papercuts in the language that have had to be dealt with since, but the core syntax is fine. I believe that can be attributed to the serious minded attention that the syntax received from people way, waaay up the cognition curve. The part that didn't get enough thought was async runtimes. In an ideal world, one would develop a Rust library that utilizes and/or implements asynchronous calls and transparently, flawlessly run on any correctly implemented runtime alongside any other number of libraries also utilizing and/or implementing async calls.

That is not the case, and the damage that's doing is severe. For every one person, such as myself, that will dare attempt to articulate this pain and, in the process, certainly revealing clear evidence of blatant ignorance, a thousand others just silently gave up.

Re: Was Rust Worth It?

#237

> I started writing tests in Rust as I would in any other language but found that I was writing tests couldn’t fail. This is a common refrain in C++ testing: if it compiles then it's probably correct. > Rust has accounted for so many errors that many common test cases become irrelevant In practice, if you think this way I think it's a sign that you aren't testing the right things in those other languages. You should…

> This is a common refrain in C++ testing: if it compiles then it's probably correct. I’ve heard this in Haskell and in Rust. I’ve never heard it applied to C++…

I’ve definitely experienced it in Haskell and Rust. I can believe some C++ could be that way, but I’ve never experienced it, but then again those projects didn’t have useful tests either. I think with C++ a lot of this depends on domain and the quality of the code and libraries.

Re: Was Rust Worth It?

#238

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?

It feels like most of the hatred for rust async is for people that try to act like Tokio isn't async rust and that for some reason you should try to randomly avoid tokio for some reason.

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!

Re: Was Rust Worth It?

#239

"Rust screams at you all day, every day, often about things that you would have considered perfectly normal in another life." A good C compiler does this when you turn on all the flags. I like languages/compilers that let you selectively disable the screaming and let you write bad code on purpose. Bad code that works but can be written fast is often better than perfect code that takes forever to write. Once you have…

> A good C compiler does this when you turn on all the flags. I like languages/compilers that let you selectively disable the screaming and let you write bad code on purpose. Bad code that works but can be written fast is often better than perfect code that takes forever to write. Once you have a bad but working POC, you can make it less bad. Rust supports that. Just mark everything unsafe.

"Just mark everything unsafe" seems to be the motto of many (most?) crate developers. There's so much "unsafe" in dependencies used by so many Rust programs. It's a timebomb waiting to go off.

Re: Was Rust Worth It?

#240
post #176
post #142

Earlier quoted context omitted.

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…

That ChatGPT suggestion is dodgy. Tokio is going to complain when you create a runtime while in async runtime, and refuse block_on in an async context.

You can have multiple runtimes, but create them ahead of time, in synchronous main, and keep a Handle to them.

But you probably need: https://docs.rs/tokio/latest/tokio/task/struct.LocalSet.html

Post reply on HN