6 ms·
I rebuilt my algorithmic trading platform in Rust. I'm filled with regret
- Gepsens 2y agoWhy is the level so low in software engineering in general? Well, at least I know I'll never be out of a job.
- tossandthrow 2y ago> one of the safest This seems to be a severe misunderstanding, basically all typed pure functional languages are more safe: haskell, sml, ocaml, etc. It is safe without a garbage collector that is the core benefit.
- unstruktured 2y agoI think when people say safest they mean the safest "C like" language with zero cost abstractions.
- fl0id 2y agoYeah but the author went from typescript to rust… what did they expect.
- tossandthrow 2y agoThen irony is that typescript (well, Javascript) has full memory safety. The changes of segfaults only increased when he switched to rust.
- palata 2y agoI am not convinced about that. I think that many people discovered the notion of "memory safety" with Rust, and think that only Rust provides it. The grandparent is right: Rust brings memory safety at low cost, that's the whole point.
- palata 2y agoI am not a Rust fan by any mean, but it feels like this rant is not completely informed. Things like: > Just give me a garbage collector, and let me do what I want to do! and > But when compared with other languages (like Go), its “safety” to me is more of a detriment. Sound like the author is not exactly clear about what "memory safety" is. Many languages are memory safe. The difference is that Rust aims for memory safety at zero (in practice "very low") cost. If garbage collected languages could do that without sacrificing their simplicity, they would do it. It's a tradeoff. If Kotlin is fine for you in terms of performances, then use it! Rust is rather an alternative for C/C++, where performance matters. Feel free to use Rust wherever you want if you love it, but don't use it when performance does not matter if you hate it!
- qarl 2y agoYeah, > Just give me a garbage collector, and let me do what I want to do! That line pretty much perfectly shows the author doesn't know what he's talking about. Note to the author: Rust is specifically made for situations where you can't use a garbage collector.
- dehrmann 2y agoThe problem is Rust's marketing. They sell the language too well for use cases that don't need the same degree of safety or speed, and Java (or Go, or C#) would be the more pragmatic choice. If you find yourself writing an OS or browser, Rust is a great choice. Basically anything where C++ is the alternative.
- Fire-Dragon-DoL 2y agoI have a vague hunch where Rust is chosen because of the good quality abstraction the language support that's missing from modern languages. I keep joking about it, but immutability is si valuable for general software development. None of the mainstream languages support that, but Rust achieves the same benefits (even if in a different way). Then the Rust type system is sound while modern languages are still dealing with problematic nulls and lack of advanced types (like what's possible with typescript)
- 2y ago
- piker 2y agoBetween endless builder patterns and the let if/match syntax it does get quite wide and ugly relative to C or something. But it definitely has its upsides.
- j16sdiz 2y agoI hate rust, but I think this article is unfair because the author has got his expectation wrong. I meant, he is comparing that to pythons and typescript?
- VHRanger 2y agoI programmed in C++ before, mostly doing high performance stuff. Like anyone who used C++ for a while, I had issues with the language. Here are why I dislike it: 1. Compile times. There's a big difference in user experience between <10sec and >30 sec between clicking "build" and getting feedback on what mistakes you made. Above 15-20 seconds I tend to shift my focus to something else. This means when I read the error message I have to context switch back to the task. The productivity gains from fast builds (Go, D, or even Python to be honest) are immense in my experience. 2. The syntax is bad. It's rare to have a meaningful line of code with fewer than 70-90 characters. Your eyes go horizontally as well as vertically. There's a lot of coginitive overhead in learning which stuff to skip reading, because it's boilerplate or language quirks. 3. Building C++ is nonsense, everyone has their own different solution, so getting external libraries into a project that aren't header only is hell. And header only libraries make problem #1 even worse. C++ being insecure is not my problem. Rust focuses hard on that thing which is not my problem, but Rust puts little focus on problems #1 and #2. They do solve problem #3, they have a package manager, great, but every other language also does that so it's not a competitive advantage for me. I seriously doubt if most people listed their priorities with languages they would align with Rust's. Few people are actually writing linux kernel code or core system libraries that could expose dangerous memory bugs.
- kolanos 2y agoA resource where different programming languages are evaluated like this for different use cases in a balanced way would be useful I think. Only thing I can think of like this is the "Your Programming Language Sucks" threads that are more meant as humorous hyperbole.
- estebank 2y agoRe #1, when writing Rust consider using cargo check instead of cargo build. It stops a few stages before code gen so it can give you feedback faster. It doesn't help when you want to run your runtime tests, but will speed up the cycle of getting code that can compile in the first place.
- glzone1 2y agoI think this omits one item that can be relevant. It talks about rust being fast. Rust can be quite slow to compile. If development velocity is relevant, then Rust may not be as "fast" as go to compile as an example. Of course, some folks are chasing speed at all costs (and spending 18 months re-writing to do so). Rust may be a good fit there.
- manaskarekar 2y agoThe example author shows as unreadable is perfectly readable to me.
- tired_and_awake 2y agoYeah I think he's just coming from a totally different operating domain. I cannot even imagine going from Typescript to C/C++/Rust. I'm even impressed OP maybe it this far...
- stouset 2y agoSame, and then they provide a Go example that… is basically identical? Then they complain about Rust not providing stack information about errors, but at the same time the Go equivalent just does `return nil, err` everywhere, also throwing away stack traces. They correctly point out that you can wrap errors in Go with `errors.Wrap(...)`. But you can also do exactly the same thing in Rust with something like `std::backtrace`, the `failure`, or the `anyhow` crate.
- playingalong 2y agoThe comment about Rust community being unfriendly (well, the words used are harsher than this) might be specific to Reddit sub.
- fragmede 2y agoIf there is a friendly Rust community, please link it otherwise we have to assume it doesn't exist. edit: Cunningham's law :)
- estebank 2y agohttps://users.rust-lang.org https://users.rust-lang.org https://internals.rust-lang.org https://internals.rust-lang.org https://rust-lang.zulipchat.com https://rust-lang.zulipchat.com
- steveklabnik 2y agoThere has been some uh, lively discussion about this post on various reddits since yesterday. The author said > I wanted to try writing the article in an inflammatory style for engagement. but to respond to some of the things claimed, for anyone curious: > Just give me a garbage collector, and let me do what I want to do! This is absolutely a reasonable opinion to have, but it means Rust was just not the correct choice. That doesn't mean Rust is bad. > Maybe I’m just an idiot and can’t figure out how to enable stack traces. But when an error happens in my application, I have no idea why! Panics have an environment variable you can set to print a stacktrace. You can also grab a stacktrace yourself with the tools in std::backtrace, and many error libraries like anyhow will let you capture backtraces for Results. However, part of the pain the author is feeling here is that instead of using error objects directly, their example code shows them converting them to strings and then returning them that way. This is going to make figuring things out harder, but that's because you're not using the tools given.
- fragmede 2y agoYes but the language is making it hard to use the tools given. It's easy enough to say it's a skill issue, and say they should have discovered RUST_BACKTRACE=1, but when you're learning the language and trying figure out how to use error objects in the first place the tools given don't work and just give me a string that says I'm doing a dumb shouldn't be so hard.
- nequo 2y agoIn this case, `RUST_BACKTRACE` is described in Chapter 9 of The Book: https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-with-panic.html https://doc.rust-lang.org/book/ch09-01-unrecoverable-errors-... I would say that this has good discoverability. If you're learning the language and writing your algorithmic trading platform in it, The Book should probably be the first document that you go to.
- estebank 2y agoWhen encountering panics, the runtime output will tell you how to get the backtrace: thread 'main' panicked at src/main.rs:3:7: called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace It's true that neither rustc nor clippy complain about having a `Result<_, String>` return type. Maybe they should. It wouldn't be too hard to implement such a lint, but I would expect people to be annoyed by it. I would argue that in 18 months there are plenty of chances to come across any of the documentation and blog posts that explain this, or to ask questions in https://users.rust-lang.org https://users.rust-lang.org. I want our toolchain to be as easy to use as possible, to make it best in class. I have a long list of things I'd like to see improve in Rust. The critiques in the article are not constructive, neither in presentation nor substance.
- shepardrtc 2y agoI built an algorithmic trading platform in Python and used Cython to speed up the hotspots. No regrets.
- fragmede 2y agoNot pypy?
- jvanderbot 2y ago> Just give me a garbage collector, and let me do what I want to do! Yes - a clear sign you have not found a good application for safety, security, and low-level control vs developer speed. Systems, safety critical, embedded, etc. Why it expanded beyond this is not clear to me, other than hype and falling into a gaping void in distributed systems development that Go never filled for some reason.
- taylodl 2y ago> If we compare it to C++, it’s obviously the better language. It really depends on what is meant by "better." The thing I like about C++ is its problems are well-known as is how to work around them. The thing that concerns me about Rust is we don't know all its problems - in practice. We will eventually, sure. Sometimes I don't think we pay enough attention to how much our collective experience with a language matters.
- stouset 2y agoWe’re aware of C++’s problems but working around many of them is still a widely open problem (until we discover / invent perfect humans).
- taylodl 2y agoIt's not the case that we don't have work arounds, we simply don't have generally accepted and agreed-upon work arounds. You have options. For example, there's no generally accepted work around in C++ for manual memory management. You can develop your own strategy, but you may not be able to use libraries out of the box without having to create shims (or monads) but the point is: we know how to do these things. Most of the code in production has done these things and few people are interested in refactoring this huge investment to Rust.
- CrimsonCape 2y agoI'm curious as to the lifetime annotations. This is essentially the language designer's intent to say "place a marker on this data field such that the compiler can trace the usage of the field to insure it is not accessed (before,after) the memory is released." Therefore, the lifetime is expressed via an additional abstraction requiring the associated language syntax, compiler design, additional rulesets, etc. Why would the same concept not be expressible as it's own data type, that would then be passed as data? In this case, you remove the additional abstraction. It seems like Jai is going that route, where you pass an arena type instance around and interact with it.
- steveklabnik 2y agoData is at run time, but types (which lifetimes are) are at compile time. You may remove an abstraction, but you'd also lose efficiency.
- ergonaught 2y agoI do not understand taking so long to arrive at these conclusions. Each of them smacks you in the face pretty quickly if they bother you, so it's strange to invest so much time before deciding they are rant-worthy.