Live data from Hacker News

Rust Is Surprisingly Good as a Server Language

stu2b50.dev

121–130 of 352 posts

Re: Rust Is Surprisingly Good as a Server Language

#121
post #101

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 spot on. I mostly work with C#, F# in a day to day job and I build my code only a few times. This is also true when I work with Java, Angular and TypeScript. When I pick a new feature to implement I design that on paper with pencil and then mostly translate that to code. Mostly I can code for hours without compiling since this is where Typed Languages have strength.

I guess it depends what you're working on.

I mostly work with C#, and occasionally I might only end up compiling the project a couple of times in a day, but I'll probably be building a test project several times in the meantime (e.g. after adding each test).

Alternatively, if I'm building a web GUI, I'll probably be building quite frequently, making sure that data is bound correctly and that the UI looks as expected.

Re: Rust Is Surprisingly Good as a Server Language

#122
post #58
post #51

Earlier quoted context omitted.

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

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

I get that there're some differences in the games domain, but I don't quite get your examples, because changing the position or color of objects seems like a data and not a code change. If you have these properties as data you might be even able to change them on the fly, in the running game, which will increase your iteration times quite a bit more than any faster compile times.

Re: Rust Is Surprisingly Good as a Server Language

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

In dynamic languages like JavaScript or Python it's necessary to continually run your code in order to validate that the API (of the standard library or of dependencies) was used correctly, that the types match, etc. Rerunning your code continually is no longer necessary in a language like Rust, because the compiler already does that for you. People complaining about slow compile times in static languages like Rust,…

> In dynamic languages like JavaScript or Python it's necessary to continually run your code

No it's not. It's just preferable to do your work in smaller batches so that your feedback loop is fast and you know exactly which change broke things, rather than making 10 changes and then having to figure out which of those changes 4 bugs relate to. And it's better to discover a flaw in your implementation early rather than late, which is also easier when working in small increments.

Re: Rust Is Surprisingly Good as a Server Language

#124
I had a similar idea for my blog [1], with almost identical goals, but I wrote it in Go. Rust is on my to-learn list, but I find it harder to read from the code samples in the article and what I saw on other websites. I guess I will stick to Go for business logic. When would you guys chose Rust over something else, like Go?

[1] https://marvinblum.de/blog/how-i-built-my-website-using-emvi...

Re: Rust Is Surprisingly Good as a Server Language

#125
post #19

Why wouldn't you just use OCaml, Haskell, F#, or Scala, where you've got much more mature web framework options? Don't get me wrong, Rust is fine, but if you don't need its memory management then why make trouble for yourself?

Rust is interesting in that it may eventually end up as a very useful language for WASM work.

Rust has the advantage that when compiled to WASM it won't require a runtime library. So the prospect of Rust as a fast, low overhead, use anywhere language is tempting.

Since Rust is a relatively new language it's worth checking to see how it's maturing over time against small low risk projects exactly as the author has done.

Rust may not be a perfect fit right now but that may change. So it's very valid to test one's assumptions from time to time.

Or to put it another way, working in one of the languages you've mentioned wouldn't answer the question "how suitable is Rust for web server work right now?"

Re: Rust Is Surprisingly Good as a Server Language

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

In dynamic languages like JavaScript or Python it's necessary to continually run your code in order to validate that the API (of the standard library or of dependencies) was used correctly, that the types match, etc. Rerunning your code continually is no longer necessary in a language like Rust, because the compiler already does that for you. People complaining about slow compile times in static languages like Rust,…

For me the problem would be learning how something does or does not work, even with a compiled language.

The reason I hate Spring for example (not that I've worked with it extensively) is that the documentation gives you zero feel for what you expect the behaviour to be. It will compile, but until you run it and check what it's doing, very often you'll be developing with no idea of what you're actually building.

Especially if you're trying to get specific behaviour of what you want to see (e.g: figuring out why it won't send mail, or why it doesn't ignore a certain json key or whatever), it still needs many runs to get right.

Re: Rust Is Surprisingly Good as a Server Language

#127
post #61
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,…

Is this not something you can just throw more hardware at?

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.

Re: Rust Is Surprisingly Good as a Server Language

#128
post #45

Earlier quoted context omitted.

>> in a normal day I'd probably average hundreds to a thousand compilation cycles! Maybe it's time to switch to an interpreter ? :-)

Or a language like Go, C or Nim that can compile tens of thousands of lines of code in a few seconds.

You forgot about D, where you can basically bind ctrl+s to rdmd in your favourite IDE and enjoy scripting language akin experience.

Re: Rust Is Surprisingly Good as a Server Language

#129
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 <=?…

I've to say, I really hate this way of working, which might be the reason why I prefer statically typed languages like Rust.

I think the main reason why I dislike working with dynamically typed languages is that most of them make the reasoning of code a lot harder. If you're able to reason about the code at hand, then there's a lot less need to run the code for every small change.

Re: Rust Is Surprisingly Good as a Server Language

#130

I had a similar idea for my blog [1], with almost identical goals, but I wrote it in Go. Rust is on my to-learn list, but I find it harder to read from the code samples in the article and what I saw on other websites. I guess I will stick to Go for business logic. When would you guys chose Rust over something else, like Go? [1] https://marvinblum.de/blog/how-i-built-my-website-using-emvi...

Go comes with more tools to do what you want with stdlib. It'll be easier to do this with go than learning rust and the required dependency.

So that's one answer: forcing yourself to learn more about a languages environment and ecosystem.

Another answer might be: "I already know/prefer rust."

I'd be surprised if there were much/any performance benefit.

Post reply on HN