Live data from Hacker News

Using Rust at a startup: A cautionary tale

scribe.rip

91–100 of 134 posts

Re: Using Rust at a startup: A cautionary tale

#91
post #61

Rust has brought so many great ideas into the programming mainstream. It is a shame that it has also attracted such a community around it that seems to project all sorts of hopes and wishes into the language. I don't get how someone could think making a CRUD app in Rust could ever be a good idea (beyond hobby projects). That is just not playing to the strengths of the languages at all. If you CAN use a language with…

I worked at a company where a principal developer got tasked with building a CRUD app. He worked in a silo on it, coming back in 3 months with a CRUD app... written in Scala with heavy use of scalaz. It was a CRUD app that was scalaz features to defer the entire execution until runtime. Nobody could understand the code at all. The team ended up replacing the entire functionality in less than a week using Python+Flask…

[deleted]

Re: Using Rust at a startup: A cautionary tale

#92

Earlier quoted context omitted.

Oh, wow, yes. I confess I skimmed the part about green threads. I think OP doesn't understand that runtime features like GC and green threads have a cost, and Rust is designed around a making it safe to avoid that cost. Most of Rust's features don't make sense in the context of a managed runtime—what you would be left with is basically a subset of OCaml with C-style syntax and optional mutability.

> Most of Rust's features don't make sense in the context of a managed runtime I don’t think that’s entirely true actually (which is why linearity is explored in languages like haskell). For instance Go makes it easier to trigger data races, which undermine memory safety. This is a managed langage “built for concurrency” where using concurrency means memory safety is at risk. And that’s not recent news, Russ Cox hims…

True, but linearity/affine types applied carefully in the context of a managed runtime would look quite different from Rust's borrow checker. The reason why Rust's borrow checker is so infamous is because Rust has to prove everything at compile time. Bringing affine types to a GC language would most likely involve making them opt-in (or only triggered in concurrent situations), while making linearity optional in Rust would undermine its foundations.

Re: Using Rust at a startup: A cautionary tale

#94

Rust has brought so many great ideas into the programming mainstream. It is a shame that it has also attracted such a community around it that seems to project all sorts of hopes and wishes into the language. I don't get how someone could think making a CRUD app in Rust could ever be a good idea (beyond hobby projects). That is just not playing to the strengths of the languages at all. If you CAN use a language with…

> I don't get how someone could think making a CRUD app in Rust could ever be a good idea (beyond hobby projects).

Me either, and I've said that before on HN. There is, however, a Rust lobby for CRUD apps. Those are the people who are pushing hard for "async". "Async" has its uses, but you don't really need it unless the load on your server has many thousands of concurrent connections, most of which are waiting. The OP here points out that his load is nowhere near that high. Python or node.js would work. Maybe even PHP.

If you need to write CRUD apps with high performance, use Go. That's what it's for. The libraries for what you need probably not only exist, but are running in production on warehouse-sized server farms.

I've been writing a metaverse client in Rust for two years, and I'm about 35,000 lines of safe Rust in. Separate threads are rendering, processing incoming messages from the network, updating the world state, fetching assets, and moving objects that are in motion, all in parallel. There's a lot of heavy machinery. Rust is good for this sort of highly concurrent problem. There have been no bugs in my code that required a debugger. (An early version of the rendering library I use, which is unsafe, caused trouble requiring using a debugger back in 2020. Took about 20 minutes to find the problem.) Rust is the right tool for the job for this sort of thing. I'd need a sizable team to do this in C++, and far more debugging.

As the original poster points out, and as some game devs have mentioned, the safety issues do slow development. You can paint yourself into a corner, where no easy fix will satisfy the ownership rules. It can take a week of rewriting to get out of that. Sometimes longer. Anything where an object needs a connection to its parent is unwieldy in Rust. You can do it, but soundness requires you do it through forward reference counted pointers and backwards weak pointers.

Re: Using Rust at a startup: A cautionary tale

#95

Earlier quoted context omitted.

