News for hackers. Stuff that matters.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by crabbygrabby on Thursday June 02, 2022 @09:19PM (#31603034)
Why? Because it's stupid fast, fast means serving an order of magnitude or more clients before requiring scale up. Scale up means $. No stop the world GC time situations, etc. That's basically it.

To be fair, I usually prefer to use go as well, lately though rust is more appealing.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by cmrdporcupine on Thursday June 02, 2022 @09:25PM (#31603079)
I mean, there's no world in which my personal tastes wouldn't prefer Rust over Go -- I quite dislike writing Go. But as an engineer it is my responsibility to use the right tool for the job, not pick tools based on my tastes or gut feelings.

There's different kinds of fast. For most kinds of fast that people doing 'web' type things need, a garbage collector and a VM are not going to be the bottleneck. Efficient management of workloads across blocking I/O is going to be where the hard work is.

Now, I've written ad servers and video streamers, and other low latency high throughput things, and yes, I'd probably reach for C++ or Rust there. But some of the jobs I've seen lately posting for Rust, I do question. Even if I'm tempted to apply, because I'd like to get $$ to work in Rust.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by crabbygrabby on Thursday June 02, 2022 @09:47PM (#31603248)
Yea it's hard to say without context, I just gave the generic answer. I'm not sure you ever 'need' a garbage collector, and if avoiding one lets me save 20k in cloud expenses a year on a small team, it's probably worth it, because after scale out 20k isn't 20k anymore.

That said, people misuse technology all the dang time(I've done it). And in general I agree, Go is usually enough and has the best cloud ecosystem. I've had trouble with large go code bases exploding over time and requiring a lot of bodies to maintain compared with rust/scala.

Sometimes it's hard to speculate when one tool is clearly better than another. Some companies just want to use new stuff to sound cooler...

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by jerf on Thursday June 02, 2022 @09:39PM (#31603188)
Rust does not in general have an order of magnitude advantage over Go. 2 or 3 would be closer, and that's with some nontrivial attention paid to optimization, not "you write Rust and it's automatically always faster".

Super high-end stuff can outclass Go by that much, like if you're seriously using DPDK or something, and in those cases I strongly recommend Rust over Go. There some other noches like that. But in general, it's not a factor of magnitude.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by crabbygrabby on Thursday June 02, 2022 @10:11PM (#31603407)
It really depends. I agree it's not always an entire order of magnitude didn't mean to paint that picture for passerbys who don't know better. Not trying to touch the "this lang vs that lang performance" conversation with a ten foot pole...
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by jerf on Monday June 06, 2022 @10:00AM (#31640577)
10x improvement over Go is a reasonable expectation, in a limited set of environments, generally at a scale where you're looking at using every last bit of a 32-core or 64-core machine and doing a lot of memory work. You should also expect to be spending a lot of time optimizing that Rust to get there. But when you need that level of performance, you also basically made a mistake starting with Go in the first place.

However, by far the bigger problem is people thinking their little web service serving out 5 requests a second requires that level of optimization when in fact even a Go implementation will use <1% of the CPU and no other resources to speak of. Dynamic scripting languages, IMHO, have skewed a lot of people's performance views. Go is already more power than most problems need, in terms of raw performance, and it's only a sliver, a niche where that's the difference between a Go vs. Rust choice.

It's a delicate understanding, but an important one for a professional.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by pclmulqdq on Thursday June 02, 2022 @10:13PM (#31603430)
I would not suggest using DPDK with Rust, unless you want to write a lot of stuff for yourself and wrangle with some tricky `unsafe` code. Sticking to C or C++ will make your life a lot easier.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by WuxiFingerHold on Friday June 03, 2022 @02:06PM (#31611713)
An order of magnitude? Not true at all. Look at this benchmarks:

https://web-frameworks-benchmark.netlify.app/result?f=axum,g...

I've done some benchmarking with Actic, Axum and Go (std lib). Actix was top, Axum about 85 % of Actix and Go about 75 % of Actix.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by SuperQue on Thursday June 02, 2022 @10:44PM (#31603646)
The problem is there is more than one kind of "fast". There is latency "fast" and throughput "fast".

For a lot of web stuff you need throughput more than you need latency "fast".

In order to do throughput well you need concurrency.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by mmarq on Friday June 03, 2022 @03:30AM (#31605303)
There’s also how much it takes to hire 5 developers ”fast”. At least for now, Rust is not that performant on that respect.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by crabbygrabby on Friday June 03, 2022 @08:58AM (#31607610)
Pretty sure you could hire 5 rust developers pretty easily. A lot of people in the rust community are dying to find a job that will let them write rust professionally...
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by DeathArrow on Friday June 03, 2022 @01:55AM (#31604741)
It's at most 50% faster than Java and C# and not faster than C++. An order of magnitude would mean 900%, not 50%.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by Xorlev on Friday June 03, 2022 @02:17AM (#31604881)
Perhaps in TechEmpower benchmarks, which to be fair aren't the worst way of taking frameworks out for a run to see what they can do, but at the end of the day they're very synthetic workloads. Interesting applications are piles of business logic where a slightly faster framework doesn't really buy you much.

Anecdata are all I can provide, but the equivalent (Google) batch job in C++ vs. Java is often an order of magnitude better for a variety of reasons. It might only be 0.5-3x faster, but it also uses less cores and less memory to do the same amount of work.

Having written C++ and Java services, the median C++ service is performs better than the median Java service. Some of that is less pointer chasing, some of it is better libraries. Some services will be slow no matter what you write them in. There's too many variables to quantify, and "performs better" is a real load bearing term. Sometimes it's less CPU, memory. Sometimes it's latency.

I still primarily work on Java services, and they perform pretty well. That said, the operational dynamism of Java services is a real thorn in my side. Beyond the GC, there's a lot going on in the runtime including JIT that just makes JVM services less predictable. Even classloading is a source of unpredictability, unless you eagerly load classes.

FWIW, I think Go does a pretty good job being predictable too. AOT compilation helps there, you're not worrying about new tasks needing to JIT. Go mostly worries about GC (often irrelevant), warmup of state (like TCP connections), and avoiding footguns that leak Goroutines. :) At least Go's footguns rarely blow your whole leg off.

Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @07:00AM (#31606723)
In practice, on bigger applications Go very much fails to be faster than Java or C#.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by DeathArrow on Friday June 03, 2022 @07:38AM (#31606970)
The point was about Rust. Go is on par with C# and Java.
Re:Rust Is Hard, Or: The Misery of Mainstream Programming by kaba0 on Friday June 03, 2022 @07:41AM (#31606989)
Sure, just many people do believe that Go is somehow faster than the other two, so I thought it would be worth to chime in.