←back to thread

611 points LorenDB | 1 comments | | HN request time: 0.001s | source
Show context
atemerev ◴[] No.43908259[source]
Right. I attempted using Rust for trading-related code as well. However, I failed to write a dynamically linked always sorted order book where you can splice orders in the middle. It is just too dynamic for Rust. Borrow checker killed me.

And don't get me started on dynamic graphs.

I would happily use Rust over C++ if it had all other improvements but similar memory management. I am completely unproductive with Rust model.

replies(4): >>43908277 #>>43908709 #>>43909131 #>>43909428 #
sunshowers ◴[] No.43908277[source]
I apologize for the naive question, but that sounds like a heap?
replies(2): >>43908888 #>>43910095 #
jpc0 ◴[] No.43908888[source]
In my experience you need to approach this with vec or arrays of some sort and pass indices around… “We have pointers at home” behaviour. This is fine but coming from C++ it definitely feels weird…
replies(2): >>43908917 #>>43909512 #
bigstrat2003 ◴[] No.43908917{3}[source]
Why not just use pointers? Rust has them, they aren't evil or anything. If you need to make a data structure that isn't feasible with references due to the borrow checker (such as a linked list), there's absolutely nothing wrong with using pointers.
replies(1): >>43910054 #
atemerev ◴[] No.43910054{4}[source]
And it will look like this: https://rust-unofficial.github.io/too-many-lists/sixth-final...

(filled with boilerplate, strange Rust idioms, borrow_unchecked, phantomdata, and you still have to manage lifetimes annotations).

replies(1): >>43910962 #
bigstrat2003 ◴[] No.43910962{5}[source]
And? I don't really see the issue. It works, it is sound, and it has a nice clean interface for safe code to use. That's all I really ask for. Lots of useful things in programming are quite gnarly under the hood, but that doesn't mean those things aren't worth using.
replies(1): >>43913004 #
uecker ◴[] No.43913004{6}[source]
It is fine, there is just not much Rust safety advantage left then. Also in C/C++ the errors do not usually occur when using a nicely defined API, but when doing the low-level gnarly stuff and getting it wrong. As said before, I think there is some advantage of Rust having a safe and unsafe subset, but is is nowhere as big as people claim it is.
replies(2): >>43918304 #>>43918558 #
sunshowers ◴[] No.43918558{7}[source]
Is there a safety advantage to using Java given that the HotSpot JVM is written in C++?

All safe code is built on a foundation of unsafe code.

replies(1): >>43921947 #
uecker ◴[] No.43921947{8}[source]
Sure, but the point is that you can also build reasonably safe abstractions in C / C++.
replies(1): >>43923622 #
sunshowers ◴[] No.43923622{9}[source]
The last fifty years have shown us that you can't — at least not sustainably and at scale. You can do so at one moment in time, or for smaller projects, but not in the face of large scale projects with team members changing over time.
replies(1): >>43944742 #
uecker ◴[] No.43944742{10}[source]
I don't this the last fifty years show this at all, although Rust proponents want you to believe this.
replies(2): >>43956083 #>>43959130 #
1. sunshowers ◴[] No.43959130{11}[source]
I guess.