Live data from Hacker News

Rust Is Surprisingly Good as a Server Language

stu2b50.dev

231–240 of 352 posts

Re: Rust Is Surprisingly Good as a Server Language

#231

Earlier quoted context omitted.

Other languages are able to compile much faster than Rust on the same hardware. So while adding hardware helps (up to a point), Rust is definitely an outlier when it comes to compilation speed.

This really isn't true compared to C++. Also Rust is doing more than basically every other language, so it's provably slower.

I don't have a good idea about the compilation speeds of C++, so I don't doubt you on that point.

That's hardly the only other AOT language competing with Rust though, and while some of them are simpler on a language level (i.e. C) the compilers do a fair share of work in the optimizing stage of those simpler languages. There's also several languages that do quite a bit of heavy lifting during compilation, like Zig and Nim have extensive compile time features for example. And Nim does two passes since it compiles to C first (by default) and then that's compiled to machine code.

On balance, I don't think you can wriggle out from the fact that Rust compiles slowly compared to its competitors.

Even the Rust team admits this and are working on improving it.

Re: Rust Is Surprisingly Good as a Server Language

#232

Earlier quoted context omitted.

The thing with ownership reasoning in Rust is that you can opt out of it whenever it makes sense to do so. If you really have "objects which live for indeterminate amounts of time and can be shared across views", that's not an increase in complexity; you just acknowledge that reasoning about ownership and sharing at compile time is not going to be feasible, write Rc > (with a documentation comment to that effect) and…

Yes, but you still can't write garbage collected code, which is tremendously useful in many circumstances. E.g. when using closures you really don't want to be thinking about memory allocation, and closures have proven a very useful concept. There are countless of reasons why the availability of a GC is a productivity booster. So I wouldn't describe Rust as a language that fits all domains and/or programmers well.

Isn't Rc essentially garbage collection though?

Re: Rust Is Surprisingly Good as a Server Language

#233
post #30

I tried Rust about a month ago. The language itself is amazing, the pattern matching is super expressive, the borrow checker is incredible in the kinds of errors it can pick up on, and rust-analyzer is leagues beyond where RLS was. But... the compile times are an absolute non-starter for me. I'm the kind of guy that likes to re-run his code continually to see if it validates to what I expect it to be doing. In Rust,…

I don't have that much to add to the discussion, really. I just wanted to ruminate on something:

> I've often wondered how this can be possible, given that to me it's such an obvious glaring issue that all the other cited problems are distant distant seconds at best.

It's amazing how little I understand your point of view. And I'm being genuine and not critical of you at all.

To me, all of the features of the language, from move semantics, to ergonomic sum types, to nicer error handling (to me. I know it's debatable), and great runtime performance are so important, and bring me so much more peace and joy while working that compile times are literally not even on my radar. I simply don't care if they ever get better (assuming that effort is being put elsewhere. I guess if the language is "done" then work on the compile times is appreciated).

And I've certainly done real work in languages that compile fast (Go, Java) and languages that don't even compile. They always made me so much less happy because of the languages themselves just not clicking with my mental model of problem solving. Again, compile-run feedback loop just had nothing to do with it.

All that said, I use Rust Analyzer for code completion and it's generally fast enough. But it's still sometimes has a noticeable stall. That's not my favorite and it's kinda related to compile times.

Just really amazing how different people using the same tool have such wildly different modes of interaction and perceptions. Cool stuff. Cheers!

Re: Rust Is Surprisingly Good as a Server Language

#234
post #30

I tried Rust about a month ago. The language itself is amazing, the pattern matching is super expressive, the borrow checker is incredible in the kinds of errors it can pick up on, and rust-analyzer is leagues beyond where RLS was. But... the compile times are an absolute non-starter for me. I'm the kind of guy that likes to re-run his code continually to see if it validates to what I expect it to be doing. In Rust,…

Disclaimer: I’m only a casual Rust user.

> One group loves fast compile times and quickly validating hypotheses

In Rust, it’s sufficient to type check (if it type/borrow checks, it will probably work) and Rust can type check in real time via rust-analyzer. This is much faster feedback than running your program or even its tests.

Of course, Rust’s type/borrow checker is also choosier than many others, and you still spend more time fighting with errors that don’t actually improve your code’s correctness (e.g., borrow checker errors are rarely indicative of a bug in a single-threaded context). So Rust’s iteration loop is quite fast but it’s development velocity is still relatively low (even when adjusting for quality), but it’s improving all the time.

Re: Rust Is Surprisingly Good as a Server Language

#235

Earlier quoted context omitted.

Maybe. At the rate I hit :w, probably not :)

