Hacker News new | ask | show | jobs
by rtpg 59 days ago
For a server using a DB, all of your methods are calling out to data stores. So you're like "OK I receive a &connection" but all the mutability is hidden inside.

There's a bunch of type direction you can do to get around this (`ReadConnection` vs `ReadWriteConnection` and some other magic), far from an immediate win but it's not impossible.

People talk about mutability a lot but the vast majority of Python code I see in the wild is SSA and has _very_ little mutability to begin with.

Of course ownership still has its costs. Lots of "I guess I'm copying this dict because I don't know if the owner will modify it or not" issues.

I think people overestimate how much they'll get from `&mut` annotations on business logic, and undersestimate how much line noise they'd get from a lot of the other stuff that happens in a lot of business logic.

Granted, I'm coming from a web-dev/Django perspective, where duck typing and overriding methods in subclasses is used heavily. And a lot of that doesn't have a nice 1:1 equivalent in the Rust model.

(I enjoy Rust BTW, just don't feel particular excitement about shuffling around strings in it)

1 comments

not everyone is writing simple web servers :) and if you are, then the rust is easy to read as it's simple. I also use django in some large projects, and don't see a future of my use of django really anymore. If I'm not feeling like rust is a great fit, I usually reach for Java with javalin.