4 ms·
I recently spent 15 minutes going over a Rust futures tutorial and was then able to get a Rust program streaming live bitcoin futures (coincidence!) over websoc
by brobinson 6y ago
I recently spent 15 minutes going over a Rust futures tutorial and was then able to get a Rust program streaming live bitcoin futures (coincidence!) over websocket connections from multiple exchanges working in less than an hour.
I then then attempted to port some Python code to use Python's new async/await and was unsuccessful. I managed to get a bunch of async workers running, but only the first one would process jobs from the queue or the entire program would just hang indefinitely. Couldn't figure it out after two hours and just gave up on it.
Nice work, Rust team. This is a game changer for me.
- ygram 6y agoPython got async/await in 2015, so not exactly new.
- brobinson 6y agoI still find people writing new code in Python 2 so I consider 3.7.x to be "new", but you are right.
- deleted 6y ago[deleted]
- jib_flow 6y agoAs someone who has struggled learning Rust, it's incredible to me you were able to do this so quickly. Had you spent much time prior with Rust?
- brobinson 6y agoI've been using it off and on since late 2014, back when my code would stop working every week due to a new breaking change. :D
- martamorena9182 6y agoLooking at the code, it's a nightmare to parse. There are so many details to deal with that should never bother you under normal circumstances (the core problem of using Rust where it's not necessary). It's admirable that you have such an easy time with it. However, for most people, using Rust for these purposes is absolutely not recommended. Java/Kotlin paired with reactive streams makes these tasks super easy to read, once you get the hang of reactive streams. Also there are complexities in there, you just simply can't brush all the intricacies of network programming and multi-threading under the rug, but at least you are dealing only with the complexities that are necessary for your problem. With Rust you are dealing with tons of additional complexity that doesn't matter to 99% of people & problems. I love that Rust exists and it has its uses (browsers, hypervisors, drivers, kernels, etc). I just find it very alienating when people compare this to Python and do everyday tasks with it. No, you really don't want to deal with borrowing, memory management and life-times, unless it is part of the problem you are trying to solve (and there aren't too many for which that applies).
- steveklabnik 6y agoThis code is all about learning about how this stuff works at a deeper level. To use async Rust, you need to write none of this code.
- martamorena9182 6y agoYes, this is usually how it turns out in practice. You don't need to understand what's going on under the hood, you just string some libraries together and call it a day ;). /sarcasm off
- steveklabnik 6y agoAbstractions and use of them is the core of our discipline, not sure why you think your comment is sarcastic.
- db48x 6y agoThis article is explaining how Futures work by showing you what's under the covers. You don't actually have to write this code yourself, you can just use one of many wonderful libraries that handle it all for you. As it says in the second paragraph: "Going into the level of detail I do in this book is not needed to use futures or async/await in Rust. It's for the curious out there that want to know how it all works."