Live data from Hacker News

Rust Is Surprisingly Good as a Server Language

stu2b50.dev

141–150 of 352 posts

Re: Rust Is Surprisingly Good as a Server Language

#141
post #120

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.

Actually the OP only wrote that the current state of the ecosystem is surprisingly mature, but he doesn't recommend writing anything serious in it yet. Personally I don't see the point to implement a typical web application in Rust - the performance improvements you get will be lost on IO-bound applications, but you'll still be saddled with the complexity of the memory management. I'd rather suggest to rewrite VS Cod…

> the performance improvements you get will be lost on IO-bound applications

Performance starts mattering even in IO-bound applications as soon as you're trying to seriously scale out. Especially when running on a cloud-based platform. As for "the complexity of memory management", people like to bring this up about Rust but OP suggests that it's not a huge concern with the language.

I do agree that rewriting stuff like Electron-based apps should be a priority, and that Rust can help this via easy bindings to native OS and GUI platforms.

Re: Rust Is Surprisingly Good as a Server Language

#142

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.

I thought about getting back into game development. Nothing fancy, just some 2D experiements. I haven't looked into Vulcan/OpenGL bindings for Go in a while, but I remember that it wasn't really recommended. Maybe I'll give Rust a shot one day to do that.

Re: Rust Is Surprisingly Good as a Server Language

#143
post #7

There is an advocate on our team that wants to migrate our web service from Nodejs to Rust. While I am not a huge fan of Typescript, at least libraries are readily available and generally easy to use. On the other hand, being able to show that we are able to do monitoring, user auditing, ORM, opentracing, gRPC-web with Rust is non trivial. Now that I think of it, being able to do a "hello world" on any language is pr…

Rewriting is very expensive, and the advocate will need to make a VERY strong case for Rust if they're asking your company to invest in replacing it - and alternatives have to be suggested as well, including other languages and a good list of things wrong with Node / TS. Consider developer availability as well. I don't think a strong enough argument can be made. I'm sure you CAN write web services in Rust, and that i…

Why not Kotlin?

Re: Rust Is Surprisingly Good as a Server Language

#144
post #77

Earlier quoted context omitted.

The most time wasteful part of programming is debugging. Writing slowly and thinking through your options and double checking what you wrote saves time. Especially since you are doing this while writing and you have the complete picture in your head. Obviously it does not catch everything. But one should strive to minimize detective work.

After I've been programming for an entire day I will rely on the compile to tell me when I'm wrong with an assumption. I'm honestly trying to conserve mental energy so I've learned that it's better to do it from the start and avoid keeping track of as much stuff as possible in my head. The compile tells me something's wrong somewhere and I go fix it and move on. That's not detective work, at least it doesn't feel lik…

Turning off parts of your brain is generally not a great idea when the goal is to write code that works. A better way to conserve mental energy would be to take a break, go for a walk, or just context switch for a while.

Re: Rust Is Surprisingly Good as a Server Language

#145

Earlier quoted context omitted.

In theory and to some degree in practice. The compiler won't fix the code that compiles but runs incorrectly. Besides, there are statically typed functional languages where compiling time is not a problem, see D.

I haven't worked with D, but D isn't a functional programming language ;-)

You will be surprised if you do ;) Multi-paradigm to be exact. Scala is a multi-paradigm as well btw.

http://beza1e1.tuxen.de/stuff/FunctionalD.pdf

Re: Rust Is Surprisingly Good as a Server Language

#146
post #112

Earlier quoted context omitted.

Does having to develop against rust nightly over stable not worry you when attempting to productionize a service? I understand new features get shipped behind feature flags/language pragmas, but it seems like a massive looming risk.

Not that as of Rust 1.45, coming out this Thursday, Rocket will be able to target stable Rust: https://github.com/SergioBenitez/Rocket/issues/19#issuecomme... I believe Diesel has been on stable for a long time now, so for this use case I don't think anyone will need to worry about using the nightly releases.

That's good news! Wasn't aware of the pin change for rocket.

Re: Rust Is Surprisingly Good as a Server Language

#147
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 use Rust (super interested in rectifying that someday though, especially to replace the ruby we use in our server) but I have the same compile time issue with bytecode on Android.

I used to be the kind of dev who compiles every tens minutes. The thing is, on Android compilation time are just getting larger and larger. Anecdotally, this is not because the tooling team is not interested in build performances, on the contrary they continuously work on it. However they are currently losing the battle : the median app complexity is growing way faster than they are improving the build times.

I mostly got used to it. I can write code for a whole day and only compile once or twice. The more I am accustomed to our ecosystem and codebase, the less I feel the need to compile frequently.

The only exception is for graphics code. The only way to know if something looks correct and good is often to compile. For that reason, while I still love writing polished animations, I dread having to compile 10 times in a row to get it just right.

Re: Rust Is Surprisingly Good as a Server Language

#148
post #93

Earlier quoted context omitted.

What do you miss about java?

The ecosystem, i.e. Spring.

Oof, there are people out there that like to work with Spring?

The over-engineering in the Java ecosystem has wasted more of my time than saved it.

Re: Rust Is Surprisingly Good as a Server Language

#149
post #75

Earlier quoted context omitted.

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

Perhaps my examples were a little too trivial. I do a decent amount of game/graphics coding, so there's a lot of "hmm, does this look good 20 pixels over? How about 18?" and I don't know how you'd get around that without recompiling. (OK, you could read preferences from a file, but then you'd have to optimistically write every value you'd ever want to recompile to a file. I've tried this, but it's far too much overhe…

Why not have controls in your program to do these immediate, non-logic changing modifications? It can report the ideal value through a debug interface. No recompiles needed.

I'd also recommend getting used to serialisation/deserialisation. Serde for Rust makes this remarkably easy. Writing every setting to a file is simple if the compiler can do it for you, rather than you walking the long way around.

Re: Rust Is Surprisingly Good as a Server Language

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

Could someone who is familiar with Rust clarify something for me? If I am using an IDE such as IDEA's Rust plugin, and I write some function which contains a type error, do I have to compile in order for the IDE to tell me there is a type error, or can I rely on automatic type-checking like I can in e.g. Java? In other words, is Rust slow to validate code, or is simply slow to compile code into a runnable binary? If it is the former then I can totally understand why Rust would turn certain programmers away. If it is only the latter, then I find it slightly harder to understand.
Post reply on HN