News for hackers. Stuff that matters.
Re:Performance Showdown: Rust vs Javascript (2020) by flohofwoe on Friday February 12, 2021 @10:19AM (#26114551)
It's possible to design a standard library which makes it obvious to the user when a function allocates memory under the hood, for instance by taking an allocator argument. That way it becames very clear what "simple" functions are potentially expensive, and writing potentially slow code should be much less convenient than writing potentially fast code so that users are pushed to writing fast code, same as Rust pushes them to write memory-safe code.
Re:Performance Showdown: Rust vs Javascript (2020) by DougBTX on Friday February 12, 2021 @10:50AM (#26114943)
In Rust to_lowercase returns a String, which is an owned struct with heap allocated data, so it is reasonably clear that it allocates. In contrast, trim_start for example returns a reference to a string slice with the same lifetime as the source string, so again it is reasonably obvious from the type signature what's going on.

The mistake here really is trying to do case insensitive string comparison by converting both arguments to the same case, then comparing them with case-sensitivity. It is much better to compare them directly, but case-insensitively.

Re:Performance Showdown: Rust vs Javascript (2020) by steveklabnik on Friday February 12, 2021 @10:40AM (#26114833)
This is sorta Zig’s wheelhouse.