Live data from Hacker News

Is Rust Web Yet?

arewewebyet.org

141–150 of 183 posts

Re: Is Rust Web Yet?

#141
post #94

Earlier quoted context omitted.

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

I guess, but if you're just building some basic CRUD app that's never going to change, why would iteration speed matter anyway?

It's more a CRUD app that has many features added in the first six months, and fewer features added thereafter, and then a few months go by and a new developer takes over and has to figure out how to add yet another feature.

That model favours easy-to-google frameworks with wide ecosystems.

Re: Is Rust Web Yet?

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

> I think your "ease of iteration" point will still probably win for PHP vs any compiled language.

While I don't think you can beat straight php/js/python for this, there's still a lot of room for improvement over the rust/c++ magnitude of compile times.

For example Go/OCaml/Common Lisp (at least, SBCL is a compiler, there are lisp interpreters), all have reasonably quick compile times. And the latter two have repls, which really does help improve the iteration cycle.

I haven't had to play with crystal, where does it fall on this spectrum?

Re: Is Rust Web Yet?

#143
post #9

This content, while still accurate (Rust is Web-ready, and all the frameworks listed are excellent!), is missing out a few credible and recent options. In particular I want to shout out for Axum ( https://github.com/tokio-rs/axum ), from the folks who brought us Tokio. I've been building with it for the past few weeks and have enjoyed every minute. I started with Warp, but ended up struggling a bit with middleware. I…

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 to read and modify is extremely valuable, it makes code reviews accessible to more people.

I’m not a rust developer, though I admire what it can do. That said, having looked at the starter queries on each, it would take a lot to make me contemplate use of any of the rust-based ORMs you’ve listed.

As a sibling comment points out, typing and async are valuable and Django has no typing and is still working on delivering async support in its ORM.

That said, for web products reducing time to flipping feature flags seems to be the main goal.

In that way Python / Django and I suppose even SQLAlchemy will probably retain users against Rust.

Re: Is Rust Web Yet?

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

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?

#145
post #8

> Yes! And it's freaking fast! Going by these benchmarks (click around to find your own use case) Rust is definitely fast, but not (much) faster than many other languages, including Javascript. https://www.techempower.com/benchmarks/#section=data-r20&hw=... When it comes to JSON serializers, there is a Java framework that is faster than Rust, which is interesting to say the least. When you start comparing actual full…

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.

The author of just-js did a write up about how he got that performance: https://just.billywhizz.io/blog/on-javascript-performance-01...

Re: Is Rust Web Yet?

#146
post #72

Earlier quoted context omitted.

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…

Thanks. I’m not going to delete or edit my original comment, but I will say my question was meant in good faith without the intent to cast shade. I’m really surprised I was downvoted. I know next to nothing about rust beyond a fleeting hour or two I’ve spent with it, but I don’t think the way I phrased my comment was any worse than the off-handed remarks made in that article. Perhaps it’s neither here nor there but I’ve worked a lot lately. I’ve worked more than I care to admit for reasons completely beyond my control. I still try to keep up with stuff like this because I care. I love my work and this industry. I’m doing my best.

Re: Is Rust Web Yet?

#147
post #9

This content, while still accurate (Rust is Web-ready, and all the frameworks listed are excellent!), is missing out a few credible and recent options. In particular I want to shout out for Axum ( https://github.com/tokio-rs/axum ), from the folks who brought us Tokio. I've been building with it for the past few weeks and have enjoyed every minute. I started with Warp, but ended up struggling a bit with middleware. I…

You might be interested in our community interview with Tokio Axum maintainer David Pedersen. It is recent and covers a lot of intermediate Axum stuff. https://www.youtube.com/watch?v=nZLimYT4EHs

Re: Is Rust Web Yet?

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

> 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.

Re: Is Rust Web Yet?

#149
post #125
post #115

Earlier quoted context omitted.

Rust noob here but couldn't you write if let Some(element) = some_vec.first() { println!("{}", element); // .. more code } and avoid the unwrap and the empty check? Edit: Added a `let` I had forgotten.

Yes, but IMO that makes the code a bit more abstract: You've left behind an explicit "is this collection non-empty" and you're instead relying on a property of a non-empty collection. The PHP version can also be written as if (($element = reset($some_arr)) !== null) { echo $element; } But that code is similarly divorced from the imaginary pseudocode equivalent

> Yes, but IMO that makes the code a bit more abstract:

> You've left behind an explicit "is this collection non-empty" and you're instead relying on a property of a non-empty collection.

More abstract for who? I think virtually all Rust programmers would easily understand the `if let` snippet, virtually all PHP programmers would understand the PHP snippet, and virtually all programmers of any language would understand that a non-empty array has a first element. I'm not at all convinced that most programmers would correctly guess that a function called `reset` is used to access the first element in an array though.

Re: Is Rust Web Yet?

#150

Earlier quoted context omitted.

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

The time it takes to run `cargo check` is nothing compared to dealing with bugs, terrible tooling, weak errors, etc. All of those areas have been radically better with Rust. As an example, type errors in Rust are radically better than mypy, it's no competition. In general rust's type system is just way better, we have to use Any all over the place because mypy can't even handle a Json type (no recursive types at all)…

Check out pip install -c constraints.txt for the equivalent of lock files.
Post reply on HN