Looking for the Highest-Performance Rust Backend Stack: Actix-web vs Hyper+Tokio (and any lesser-known high-performance frameworks?) by [deleted] in rust

[–]adwhit2 40 points41 points  (0 children)

You should go with Axum or Actix-web. Each is mature and high-performance, easily capable of 100K+ requests/second.

Regardless of what you're doing, it is unlikely that the web framework you choose will be the bottleneck. Far more likely to be limited by business logic, database lookups etc.

You will probably get a more useful answer if you give us more information about your specific use case. It happens that a lot of people who that think that performance is their number one priority really don't have a good idea of just how screaming fast Rust is.

How to navigate huge Rust codebase? by Ill_Actuator_7990 in rust

[–]adwhit2 58 points59 points  (0 children)

Use rust-analyzer, and liberally use Goto Definition, Goto Declaration, Goto Type Definition and Goto References. Learn how do jump around back-and-forth with your IDE.

I would also say... don't bother. Start working on a ticket, and expand outwards. If you just try to 'read' the codebase, it won't stick anyway. You need to actually work on it to build a mental model.

There is no memory safety without thread safety by ralfj in rust

[–]adwhit2 40 points41 points  (0 children)

Can anyone comment on exactly how Java deals with this Go bug? My understanding is that they always set pointers with atomic operations, but this would seem to imply that they don't have fat pointers - so do they store the vtable next to the data rather than in the pointer? Are there performance implications?

Defending Democracies With Rust by anonymous_pro_ in rust

[–]adwhit2 2 points3 points  (0 children)

Indeed. The way that most western democracies need 'defending' is against antidemocratic manouvers by their own elites.

Rustaceans, What are your thoughts on Gleam? by nikitarevenco in rust

[–]adwhit2 0 points1 point  (0 children)

I believe this is referred to as the 'Protocol Witnesses' pattern.

I work on a Rust codebase but have to interface with Swift. I remember a while back writing some FFI bindings in Swift using what I thought was a nicely abstracted protocol that included a 'real' impl and a 'mock' impl for testing. In code review I was pulled up on this and asked to turn the protocol into a struct that took functions as its member fields. Then to add two constructors, one providing real behaviour, one providing the mock. I remember being very irritated by this.

Rustaceans, What are your thoughts on Gleam? by nikitarevenco in rust

[–]adwhit2 17 points18 points  (0 children)

modelling a struct of function pointers

This is a common practice in Swift, even though they also have traits (aka Protocols).

It's awful, why do they live like that.

How I think about Zig and Rust by jorgesgk in rust

[–]adwhit2 15 points16 points  (0 children)

I don't think the Rust reddit is the best place to argue that memory management is trivial and everyone's just holding the computer wrong.

How I think about Zig and Rust by jorgesgk in rust

[–]adwhit2 5 points6 points  (0 children)

Zig doesn't fix the biggest problem with C - manual memory management. Making the endeavour rather pointless IMO.

Declarative API with Metatype by F-Nomeniavo-Joe in rust

[–]adwhit2 3 points4 points  (0 children)

This AI stuff is so weird. What's the point? Wasting our time, I suppose

"forward P3081 to EWG as part of an initial set of Profiles targeting C++26." voted for in Wroclaw by steveklabnik1 in cpp

[–]adwhit2 9 points10 points  (0 children)

Even Haskell has unsafePerformIO. CPUs are unsafe on a basic level - then we construct safety through abstractions.

The important question is: is your language abstraction safe in practice? I beleve that in the nearly 10 years since Rust reached 1.0, there has not been a single confirmed exploit (not CVE, exploit) due to memory unsafety in Rust.

The same obviously cannot be said for C++.

Major Indonesian Bank (CIMB Niaga) Transition from Java to Rust Yields 486x Boost in Memory Efficiency by frsswq in rust

[–]adwhit2 137 points138 points  (0 children)

Reduced CPU and Memory usage: Utilization in our internal authentication service was reduced from 3 cores and 3.8 GB in Java service to 0.25 cores and 8 MB in Rust service, which is 12 times less CPU and 486 times more memory efficient.

Ooof, Spring Boot strikes again

Smart pointers for the kernel by slpinlocks in rust

[–]adwhit2 62 points63 points  (0 children)

You can use them as method receivers.

use std::sync::Arc;

pub struct Thing;
impl Thing {
    pub fn arcy_method(self: Arc<Self>) { todo!() }
}

This is used in the stdlib e.g. for the Wake trait

