top | item 41971330

(no title)

ports543u | 1 year ago

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.

discuss

order

mplanchard|1 year ago

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)?

ports543u|1 year ago

> 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.

AndrewDucker|1 year ago

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)

baq|1 year ago

'of course' is not really that obvious except for microbenchmarks like this one.

ports543u|1 year ago

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.