Earlier quoted context omitted.
> The Rust version requires you to use your intuition to figure out that `unwrap()` will never panic here. You should not use `unwrap` in a production product. It's there for prototyping and I think it's a mistake they have it (though the language already requires a good upfront time investment as it is). Use `?` and have your error propagate accordingly to the top of the chain. Have your own error types and convert…
We tried this style in one of Google Earth's packages for a while (using an internal C++ class similar to Rust's Result). So many operations could theoretically fail (e.g. indexing out of bounds or an expected key not existing) that pretty much every single function in that package returned a Result. These "unexpected" errors would just fly up the stack, manually unwinding it, because nobody could really do anything…
Is Rust Web Yet?
151–160 of 183 posts
Re: Is Rust Web Yet?
#152Earlier quoted context omitted.
I have been toying around with Axum a bit and it is nice as a web framework. I really appreciate the many examples in the repo. Having come from python (day job) I did hit a screeching halt when it came time to meaningfully interact with a database. It is unfair to compare Rusts current offerings to something as mature as SQLAlchecmy but boy does it slow things down dev wise to be mapping my own types and queries usi…
I am picking up SQLAlchemy as a long time Django ORM user. I’m somewhat wide-eyed at how much simpler and more readable query building is in Django. I have been spoiled. SQLAlchemy is closer to SQL than I generally want to be for pedestrian web programming. It also lacks conveniences I’ve taken for granted writing Django backend. Even for writing data migrations in scripting, having ORM queries be incredibly simple t…
Re: Is Rust Web Yet?
#153Earlier quoted context omitted.
The 3x speed increase is interesting. Do you have any further details?
Yes — that's after a ton of Rust-centric optimisation. About 25% of the runtime is currently consumed with deallocating memory (there are a lot of heavily-nested data structures getting cleaned up), so there's definitely some more work to be done to reduce cloning.
Re: Is Rust Web Yet?
#154Earlier quoted context omitted.
> Things I've lost: > - ease of iteration > - concise, readable code Ouch... then it's a big nope for me.
When a person converts their 100 KLOC PHP command line utility(!) to Rust and that's not a bigger red flag than their negatives list, it's a world gone mad.
I'm not converting, I'm just porting a good chunk of it for a slightly different purpose.
Not sure what's a red flag -- the original PHP utility has 17 million downloads and people are pretty happy with it.
Re: Is Rust Web Yet?
#155Earlier quoted context omitted.
> Rust code is significantly more readable. You should put down the Rust kool-aid. Rust is incredibly hard to read due to its sigil and abbreviation heaviness.
I think that's obviously a matter of opinion. I don't think Rust is hard to read at all, nor do I think of it as being particularly sigil heavy, but that's me. I think the syntax is probably unfamiliar for some, and familiarity is almost always what people mean when they say "readability". Coming from c++, Rust was pretty familiar. PHP isn't that hard to read either.
Maybe all this is necessary for a system level programming language, fine, but don't tell me this is easy to read.
Re: Is Rust Web Yet?
#156Earlier quoted context omitted.
I disagree on the things you've lost. > - concise, readable code Rust code is significantly more readable. Use the type system to your advantage. > - - really smart type inference Rust has really smart type inference too and only rarely ask for an explicit type. I've found that I prefer annotating my types. It adds to documentation and readability. > - a bunch of time thinking about the borrow checker You can use Arc…
> Rust code is significantly more readable. You should put down the Rust kool-aid. Rust is incredibly hard to read due to its sigil and abbreviation heaviness.
Re: Is Rust Web Yet?
#157Earlier quoted context omitted.
> has a lot of corner cases it can't catch The instances of safe code that the borrow checker can't verify as such are not "corner cases" by and large, they're genuinely non-trivial patterns, often with non-obvious drawbacks such as lack of composability/modularity. Rust devs and researchers are working on better abstractions to support those cases, but these are very much the exception, not the rule. > people routin…
>People should stop freaking out about this. The "more inefficient code" you might get by adding a few .clone() or Rc > when the borrow checker complains about something is still way more efficient than anything written in alternative "safe" languages. But you don't have to use a "safe language". C++ can avoid a lot of copies and be just as safe from an absolute point of view. The borrow checker isn't god and Rust is…
Re: Is Rust Web Yet?
#158Earlier quoted context omitted.
Someone hands you a waffle head hammer seems like a more apt comparison. If you can get the hang of it, it’s a safer hammer. You’re still going to be manually managing your memory allocations though. The nailgun people have garbage collection (and yes for the gc folks, I’m aware you can still write allocation free code, or at least take manual control of allocations in a garbage collected language and therefore opt o…
I'm not sure what you mean by manually manage. I don't manually manage my memory anymore in Rust than I do in garbage collected languages (say Python or Go). (I do have to think about object lifetimes and whats pointing where in all three mentioned languages). As an aside, I really like not having to manually free locks, close files, release connections back to pools, etc. It's one resource management paradigm that a…
This is the (in my opinion) insurmountable difference between low and high-level languages. Even though rust is (arguably) probably the best/most readable low-level language that as you note can sometime even beat managed languages (locking/file close), it will loose to major refactor-speed.
Re: Is Rust Web Yet?
#159And the second realization is that the idea of polyglot programming has utterly failed. A lot is due to what kinds of APIs can be exposed between components, and that seems like an inherent problem of communication between different languages.
But there are other areas where you'd think we'd have wider agreement by now: the semantics of data types, runtimes, ABIs, memory layouts, etc.
I guess there are lots of reasons for differences. But it's kinda sad how much effort is spent re-writing stuff that already exists and works in a different language.
Re: Is Rust Web Yet?
#160Earlier quoted context omitted.
> I spent about the past month learning rust This is a red flag for your complains: Is VERY likely you believe Rust is wrong, when the fact the problem is that your code is not good. I know this, my first 3 months starting Rust were thinking between "I'm a failure as developer" and "Rust is wrong" or "What? Why can't do this?". For first time after learning more than 12 languages I was truly in shock. And even, for s…
shrugs Who knows, maybe rust clicking for me was just around the corner. I kept thinking "finally I'm understand this" and then something else would happen. I'll leave it to the incredibly patient programmers who can spend 3 months just learning it. I'll use all the time I save to write more tests, and probably end up with something much more correct.
After all, you are human, and we humans aren't good at exhaustive covering of all bases. Sometimes when I am reading a rust compiler error message about erroneous borrowing I really wonder that I never could have thought about that corner case.
It's true. Sometimes Rust compiler's pedantry is just not neccessary. Then write Python, TypeScript, Ruby or in Rust box, arc and clone everything.