> Most of Rust's features don't make sense in the context of a managed runtime I don’t think that’s entirely true actually (which is why linearity is explored in languages like haskell). For instance Go makes it easier to trigger data races, which undermine memory safety. This is a managed langage “built for concurrency” where using concurrency means memory safety is at risk. And that’s not recent news, Russ Cox hims…

True, but linearity/affine types applied carefully in the context of a managed runtime would look quite different from Rust's borrow checker. The reason why Rust's borrow checker is so infamous is because Rust has to prove everything at compile time. Bringing affine types to a GC language would most likely involve making them opt-in (or only triggered in concurrent situations), while making linearity optional in Rust…

You can opt into runtime checking in Rust via interior mutability. Cell, RefCell, Rc, Arc, Mutex, Rwlock are constructs that involve varying levels of runtime checking - most of these will be way more efficient than GC. It's even simpler to use .clone() in order to effectively do away with any requirement for linearity.

Re: Using Rust at a startup: A cautionary tale

#96

One question though: What does Garbage collection do besides what Rust provide? Ownership and borrow checker.

Frees cognitive resources because you can usually forget that menory management is a thing. When on GC.

That also means that "soup of pointers" datastructures have a more fertile ground to sprout because there's no pushback to them, except by the developers themselves. I find that the memory patterns that the borrow checker dislikes are also the ones that tend to confuse humans.

Re: Using Rust at a startup: A cautionary tale

#97
post #32

> Because we had chosen an “esoteric” programming language for this service, the other engineers in the company who might have otherwise been helpful in building features, debugging production issues, and so forth were largely unable to help because they couldn’t make heads or tails of the Rust codebase. Then they are bad engineers and should be fired. Maybe it's just my general rage at so-called developers being inc…

I agree that it sounds like they're not the sharpest knives in the drawer, but completely disagree on the 'should be fired' part.

Re: Using Rust at a startup: A cautionary tale

#98
post #49

Earlier quoted context omitted.

Anecdotally I've been able to move faster with Rust on CRUD apps professionally than I've previously in other languages with GC built-in (e.g., C#, TypeScript/Node.js). The borrow checker isn't a problem after you get used to it. There is still a steep learning curve, although the learning curve has improved significantly over the past couple years. Rust's type system, syntax, and standard library are major strengths…

Rust has healthy friction and you learn how to avoid that friction. It might take you a bit longer to hash something out but chances are it will work first time, and will have better fundamentals in design.

I have a different experience with Rust these days. The errors that Rust throws are either the ones I had a vague hunch about or the ones I missed. It never feels like friction, but rather like helping guides. The error messages are informative and often very helpful in resolving problems.

The key, I believe is understanding the machine and memory model of low level computing. Rust errors immediately make sense in that context and it becomes easier to find a proper solution without having to work around it.

These days I feel much more comfortable with Rust than I'm with even Python. It feels like Rust does a lot of heavy lifting and thorough checking of a lot of semantics that's not possible in other languages. The worries about unforseen bugs are lesser (not zero, though) with Rust.

Edit: Phrasing

Re: Using Rust at a startup: A cautionary tale

#99

Earlier quoted context omitted.

Frees cognitive resources because you can usually forget that menory management is a thing. When on GC.

I usually don't think about memory management in Rust, to be fair. Also GC doesn't remove all resource management... ironically I find most GC-based languages to be more mentally taxing when managing manual resources (file handles, mutex locks, etc).

Haskell programmers says that Haskell is just fine as well, but in the end there aren't many big programs with complex architecture in these languages. Compilers, interpreters, crud servers etc, those things are very simple architecturally so for them these languages are fine, but for more complex cases these pure languages seems to be too cumbersome.

Re: Using Rust at a startup: A cautionary tale

#100
I have been shocked on multiple occasions to see how difficult teams make it to do basic CRUD apps.

Go lang is suggested rather than Rust, but the standard way of using Go is lower-level and less productive (unless you care about performance) than the Rails of 10 years ago (and I am not a fan of Rails).

Haskell can be a great option here- all the high level benefits of Rust and more in a language with a GC and plenty of good frameworks and libraries for CRUD. Unfortunately its one of the only languages that has a greater learning curve than Rust.

Post reply on HN