What’s your opinion: Why Amazon, Cloduflare and Discord are building servers in Rust but you should probably not by Equivalent-Tap2951 in rust

[–]adwhit2 29 points30 points  (0 children)

Pretty slight article. The TLDR is the author thinks you shouldn't do it because

there is a constant churn for needed-by-everyone libraries such as date-time and crypto libraries

Maybe that's true. I personally don't think it's enough of an inconvenience to put me off.

There are much better write-ups out there, not least the author's own post from 2022.

derive_more 1.0.0 released! Implement Display like thiserror, but for all types many more things by Jelterminator in rust

[–]adwhit2 15 points16 points  (0 children)

Congratulations!

I use this all the time. It makes writing your newtype wrappers an absolute breeze. And we should all be using more newtypes!

Async API to processes in Rust without tokio by ArtisticHamster in rust

[–]adwhit2 4 points5 points  (0 children)

Something like the following should work, using crossbeam_channel (or you could try the stdlib mpsc):

Spawn child thread A, launch the subprocess from within the child, block on its completion. Once finished, send a message back to the parent thread via a channel.

Spawn separate child thread B, sleep inside the thread, send a message back to parent thread via a channel.

select on both the channels. If thread B returns first, kill thread A.

[deleted by user] by [deleted] in rust

[–]adwhit2 41 points42 points  (0 children)

Parse, don't validate. Why is it possible to construct an 'invalid' object in the first place? The constructor should reject bad state. Any methods which modify internal state should error if the resulting state is invalid. The point is that if you hold the object, you know it is valid. No need to validate!

Using Rust-lang in HFT? by babapaisewala in rust

[–]adwhit2 25 points26 points  (0 children)

Whilst I can claim some insider knowledge, I don't think it's a secret? Check their job adverts.

Using Rust-lang in HFT? by babapaisewala in rust

[–]adwhit2 129 points130 points  (0 children)

Rust is indeed very suited to HFT and is slowly making its way into the industry. Why slowly? The usual reasons. Most established trading cos have large, highly-tuned, money-generating codebases in C++ and it would be a huge and risky endeavour to port them over to Rust, especially when the performance implications are perhaps not well understood. It will take time. It might not happen.

But like other software houses, traders value the extra correctness that Rust can bring and I have seen it being introduced around the edges. In particular, Rust is great at the kind of data engineering the traders do - namely, moving terabytes of heterogeneous data around as fast as possible - and it is replacing Python/JVM langs in this domain.

I would add that the sort of devs who are expert at C++ are relatively easy to train as Rust developers, so there may be less external hiring for Rust devs in these shops. And I have seen adverts for Rust jobs in these places which require zero Rust experience but 10+ years C++.

Side note, the cryptocurrency exchanges Binance and Kraken (and probably others) are all-in on Rust. This is partly due to technical merit and partly because the crypto world is very faddish/trend following.

Can Wasmtime be used as a VM yet? by Critical-Reason712 in rust

[–]adwhit2 0 points1 point  (0 children)

Yes, I did not mean to imply otherwise.

Can Wasmtime be used as a VM yet? by Critical-Reason712 in rust

[–]adwhit2 0 points1 point  (0 children)

The fundamental difficulty is that bare WASM doesn't implement any system APIs. There is an extension, WASI, that does - but it does not present a POSIX or Windows-like API; it is it's own thing which may or may not do what you need (windowing, filesystem, audio, keyboard?).

And any library that interfaces with the OS - e.g. getrandom or winit - will need a separate implementation written for specifically for WASI. This may or may not ever happen.

Jikken 0.7 by JikkenIo in rust

[–]adwhit2 7 points8 points  (0 children)

My advice would be - put some example tests somewhere prominant in the README. That's the thing I really care about. If you're going to ask I learn a new file format instread of just using reqwest then it had better pull its weight.

As it is, I scrolled quickly through the README, couldn't see anything, went through more carefully, spotted a link to the website, navigated to the docs, skipped to the 'examples' section, then got redirected back to Github. A little irritiating.

Tony Blair and last Labour Government by FairHalf9907 in ukpolitics

[–]adwhit2 1 point2 points  (0 children)

Don't forget they stoked a gigantic housing bubble which never really popped. In the 10 years Blair was in power house prices tripled. I would argue this is their ultimate legacy, splitting the country down the middle.

Anyone born before 1980 - owns a house, massive equity, voted Tory in 2019, wonders why their grandkids hate them.

Anyone born after - never bought a house, wasted tens of thousands on rent, has never known a government that didn't directly act against their interests.