5 ms·
Here's a story: I once did a hackathon with a few acquaintances for a few hours where our goal was to write a simple Matrix bot. Given that we were always chatt
by cedws 5y ago
Here's a story: I once did a hackathon with a few acquaintances for a few hours where our goal was to write a simple Matrix bot. Given that we were always chatting about Rust, a couple chose it for their bot. I chose Python.
My basic bot was done in about an hour. One of the guys took about an hour to try and compile an outdated, abandoned crate for interacting with the Matrix API. I recall he then had to write his own using async/futures. It took him about 6 hours and he was working well into the early morning after we'd already left. The resulting code was hideous - a slurry of nested closures, ?s, unwrap()s everywhere. The compiler was throwing demonicly complex compile errors at him and he was doing whatever he could to get it just to compile. Bearing in mind he was not new to the language.
No, I'm not arguing that Python is better, these languages clearly have a different purpose. I'm arguing that if it takes a really smart guy like him more than 6 hours to produce something of that quality in Rust then... it's not for me. I've already tried it and development with it is just slow and I don't like several syntax decisions. Not to mention the crate ecosystem which is primed to be the new npm disaster.
- smt88 5y agoOptimizing for the first 6 hours of development is insane and also the reason we have so many towering piles of unmaintainable garbage in our industry. Rust is the wrong language for a hackathon, but hackathons are an extreme edge case. Most devs work on large, aging code bases built by other people. Rust and similar languages make that work much less error-prone. Who cares if it's not good for a hackathon?
- cedws 5y agoWhat should the expectations be then? I don't think 6 hours is an unreasonable timeframe to produce a Matrix bot in any language (we're not counting esolangs of course). It's a POST request, I mean come on. Maybe a GET long poll as well. How long should it take in Rust?
- option_greek 5y agoIt takes a couple of lines to call any API in Rust using reqwest: https://github.com/seanmonstar/reqwest https://github.com/seanmonstar/reqwest I'm not sure where this 6 hours for matrix bot thingy comes from. A better comparison would be to write something from scratch or use comparable frameworks.
- Ygg2 5y agoIt's not just where. It's when. I suspect it's true but like a few years ago (I haven't really monitored Rust due to real life work).
- blub 5y agoI don’t think it’s just 6 hours. Rust requires more up-front design both during initial development and when doing maintenance compared to Python. One has to specify things in much more detail when writing Rust and sometimes that’s great, but other times it doesn’t really matter much. Many times one doesn’t really care about the overhead of GC or that values a copied a lot. I’ve always written default-efficient code myself (mostly in C++) and using Python exclusively and over a longer time period for data wrangling was an educational experience. It feels quite liberating to just write code without having to think at every point about efficiency and memory.
- shepherdjerred 5y agoEvery language has its appropriate uses. Maybe this isn't where Rust shines. Do you need type safety or static type checking? Are you dealing with concurrency, or need the performance that manually managing memory provides? Do you want safety when doing low-level operations such that the compiler can eliminate many classes of mistakes? Rust might be the right choice. Are you trying to write a throwaway chat bot for hackathon and you only have a few hours? Rust probably isn't the right choice unless you're very, very skilled.
- otherme123 5y agoI find Nim performant enough while having a GC. Also type checking. And the productivity is on par with Python, easily.
- c7DJTLrn 5y agoThat's the only kind of context I think I'd use Rust in personally - embedded, bare metal, low level stuff. Certainly not for userspace or web applications. But a lot of projects are using it anyway even if something simpler and more mature will suffice.
- Ygg2 5y agoWhat I got from your anecdata is this: - Rust isn't good at writing scripts (one-off code) - 30 year old language with massive popularity has better libraries than a relatively unknown 6 year old one. - Rust async isn't mature enough.
- fnord77 5y agonow let's imagine this matrix bot becomes a product, running on thousands of servers. the python version is 100x less energy efficient than the rust version. that 5 hours extra work now becomes a bargain.
- blub 5y agoBuilding V1 in a rapid development language and porting to a performant language when scale becomes an issue is a pretty popular pattern. Personally, I wouldn’t prototype in Rust either, but OTOH I’m not experienced enough in it.
- fnord77 5y ago> Building V1 in a rapid development language and porting to a performant language when scale becomes an issue is a pretty popular pattern. I'd say building V1 in a rapid development language and then never porting it while trying to scale it up is an even more popular pattern. There are some massive web applications out there running on hopelessly outdated Django
- c7DJTLrn 5y agoNot so sure about that. JITs can be fast, faster than C or Rust in some circumstances. Besides, the code was a trainwreck.
- axiosgunnar 5y ago> faster than C or Rust in some circumstances how?
- jph 5y agoDynamic optimizations for the specific target machine and also long lifetimes. For example when a specific target machine has a specific CPU instruction that the JIT can leverage, or has a ton of RAM that the JIT can use for caching such as for memoized methods.
- 5y ago