4 ms·
I don't have any experience in Rust. From what I read, Rust is a low level / system programming language. Comparing to dynamic languages like Python, I understa
by dvnguyen 9y ago
I don't have any experience in Rust. From what I read, Rust is a low level / system programming language. Comparing to dynamic languages like Python, I understand that Rust is much faster. However, Python is fast enough for most web applications. So why should I use Rust in web development? Even if the library ecosystem were mature enough, could I expect my productivity could become nearly high as in Python?
- kibwen 9y agoI'd say it's true that Python is fast enough for most web servers. Rather than strictly considering performance, I'd guess that people seeking to do webdev in Rust are looking to leverage Rust's static analysis to improve resilience, trading off up-front productivity for long-term maintainability (which isn't to denigrate Python, which I love, but fearless refactoring really is something that compiled langs excel at). It's not the right tradeoff for everyone or every application, certainly. And maybe other people just really like Rust. :P
- kevan 9y agoWe also shouldn't discount it just because Python is usually fast enough (all my personal projects are in Python). Developer time is cheaper than hardware 99% of the time. For the 1% that are running millions of requests per second through their web stacks the value proposition is pretty compelling.
- OJFord 9y ago> fearless refactoring really is something that compiled langs excel at Would you say that's a feature of compilation? I'd have said it's Rust's strong and static type system that makes refactoring 'fearless' and generally aids productivity and maintainability. Python ≥3.6 with liberal type hinting is a more interesting comparison in my view.
- zem 9y agoone nice use case is to add a quick web frontend to a rust project.
- fiedzia 9y agoIn terms of ecosystem maturity Rust is far behind Python, but ignoring that and performance, it still has some merits: - static analysis helps you avoid numerous issues that plague Python. Runtime errors are far less likely and you are forced to greater discipline when coding - it is modern language. After using algebraic data types, pattern matching and traits it is hard to go back to old style OOP. - You can extend existing types with your own traits, and so can library authors, so you have plenty of extremely useful extensions. Just add use clause referencing some library, and everything gets more useful methods, without any magic or monkeypatching, so it causes no issues as it could in some dynamic languages. I'd say it is massive gain in terms of quality and maintainability, but at the cost of upfront investment. Rust isn't a language I'd expect people to write prototypes in, but with few crates it can be as expressive as Python in many cases.
- pimeys 9y agoHaving written tons of Python, Rust and several other languages, I have to add one more thing: - The Cargo dependency and build tool is the best in any ecosystem. Easy to configure, works like a charm and gets improvements done regularly. I don't miss setup.py/virtualenv/pip/pex at all.
- Scarbutt 9y agoRust doesn't have a stable/mature HTTP implementation/abstraction yet.
- bluejekyll 9y agoHyper is pretty darn good and I haven't seen issues with it not being mature.
- Scarbutt 9y agofrom hyper's readme: Be aware that hyper is still actively evolving towards 1.0, and is likely to experience breaking changes before stabilising. You can also see the 1.0 issue milestone.
- pimeys 9y agoWe push millions of requests daily through Hyper 0.11, which is async and uses tokio. I've had crazy three month uptimes for these systems. Basically they just do their work fast and I don't really need to focus on fixing any problems with them. And did I tell my test coverage is quite minimal with these projects.
- zanny 9y agoIt takes longer to get the code to compile, but once it does the integration pains and debugging needed will be significantly less. I'd absolutely argue that productivity can be higher in Rust, especially the larger the project is, or the longer you expect to support it for. A lot of what people miss when approaching Rust is that writing libraries is really hard and time consuming, but writing applications using libraries is often as easy as Python. Libraries need to provide abstractions, and thus use really complex features like code generation macros, trait extension, generics, type conversion, and the annoying lifetimes that most people beat their heads on when first learning Rust. Rust for an application developer feels almost entirely OOP, like Java, and much nicer than C++ because simple data structures don't hit undefined behavior every other line with the other half being full of memory leaks.
- pimeys 9y agoIt's not that bad. Having written some Rust libraries, there are things to like that the other ecosystems don't provide. One is the rustdoc, where you document your interfaces in code, and if you write code examples in the documentation, `cargo test` will automatically check that they work. And like I said in another comment, there is nothing as good as cargo in anywhere else.