Live data from Hacker News

How Rust Is Tilde’s Competitive Advantage [pdf]

rust-lang.org

21–30 of 127 posts

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#21

> while the Java server could use up to 5GB of RAM, the comparable Rust server only used 50MB How...how is that possible? It just glosses over this interesting point. What does "comparable" Java code do to use 100x more memory?

Three things: * Java tends to allocate things separately and manipulate pointers, while Rust allocates things inline. This introduces allocation overhead and eats up the space needed by the pointers themselves. * Java uses a JIT, which consumes of memory for profiling state and for storing the resulting compiled code. * A tracing garbage collector needs about five times as much memory as explicit freeing to reach the…

Additionally things like Spring and dropwizard also add some overhead for better developer UX which rust doesn't have yet.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#22
post #2

So, I've been eyeing Rust for a while and have messed around with it a bit in my free time. Here are some things I'd want to know before trying it out on a large project: 1. What development environment are other developers using with very large code bases? Is the tooling responsive? 2. Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators f…

Neat, what is your use-case for OBD-II data? I've been investigating ways to get data from a race car back to the pit crew via something like a raspberry pi.

Right now I just want to get more fine-grained data about my mileage. But maybe add some automation into the mix later on (remote start, etc.).

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#23
post #2

So, I've been eyeing Rust for a while and have messed around with it a bit in my free time. Here are some things I'd want to know before trying it out on a large project: 1. What development environment are other developers using with very large code bases? Is the tooling responsive? 2. Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators f…

> Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators for async (assuming you want to stay on stable)? And is there a date yet when async/await will be stabilized? Can someone explain to me what async/await is, in the context of a language like Go? I've used Rust a fair amount, but Go has been my native language for ~5 years now. With that…

Yeah, you are missing some details. But this is a huge area, and it's hard to explain in a single HN comment. Basically, yes, the convenience of not needing to write async/await is useful, but in order to accomplish that, you need a bunch of other supporting decisions. These decisions make sense for Go, but do not make sense for Rust.

The first thing to say on this topic is that virtually all of this (including async/await) is a library in Rust, not a part of the language. You can build whatever model you want on top. The one I'm describing is the futures/tokio model, which is becoming the de-facto, default one. But if you want something else, you can do it! This already is a divergence from Go, where you have what the runtime gives you, and that's it.

Fundamentally, Go's model is cooperative coroutines, where the runtime does the pre-emption for you. (You can also call it yourself but as you note, this isn't usual.) It'll do this when you request something from the network, when you sleep, or when you use a channel.

Tokio's model, on the other hand, is single-threaded. Instead of a ton of gorutines, there's an event loop, and you place a chain of futures onto it. Each chain of futures can sort of be thought of as a goroutine, but it's also different. For example, Rust can know at compile time exactly how big each futures' stack is, and so can do a single, exactly correct allocation. Anyway, each future in the chain handles yielding for you.

Async/await, in Rust, is about making those chains easier to write.

Anyway, I hope that helps. Maybe someone else will have a good comparison too. There's a lot of options in this space, and similar terminology that means the same, but slightly different things, so it can be hard to get your head around.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#24

Earlier quoted context omitted.

Java has its own heap so the memory usage, certainly for a server VM, doesn't necessarily correspond to actual application memory use. (Also, of course, your main server uses "up to" 5 GiB? That's fucking great. Until it goes beyond 64 GiB, who even cares. Work on something that has a worthwhile monetary return..)

Assuming it is heap space: that just prompts the question why is there heap space so large?

The default sizing policies optimize pause times, throughput and only as tertiary goal for footprint.

Additionally people often tune the JVM to avoid some startup costs which includes fixed heap sizes which prevents the JVM from returning memory to the OS.

On top of that there often are just plain bad programming practices like deserializing large files into memory instead of streaming them. I suspect that rust also attracts more performance-conscious developers that avoid such things. Or maybe it is applied in projects where "throw more hardware at it" is not a cost-effective measure and investing in more developer-hours is appropriate.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#25

Earlier quoted context omitted.

