Live data from Hacker News

Is Rust Web Yet?

arewewebyet.org

161–170 of 183 posts

Re: Is Rust Web Yet?

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

Only 3x speed increase feels like either did PHP a very good job or the port is not optimized for rust yet.

Re: Is Rust Web Yet?

#162
post #111

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…

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

> 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'm gonna be blunt: This is the worst thing to come out of the Rust community, bar none. Rust is a fine language and I love to write in it, but I loathe the way Rust developers have convinced themselves that Rust is an axiomatically 'better' language and that the things you can't do in Rust, or the things that are painful to do in Rust, are a perfect circle venn-diagram overlap with the things that are just bad to do in general. It's a mindset that shuts down discussion and constantly shifts goalposts. It doesn't help anyone.

Re: Is Rust Web Yet?

#163
post #131
post #118

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…

> don't "convert" PHP code into Rust. Re-design your program. Trust me, I am! For example, I'm rewriting all the (very-efficient) PHP regex code to a much more convoluted version because Regex::new is so costly. Less sarcastically, I am embracing the Rust Way where necessary. My complaint is that the Rust Way sometimes forces me to depart from the idealised pseudocode version of a given algorithm much more drasticall…

Any reason why you can't put the Regex in a once_cell and then keep on applying it?

Re: Is Rust Web Yet?

#164
post #54

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…

> 3. people routinely freak out about 'unsafe', which is a bit much given the first point [borrow checker] It sounds like you're making a common misconception here. unsafe code and the borrow checker are not closely related, and unsafe blocks are not a way to play fast and loose with ownership issues. See https://steveklabnik.com/writing/you-can-t-turn-off-the-borr... If you don't want to deal with the borrow checker…

You can unsafe to get around the borrow checker, just not directly; you have to go through raw pointers.

Re: Is Rust Web Yet?

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

>really smart type inference

Are you calling php's chaotic mess of type juggling "really smart type inference"?

Re: Is Rust Web Yet?

#167
post #144

Earlier quoted context omitted.

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.

what's the total running time? ms/sec/minutes/hours? is it heavy IO bound?

A few minutes.

It's not heavily IO-bound — it's mostly memory-bound (it's a type-checking tool for very large codebases).

Further (painful) optimisations will likely involve the use of arenas to prevent so many atomic de-allocations.

Re: Is Rust Web Yet?

#168
post #161

Earlier quoted context omitted.

The 3x speed increase is interesting. Do you have any further details?

Only 3x speed increase feels like either did PHP a very good job or the port is not optimized for rust yet.

A bit of one, a bit of the other. It's fairly well-optimised. I think the big remaining optimisation will be to de-allocate memory less frequently — the program creates and destroys millions of structs representing types. 20% of the runtime is taken up iterating over and dropping collections of type-related structs.

Re: Is Rust Web Yet?

#169
post #154

Earlier quoted context omitted.

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.

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

It was a joke. It's great that people like your utility, and that you're trying Rust.

The source of my amusement was -- I really, really don't see the world the same way as you do.

I won't take your negatives point by point, but, for instance, familiarity and readability do really seem to be in the eye of the beholder, because, to my eyes, to call PHP concise and readable, especially as compared to Rust, is a spit take. PHP is emphatically not readable to me. Writing a 100KLOC project in PHP? Ugh. Yeah, you do you, but not this guy.

Re: Is Rust Web Yet?

#170
post #155

Earlier quoted context omitted.

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.

No, what I mean is https://github.com/rust-lang/rust-wiki-backup/blob/master/Si... and that's just pointers, you have #[] #![] and then three ways to invoke a macro !() !{} ![] and of course a lot more. Maybe all this is necessary for a system level programming language, fine, but don't tell me this is easy to read.

I have no problem telling you that Rust is extremely easy to read.
Post reply on HN