DEV Community

Discussion on: When to choose purely functional programming?

Collapse
 
pentacular profile image
pentacular

Why do you think that Javascript or python implementations are non-optimized?

To determine the cost of creating a new object (generally by allocating memory) on a given implementation, use a profiler.

Now compare it with the cost of extending an existing object (generally by ... allocating memory) on a given implementation, using a profiler.

In many cases you'll find that creating new objects is more cache friendly than extending sprawling trees, but ymmv.

In the end, the answer remains ... for performance, profile.