My problems with JS:

1. Allocating objects or closures results in death by garbage collection.
2. So I spend tons of effort managing indices, juggling reused objects, and passing them around awkwardly because functions can only return 1 value.
3. As for the objects, only TypedArrays/ArrayBuffers are fast, but they too require juggling due to having fixed maximum lengths.

If I started using Rust or something instead, would it ease these specific problems? Or is this just my life now?

@jonikorpi yes, because Rust actually has a notion of "place in memory", you can be very explicit about where allocations happen, and many things that can only be solved by boxing allocation in JS can be done with by-value or by-reference.

  • Lambdas don't automatically cause allocations even if they capture variables from their scope;
  • References instead of index juggling, but it does support tuples by value so you can cheaply return multiple values;
  • You still need to care to avoid reallocations with variable sized collections, but it does have the tools for that.
  • Whatever you do, test performance only in a release build though xD