Java has its own heap so the memory usage, certainly for a server VM, doesn't necessarily correspond to actual application memory use. (Also, of course, your main server uses "up to" 5 GiB? That's fucking great. Until it goes beyond 64 GiB, who even cares. Work on something that has a worthwhile monetary return..)

Assuming it is heap space: that just prompts the question why is there heap space so large?

It answers the question: you can't just look at gross native memory usage and conclude the Java app is 100x less efficient, that value simply doesn't tell you a lot. Server VMs are commonly configured to use gigabytes of RAM from the get-go, and when the initial VM heap is full, Java will not make small adjustments but instead grab a big chunk, and when that is no longer needed, it is often reluctant to release that additional memory.

I have no doubt that a Rust app will generally be more memory-efficient, but ultimately for server applications that is really not something a lot of people care about because of the incredibly low cost of "just buying more".

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#26
post #2

So, I've been eyeing Rust for a while and have messed around with it a bit in my free time. Here are some things I'd want to know before trying it out on a large project: 1. What development environment are other developers using with very large code bases? Is the tooling responsive? 2. Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators f…

> 1. What development environment are other developers using with very large code bases? Is the tooling responsive? It’s solid. If you’re coming from Visual Studio, you’ll dig IntelliJ with the Rust plug-in. > 2. Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators for async (assuming you want to stay on stable)? And is there a date yet whe…

> If you’re expecting the F# (and .NET) ecosystem, you’ll likely be satisfied. In fact, it might be better.

Not even close (100k unique packages on nuget, 13k crates on crates.io). On the other hand, you have easy interop with C (which doesn't give you stuff like safety, idiomatic error handling or nice APIs, but it's occasionally better than coding it yourself).

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#27
post #2

So, I've been eyeing Rust for a while and have messed around with it a bit in my free time. Here are some things I'd want to know before trying it out on a large project: 1. What development environment are other developers using with very large code bases? Is the tooling responsive? 2. Using a language for a large project without some kind of async/await notation seems painful. How bad is it using only combinators f…

1. VS Code with the Rust plugin along with rustfmt and the rls is great - when it works. I've had some issues now and then, but the tooling is pretty great.

2. Not qualified to answer this

3. There's a ton of rust libraries out there. The whole cargo ecosystem is quite nice.

Coming from a C background (and dabbling in lisp), I love Rust. It's C with batteries and concepts from functional programming - iterators, immutable data. The only times I've struggled with rust is when trying to mess with pointer arithmetic and evading memory safety (e.g. trying to program a garbage collector for a Lisp interpreter)

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#28

Earlier quoted context omitted.

Three things: * Java tends to allocate things separately and manipulate pointers, while Rust allocates things inline. This introduces allocation overhead and eats up the space needed by the pointers themselves. * Java uses a JIT, which consumes of memory for profiling state and for storing the resulting compiled code. * A tracing garbage collector needs about five times as much memory as explicit freeing to reach the…

Additionally things like Spring and dropwizard also add some overhead for better developer UX which rust doesn't have yet.

Spring is the new EJB. It's bloated and always amazes me on how complex it can get when you need to implement something not provided by Spring itself.

With Java 9 modularity and lightweight libraries like Guice you can get much nimbler apps.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#29
> Rust is much easier to teach than C or C++,

Not sure about that.

If you know C, which is easy to learn, you already know a lot about C++, or at least the parts that are used most of the time.

Learning about the borrow checker, match enums don't seem very easy at first, although they surely seem elegant and much safer.

Re: How Rust Is Tilde’s Competitive Advantage [pdf]

#30

> while the Java server could use up to 5GB of RAM, the comparable Rust server only used 50MB How...how is that possible? It just glosses over this interesting point. What does "comparable" Java code do to use 100x more memory?

Almost certainly either bad design (their Java app had a way bigger working set than their Rust one), or bad tuning (they set the heap needlessly large). Automatic memory management _does_ require more memory for reasonable performance, but you'd be talking about 2x or 3x the working set. Not 100x. Java objects will likely end up a little larger than Rust ones, but again not enough to make up the 100x difference.

Having a way-too-big heap is usually actively undesirable; you'll get fewer pauses, but much longer ones.

Post reply on HN