How do you have Vim (or neovim) set up to do that and report errors inline?

How I did it is that I install VimPlug then CoC then the rust extension.

Re: Rust Is Surprisingly Good as a Server Language

#236

Earlier quoted context omitted.

You can have your cake and eat it too, Ocaml & Go both have type systems and compilers that are fast enough to work iteratively

Ocaml is a somewhat fair comparison, but I have to say that Go is really in no way comparable to Rust. Rust is massively more complex.

I'd say Go is a fair comparison here.

Type checking and Parsing isn't bottleneck in Rust compilation. Code generation is. LLVM is particularly heavy and while it generates optimized code, it is quite slow.

Go Authors didn't pick LLVM because of compile speed reasons (as well as complexity), and that turned out to be worthwhile tradeoff.

Re: Rust Is Surprisingly Good as a Server Language

#237
I'm glad to see this post here. Just because I hear/read a lot of people outright dismiss Rust's potential here with arguments that kind of miss the point:

1. You don't need CPU performance for most web stuff. It's all IO bound.

2. Related to #1, garbage collectors are fine and you don't need the Rust model.

3. Rust is so hard to learn that it isn't worth it unless you need the performance.

There's so much more to Rust than the performance. It hits a really nice sweet spot between being expressive and letting you take as much control as you want/need.

Sometimes GC'd languages are a pain in the butt because I just want a damned destructor and I would like to be able to guess when/if it's gonna run.

And, frankly, Rust isn't that hard. It's an imperative language. It's not Haskell.

Re: Rust Is Surprisingly Good as a Server Language

#238

Earlier quoted context omitted.

Rust itself is not inherently "low level" per se. But others are probably right that the whole web services ecosystem for Rust is rather half-baked at this time, the OP notwithstanding.

Having to care for memory management is by definition very low level.

Tell this to someone who has had to fiddle with JVM GC parameters.

Whatever language you're using, you probably should care a little bit about your memory patterns.

Re: Rust Is Surprisingly Good as a Server Language

#239
post #139
post #71

Earlier quoted context omitted.

Copying this from someone else I replied to: No, it's an issue for warm caches as well. I had a 10 second compilation cycle to add a comment to a file in a project with a couple hundred lines of code and like 4 lines in my cargo.toml. 10 seconds! For a few hundred lines! Maybe that doesn't sound insane, but extrapolating out, that's at least 100x worse than the languages that I'm used to.

If you were using `cargo run` or `cargo build` instead of `cargo check`, these 10 seconds could be spent in linking the final binary and not running the compiler frontend. for that matter 10 secs is not unheard of for large libraries with a lot of debug symbols. That's why you should use `cargo check` instead : it will only run the rust compiler frontend, but not the LLVM linker.

Static checking is just a part of correctness verification (pretty large chunk but not enough).

It can't catch many logic bugs, eg forgetting to update a variable's value. The type system can't help without non-straightforward techniques, and at that point it is diminishing returns.

A powerful type system shouldn't be an excuse for not being able to iterate fast.

Re: Rust Is Surprisingly Good as a Server Language

#240

I'm glad to see this post here. Just because I hear/read a lot of people outright dismiss Rust's potential here with arguments that kind of miss the point: 1. You don't need CPU performance for most web stuff. It's all IO bound. 2. Related to #1, garbage collectors are fine and you don't need the Rust model. 3. Rust is so hard to learn that it isn't worth it unless you need the performance. There's so much more to Ru…

Can someone elaborate on why #2 is wrong on the server level? My systems are not performance bottleneck'd and as a Java dev I'm more worried about the potential for memory bugs (which I admit I will create) if I stray away from automatic garbage collection.
Post reply on HN