Live data from Hacker News

Rust Is Surprisingly Good as a Server Language

stu2b50.dev

51–60 of 352 posts

Re: Rust Is Surprisingly Good as a Server Language

#51
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'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.

I used to be the same way, but the more I practiced holding the state in my head while I worked, the better I got at it.

> One group loves fast compile times and quickly validating hypotheses.

You just don't need it. As you make changes, the delta between expected behavior and actual behavior continues to grow. You begin to develop an intuition for what kind of things might not work as expected, and you can conceptually model around those things and continue to build your logic and make your changes.

An IDE helps immensely with type error minutiae. I'm using CLion and it's pretty great. For the few cases it can't figure out the types for you, you can run "cargo check".

I'm confident that Rust has made me a better engineer. I don't need to continually save and evaluate and I can do deeper work with more uninterrupted flow.

Give it a try! I think you'll start to acclimate.

Edit: Why the downvotes? I stated my personal experience as it relates to OP's observations. I improved in how I approach problems after exposure to Rust.

Re: Rust Is Surprisingly Good as a Server Language

#52
post #46

Earlier quoted context omitted.

Man... I hear you, but this is only a problem compiling from a cold cache. From a warm cache, it really isn't a problem anymore.

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. (I know that compilation speed is a Hard Problem, I know that I'm compari…

If it is a project you’ve recently built, it shouldn’t matter what’s in your cargo file, since none of that will change from build to build. I wonder what’s broken. How long does it take to build a new empty project?

One think that’s helped me stay “in the flow” is switching to rust-analyzer instead of the current official RLS. Much faster, I leave format on save turned on, so `cargo check` output is usually ready in about a quarter of a second after save.

Re: Rust Is Surprisingly Good as a Server Language

#53
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 keep reading in Rust surveys that Rustaceans just don't care that much about compile times enough to prioritize improving them. I've often wondered how this can be possible

Well, there's a simple answer... https://xkcd.com/303/

Re: Rust Is Surprisingly Good as a Server Language

#54
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,…

While the initial compile time might be slow because of dependencies, subsequent runs are incremental and maybe take a second for me.

Re: Rust Is Surprisingly Good as a Server Language

#55
post #51
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'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. I used to be the same way, but the more I practiced holding the state in my head while I worked, the better I got at it. > One group loves fast compile times and quickly validating hypotheses. You just don't need it. As you make changes, the delta between expected behavior and actual behavior contin…

>I used to be the same way, but the more I practiced holding the state in my head while I worked, the better I got at it.

Doesn't that partially defeat the point of having a powerful compiler? The more work the compiler does, the less we have to keep track of in our head (and conversely, much of the pain of coding in a language like Python is the amount of stuff we need to mentally keep track of).

Re: Rust Is Surprisingly Good as a Server Language

#56
post #41

Earlier quoted context omitted.

As a datapoint for your hypothesis, when working in a typed language I will build my code only a few times a day. I much prefer working from a logical and thoughtful approach rather than iteration. At the point where I start a build I am already reasonably confident that it will do what I want it to. There are some bugs where I will need to re-build several times consecutively but these are relatively rare for me (I…

That's really interesting. Compiling only a few times a day is mind boggling to me - in a normal day I'd probably average hundreds to a thousand compilation cycles! The main thing that I use compiling for is to validate little off-by-one things. Like, is substring() exclusive on the second parameter? What about range syntax and the slice operator? What if I wrote + 1 instead of - 1 somewhere, or did < instead of <=?…

> The main thing that I use compiling for is to validate little off-by-one things. Like, is substring() exclusive on the second parameter? What about range syntax and the slice operator? What if I wrote + 1 instead of - 1 somewhere, or did I'm a really big fan of reading the docs (or, where the docs are insufficient, the source), and will always have docs.rs open alongside my editor. While the examples you provide are easily validated by testing (and I'd probably use `evalr` in `##rust`, or some similar thing, for them), many subtleties can exist in more complex functions, so not reading the docs/source for unfamiliar functions feels like programming-by-guessing to me.

Re: Rust Is Surprisingly Good as a Server Language

#57
post #25
post #9

Earlier quoted context omitted.

What is your take on TypeScript, what is it you don't like?

I come from a C# background, but to list out a few hurdles that I have already deal with with TypeScript/NodeJs. 1. C#'s AsyncLocal has made a few things simpler to trace SQL queries to a request. 2. We chose to use hapi.js some 2 years ago, because we found the interface superior to Express, but I did not expect the sole developer of hapi.js to decide stop working on the project [1], and left my head scratching on w…

I can feel the pain on all 5 points. One thing I did notice though is that NodeJS has such a huge breadth of packages that its _very_ hard to actually pick something good. But there is almost always an alternative that's maybe not as popular, but is a lot more "solid" alternative.

For example we used SOHU-Co/kafka-node for a while as a kafka client, until we hit some bugs that made us dig through its internals and we realised it had some deep issues. We then switched to kafkajs which turned out to be much more mature and polished, even though it was less "popular".

Sequalize in particular I think was developed in an era before TypeScript was a thing so it follows the ideals of that time, more in line with Ruby and being easy to use and malleable. We switched to using slonik for our query needs, with a more declarative and static approach, skipping ORMs and query builders altogether - just raw strictly typed queries. I think in the end its a better approach for our needs.

I guess what I'm trying to say is that TypeScript was built to be able to handle _all_ of the weird and wonderful world of JS from its most amateurish and fun, to its most solemn and strict. And it's just a matter of picking up where on the spectrum you want to operate and make your dependencies match that vibe. It's limiting and freeing at the same time.

Re: Rust Is Surprisingly Good as a Server Language

#58
post #51
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'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. I used to be the same way, but the more I practiced holding the state in my head while I worked, the better I got at it. > One group loves fast compile times and quickly validating hypotheses. You just don't need it. As you make changes, the delta between expected behavior and actual behavior contin…

I've always wondered if the difference is the quality of work that we do. For instance, I do a lot of graphical/games stuff, and there's no resolution in my head high enough to know that 200 pixels to the right is too far (or not) without recompiling the app and actually looking at it. Or if that shade of blue is the right one.

Still, I appreciate your optimism. I'll give it a shot! Especially for things that aren't graphical.

Re: Rust Is Surprisingly Good as a Server Language

#59
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'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

This honestly is a bad habit. Thought it does depend quite a bit on the type of work you are doing. For some things it is necessary especially if it is inherently fibbly.

Rust is a language to which the programmer must adapt his way of working and thinking. If the programmer is too set in his way, his Rust journey will be unsuccessful. If the programmer is adaptable, he will come out in the end a better programmer, because the Rust way is actually the right way.

I think I actually went a couple of weeks once before trying out my program for the first time and there was no big deal to get it to actually work in the end.

Re: Rust Is Surprisingly Good as a Server Language

#60
post #46

Earlier quoted context omitted.

Man... I hear you, but this is only a problem compiling from a cold cache. From a warm cache, it really isn't a problem anymore.

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. (I know that compilation speed is a Hard Problem, I know that I'm compari…

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

Why compile again after adding a comment?

Post reply on HN