News for hackers. Stuff that matters.
Re:Using Rust in Non-Rust Servers to Improve Performance by ports543u on Monday October 28, 2024 @10:25AM (#41971330)
While I agree the enhancement is significant, the title of this post makes it seem more like an advertisement for Rust than an optimization article. If you rewrite js code into a native language, be it Rust or C, of course it's gonna be faster and use less resources.
Re:Using Rust in Non-Rust Servers to Improve Performance by mplanchard on Monday October 28, 2024 @10:53AM (#41971605)
Is there an equivalently easy way to expose a native interface from C to JS as the example in the post? Relatedly, is it as easy to generate a QR code in C as it is in Rust (11 LoC)?
Re:Using Rust in Non-Rust Servers to Improve Performance by ports543u on Monday October 28, 2024 @11:00AM (#41971689)
> Is there an equivalently easy way to expose a native interface from C to JS as the example in the post?

Yes, for most languages. For example, in Zig (https://ziglang.org/documentation/master/#WebAssembly) or in C (https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_Wa...)

> Relatedly, is it as easy to generate a QR code in C as it is in Rust (11 LoC)?

Yes, there are plenty of easy to use QR-code libraries available, for pretty much every relevant language. Buffer in, buffer out.

Re:Using Rust in Non-Rust Servers to Improve Performance by AndrewDucker on Monday October 28, 2024 @11:06AM (#41971783)
It's that simple in Rust because it's using a library. C also has libraries for generating QR codes: https://github.com/ricmoo/QRCode

(Obviously there are other advantages to Rust)

Re:Using Rust in Non-Rust Servers to Improve Performance by mplanchard on Monday October 28, 2024 @01:50PM (#41973987)
nice, thanks for the link!
Re:Using Rust in Non-Rust Servers to Improve Performance by baq on Monday October 28, 2024 @10:28AM (#41971366)
'of course' is not really that obvious except for microbenchmarks like this one.
Re:Using Rust in Non-Rust Servers to Improve Performance by ports543u on Monday October 28, 2024 @10:37AM (#41971456)
I think it is pretty obvious. Native languages are expected to be faster than interpreted or jitted, or automatic-memory-management languages in 99.9% of cases, where the programmer has far less control over the operations the processor is doing or the memory it is copying or using.
Re:Using Rust in Non-Rust Servers to Improve Performance by baq on Tuesday October 29, 2024 @06:32AM (#41982213)
It isn't obvious at all. A jit compiler has access to information that an aot compiler can only dream of. There aren't many languages which have both jit and aot compilers, though.
Re:Using Rust in Non-Rust Servers to Improve Performance by ahoka on Tuesday October 29, 2024 @08:07AM (#41983042)
Java, C#?
Re:Using Rust in Non-Rust Servers to Improve Performance by baq on Tuesday October 29, 2024 @08:35AM (#41983237)
yeah, that isn't 'many' and e.g. in java's case hotspot is a rather nice piece of engineering
Re:Using Rust in Non-Rust Servers to Improve Performance by consteval on Tuesday October 29, 2024 @12:03PM (#41985613)
> A jit compiler has access to information that an aot compiler can only dream of

If you know the machine and platform ahead of time, not really. For frontend JS this isn't the case. But for backend code it absolutely is the case.

Sure, theoretically the JIT can sit in the background, see which functions are called the most and how they're call and then re-JIT pieces of code. In practice, I'm not sure how often this is done and if you even gain much performance. You MIGHT in a dynamically typed lang like JS because you can find out a bunch of info at runtime. In something like C# though? You already know a bunch at compile-time.

Re:Using Rust in Non-Rust Servers to Improve Performance by neonsunset on Tuesday October 29, 2024 @02:54PM (#41988078)