Comment

Comment by dahart

Like a lot of people, I'm drawn to the idea of functional programming, and I enjoy using the functional building blocks in JavaScript. What I struggle with is performance, and I bump into it all the time. The difference between overwriting an array with a for loop and using map() is roughly an order of magnitude. I use map() and other functional primitives whenever I can, with anything small and with any code that doesn't need to be fast - which is admittedly most code. But performance matters often enough that I can't adopt a single functional style even though I wish I could.

Will there be a time when going functional will be not just the fast way to write code, but the way to write fast code? Are there efforts to create high performance functional primitives that are easy to use and also outperform their imperative alternatives? I've used numpy, for example, and I wouldn't necessarily put it in the easy to use category. I'm hoping one day I can write straightforward functional code and have it not be so much slower than imperative code that I have to question which one I should use.

parent dahart 10 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton