Live data from Hacker News

Rust Is Surprisingly Good as a Server Language

stu2b50.dev

271–280 of 352 posts

Re: Rust Is Surprisingly Good as a Server Language

#271

Earlier quoted context omitted.

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

Rust's type system doesn't have a notion of "looks right visually," so the compiler is ipso facto unhelpful there

Could you expand on this? It seems like you might have a really interesting point to make but I can't tell what it is :)

Re: Rust Is Surprisingly Good as a Server Language

#272

Earlier quoted context omitted.

That con is a pretty big one. Macs have less than 10% desktop market share.

In this case Swift is being used on the server, so that could be an officially supported platform[0] which if I recall correctly is macOS, Ubuntu, CentOS, Amazon Linux 2, and Windows as of Swift 5.3.

Swift on Linux is pretty much WIP, with an ecosystem that is Mac first and hardly considers another platforms.

On Windows with luck 5.3 will be the first version that the compiler actually works, let alone existing libraries that barely work on Linux.

Re: Rust Is Surprisingly Good as a Server Language

#273
post #93

Earlier quoted context omitted.

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.

Yes, although on my case it is JEE actually.

That over-engineering is what save us from clunky solutions that are good for hello world applications and HN like posts, but fail when doing deployments across heterogeneous platforms on Fortune 500 IT departments with endless number of external contractors and technology stacks hardly seen elsewhere.

And if I have to pick between managing WebSphere containers and taking care of k8s, I will rather pick WebSphere.

Re: Rust Is Surprisingly Good as a Server Language

#274

Earlier quoted context omitted.

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.

D is sadly very underrated.

Re: Rust Is Surprisingly Good as a Server Language

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

It's interesting - i very frequently recompile, running tests, etc - and i just don't have a problem with Rusts compile times. Maybe you want it more immediate than i do?

The project i'm working on now takes ~8s to compile. Perhaps too slow, but i guess it just doesn't bother me. Though i definitely want to see it improve for wider adoption, as it's clearly an issue for many people - I just have difficulty feeling the pain in this case, i guess.

edit: I imagine i compile once every 5 min of code writing. Varies by problem solving of course.

Re: Rust Is Surprisingly Good as a Server Language

#276

Earlier quoted context omitted.

It's not wrong. I didn't mean to imply that. I just mean that saying non-GC languages are about performance overhead of the garbage collector is missing the point. Sometimes, it's convenient and easier to reason about stuff when you can predict when something is actually dropped from memory. And in Rust, you wouldn't create those memory bugs you're worried about. (Well, you can, but you have to go out of your way to…

You can absolutely create memory leaks in Rust [1]. That's a bigger problem for server applications than CPU / Memory performance issues, because the latter can be traced more easily. As a (mediocre) dev and head of a team (some are great, and some are as bad as me), I'm far more worried about bugs than performance. [1] https://stackoverflow.com/questions/55553048/is-it-possible-...

Depends what we're talking about. A "true" memory leak (as in allocated memory that is not referenced) is not very likely.

A reference cycle with `Arc`s can happen though.

But if you're talking about Java and mediocre devs (I'm in the club- don't worry), I feel like there are no shortage of ways to make bugs with null, concurrency issues, etc, that Rust completely eliminates. You can make reference cycles in Rust, though.

Also, in Rust code you often don't have references to references to references the way you do in Java, so it's just not an issue that I'm aware of having had yet.

Re: Rust Is Surprisingly Good as a Server Language

#277
post #261

Earlier quoted context omitted.

I hardly know Rust. What about using many small .rs files so the compilation units are quicker. For a change of one line of code only that .rs needs to be compiled.

Rust's unit of compilation isn't a file, but a crate. (this is ignoring incremental compilation, of course.)

Furthermore, most libraries make the stylistic decision of using generics and trait bounds instead of trait objects, which potentially generates faster code at the cost of slower compilation. This also has the consequence of requiring a recompilation of every dependant if that item: if you modify a root item that uses generics you will get a nice recompilation of your entire tree. Edit: working on dependency leaves though is mostly painless. If you don't work on fundamental libraries or frameworks of your system the experience becomes much better, although linking can take quite a while depending on your project.

Re: Rust Is Surprisingly Good as a Server Language

#278
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. In Rust, this kind of workflow just doesn't work at all.

Interestingly, my case is the exact opposite. When I am coding in Typescript or Python I'm out of place, since I got used to first write the types to make sure everything is aligned, _and then_, start writing logic...

Even in Typescript this workflow is not easy to do, since its compiler is nowhere as powerful.

Re: Rust Is Surprisingly Good as a Server Language

#279

Earlier quoted context omitted.

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?

Not really. Reference counting doesn't prevent reference loops, and reference loops which aren't reachable from code are memory leaks - which is why garbage collectors do sweeps to detect unreachable memory. Rust doesn't have any kind of automatic cleanup of unreachable memory if you bypass the borrow-checker.

Rust is a language for memory management. There is no way to write code in Rust without thinking about memory.

Re: Rust Is Surprisingly Good as a Server Language

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

It's interesting - i very frequently recompile, running tests, etc - and i just don't have a problem with Rusts compile times. Maybe you want it more immediate than i do? The project i'm working on now takes ~8s to compile. Perhaps too slow, but i guess it just doesn't bother me. Though i definitely want to see it improve for wider adoption, as it's clearly an issue for many people - I just have difficulty feeling th…

Yes 8s would me too slow for me. I'd usually set up a fullstack front+backend dev that hot reloads both parts an 8s delay interrupts flow. Compare that with 1s (or less) for Go or even Java (with a lightweight framework).
Post reply on HN