Live data from Hacker News

Is Rust Web Yet?

arewewebyet.org

91–100 of 183 posts

Re: Is Rust Web Yet?

#91

Earlier quoted context omitted.

My company has its code basically split in half between Python and Rust. Our Python code uses mypy pretty aggressively. The iteration speed difference is... drastic. Rust far outshines Python in terms of our ability to get something done, maintain it, and iterate on it over time.

Did you mean to write that python beats rust? I find it hard to believe Rust is faster to 'get something done' than Python. Happy to be proven wrong, of course.

Nope, it's written correctly as-is. Probably the "time to tests pass" is about equal, but the iteration and maintenance is far better in Rust.

Re: Is Rust Web Yet?

#92
post #71

I've spent the last few months porting the guts of a 100 KLOC PHP command-line utility I wrote to Rust. Thanks to the wonderful Rust documentation it's been a mostly painless endeavour. What I've gained as a result: - execution speed (about 3x faster, single-threaded) - better-documented data structures Things I've lost: - ease of iteration - concise, readable code - really smart type inference - a bunch of time thin…

My company has its code basically split in half between Python and Rust. Our Python code uses mypy pretty aggressively. The iteration speed difference is... drastic. Rust far outshines Python in terms of our ability to get something done, maintain it, and iterate on it over time.

My impression has been that python is easier to iterate on over the course of a week, while Rust is easier to iterate on over the course of a year.

Re: Is Rust Web Yet?

#93
post #71

I've spent the last few months porting the guts of a 100 KLOC PHP command-line utility I wrote to Rust. Thanks to the wonderful Rust documentation it's been a mostly painless endeavour. What I've gained as a result: - execution speed (about 3x faster, single-threaded) - better-documented data structures Things I've lost: - ease of iteration - concise, readable code - really smart type inference - a bunch of time thin…

You may want to check out Crystal https://crystal-lang.org/ -- you will get all of the positives you describe, while avoiding perhaps 3 out of 4 of your listed negatives. (I think your "ease of iteration" point will still probably win for PHP vs any compiled language.)

Also, I'm very curious: how does the KLOC count compare for the PHP and Rust versions?

Re: Is Rust Web Yet?

#94
post #85

Earlier quoted context omitted.

That's great for you and your team, but looking at https://github.com/grapl-security/grapl it seems like your needs are pretty different from most web developers.

How so? We use many of the crates listed on the linked page - sqlx, rusoto, actix-web, tower/tonic, etc.

Yeah, but the thing you're building is quite a bit more complex than the average consumer-focussed website.

Re: Is Rust Web Yet?

#95

Earlier quoted context omitted.

Not that I think those metrics are all that relevant, but can someone explain to me how just-js ranks so highly? Very much defying my expectations in comparison with some of the top representatives of compiled languages.

If you look at the techempower submission source code you'll quickly see why: https://github.com/TechEmpower/FrameworkBenchmarks/blob/mast... .

I so deeply wish for a set of benchmarks that accepted only idiomatic, standard code that a slightly above average developer would plausibly write.

Pretty much every set of benchmarks out there is ruined by monstrous unrealistic code that squeezes out 5% more performance than actually well written code.

As a side note, one flaw of TechEmpower benchmarks is that to my knowledge they use the original "wrk" tool, which only supports HTTP 1.0 and is sensitive to "coordinated omission" [0]. This means it ends up being biased in favor of web frameworks that implement specific optimizations or have specific behaviors that aren't actually useful in a production context.

[0] https://github.com/giltene/wrk2

Re: Is Rust Web Yet?

#96

Earlier quoted context omitted.

Did you mean to write that python beats rust? I find it hard to believe Rust is faster to 'get something done' than Python. Happy to be proven wrong, of course.

Nope, it's written correctly as-is. Probably the "time to tests pass" is about equal, but the iteration and maintenance is far better in Rust.

> but the iteration... is far better in Rust

That is something I would find hard to believe, if you mean iteration of changes. I have coordinated a few rust rewrites, and at least seeing engineers live programming, it takes far far longer to change and compile Rust code than python.

Could you talk more about your company's process or how you mean?

Re: Is Rust Web Yet?

#97

Earlier quoted context omitted.

Not that I think those metrics are all that relevant, but can someone explain to me how just-js ranks so highly? Very much defying my expectations in comparison with some of the top representatives of compiled languages.

Those benchmarks are pretty heavily gamed. Think about things like hardcoding "Content-Length: 123" instead of computing the length at runtime.

I wish benchmark suites would reject those kinds of shenanigans, it's completely ridiculous and makes the results practically worthless.

Re: Is Rust Web Yet?

#98

I spent about the past month learning rust - and decided it just wasn't a usable language for me. I think what it comes down to is that I'm just not that into bondage and discipline from a compiler. Yes, I know, it's trying to make my code 'safe', and I'm horribly cavalier and I should feel bad, but: 1. the borrow checker rejects valid programs, has a lot of corner cases it can't catch, and is in active development 2…

> 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 routinely write more inefficient code to satisfy it

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.

The "slow" solutions are a bit noisy but that's a good thing, since it tells you where it might be worthwhile to either refactor for efficiency or document why a refactor isn't feasible.

Re: Is Rust Web Yet?

#99

Earlier quoted context omitted.

Just curious, what was your programming background. Have you used C++ a lot especially “modern C++”? I find that as a C++ programmer, Rust encodes in the compiler a lot of best practices about ownership and memory management. Using Rust is a breath of fresh air in not having to worry about dangling references. From experience programming C++, I can see what the error messages are trying to prevent and why it is impor…

I had a stint as a C++14 programmer, and I switched over to C++20 for this project. You covered the downsides pretty well, big upsides for C++: - ability to use C libraries directly - and thus original C API docs. I've got battlescars from NPMs deep dependency trees, and cargo is a similar story. - I don't need the (very patient and knowledgeable!) people on rust discord to hold my hand every day. There's a stackover…

> ability to use C libraries directly - and thus original C API docs. I've got battlescars from NPMs deep dependency trees, and cargo is a similar story.

This is something Rust is relatively good at, you just may need some unsafe blocks, but assuming you can compile using clang for the C code everything tends to work well. I am saying this as a Rust skeptic.

Re: Is Rust Web Yet?

#100

Earlier quoted context omitted.

Imagine your job is hammering nails. Eight hours a day for twenty years. You’ve hammered 403,286 nails. And then someone shows up and hands you a nail gun. Rust makes me happy because we speak the same language. Stuff gets done and I go home at 4:30 and play with my kids instead of my compiler.

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…

>You’re still going to be manually managing your memory allocations though.

I'm writing a 10,000 LoC library and I call drop() manually only 3 times, in exactly one place, and not for memory reasons. I'm not sure what you mean. If you mean thinking about lifetimes, sure. If you mean thinking about drop(), almost never.

Post reply on HN