Live data from Hacker News

Is Rust Web Yet?

arewewebyet.org

101–110 of 183 posts

Re: Is Rust Web Yet?

#101

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 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 isn't perfect. In an absolute sense the C++ code you can write could be more correct and efficient(it just doesn't tend to be).

Re: Is Rust Web Yet?

#102
post #72

Earlier quoted context omitted.

Because Rust has a vocal community and that noise far over represents its usage here on HN. People aren’t searching for Rust much: https://trends.google.com/trends/explore?q=%2Fm%2F0dsbpg6,%2... Because it’s not a popular language, cobol and prolog are more popular: https://www.tiobe.com/tiobe-index/ And yet hardly a day goes by without a rust story on hn and for the past 5 years it’s scored most loved language on th…

Wasn't there an article on here the other day talking about how Rust will never make it into the kernel as-is? The sentiment seemed to be that the kernel developers simply reject the idea of packaged code and many of the modern paradigms in Rust. I only had a chance to skim it but it made it sound like Rust in the kernel would be forced/relegated to a very different usage and style compared to the way it is written e…

[deleted]

Re: Is Rust Web Yet?

#103

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…

Of course you will also write the 5% edge case where you've wrongly convinced yourself that it's fine. In general the sort of self-discipline that would likely ensure this doesn't happen also satisfies the borrow checker which might be why some people find this not a problem and others really struggle. Worth somebody studying perhaps.

Re: Is Rust Web Yet?

#105
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…

> I sometimes wonder whether people adopt Rust/Haskell/ReasonML for front-end work because they want it to feel like more of an effort than it otherwise would.

That's ridiculous. There's a lot of garbage to unpack in that sentence, but for example Rust's borrow checker provides valuable guarantees about your code and eliminates entire classes of bugs. It's not just wasted time. Haskell's purity and lazy semantics allows for equational reasoning and more composable abstractions. ReasonML makes it really hard to accidentally write a bug that crashes the program. Etc.

Just because you don't see why those things are valuable doesn't mean they aren't.

Re: Is Rust Web Yet?

#106
post #72

Earlier quoted context omitted.

Because Rust has a vocal community and that noise far over represents its usage here on HN. People aren’t searching for Rust much: https://trends.google.com/trends/explore?q=%2Fm%2F0dsbpg6,%2... Because it’s not a popular language, cobol and prolog are more popular: https://www.tiobe.com/tiobe-index/ And yet hardly a day goes by without a rust story on hn and for the past 5 years it’s scored most loved language on th…

Wasn't there an article on here the other day talking about how Rust will never make it into the kernel as-is? The sentiment seemed to be that the kernel developers simply reject the idea of packaged code and many of the modern paradigms in Rust. I only had a chance to skim it but it made it sound like Rust in the kernel would be forced/relegated to a very different usage and style compared to the way it is written e…

>I only had a chance to skim it

Here's your problem. No, that is not an accurate summary of the discussion. And the whole point of the dialogue between the kernel maintainers and the Rust developers to figure out what needs to be done to make Rust suitable for inclusion in the kernel - which has already resulted to changes in the Rust toolchain and standard library. So

> Rust will never make it into the kernel as-is

Is about the most negative possible way to frame it while being technically true. Nobody is suggesting that Rust be included in the kernel "as-is", they're suggesting that Rust be included in the kernel, and having a dialogue about what would need to be done on both sides to make that possible.

Re: Is Rust Web Yet?

#107
I really want Rocket to take off (no pun intended), but it reached v0.5-rc nearly a year ago, and has yet to even bump up to v0.5 proper. It's hard to feel confidence that it has the wings to be the future of Rust web given its current rate of development, which makes it hard to justify using in a work setting.

Does anybody have more insight into its development status?

Re: Is Rust Web Yet?

#108

> "Yes! And it's freaking fast!" They're surely not talking about compilation times. Admittedly it's been a few years since I tried to build a web stack in Rust, but I felt like I was back in the 1990s dealing with the long compile times on modern hardware. Diesel was such a nightmare to use. It was poorly documented, and took a long time to compile even trivial example projects.

Some web frameworks are much worse about compile times than others. I've heard Actix and Warp are not great at this, and that Axum is much better.

Re: Is Rust Web Yet?

#109
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…

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/Mutex to overcome some of these and review them in a refactoring.

> - ease of iteration

At the cost of introducing a bug/technical debt.

Re: Is Rust Web Yet?

#110
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?

> how does the KLOC count compare for the PHP and Rust versions

I don't have exact numbers since it's not a straight port — the original PHP code was written to analyse a slightly different language than the Rust version I'm building.

I'd estimate that Rust requires you to be about 10% more verbose than PHP. Main annoyances vs PHP: no default argument values, and only a single let allowed inside an if conditional.

Post reply on HN