Skip to content

Comment on Ask HN: Fastest language for iteration and arrays manipulation?

Comments

It doesn't have to be fastest, it just has to be faster than what you're using now. C++ compiler has a suite of automatic compiler optimizations that'll make your code performant. Things like loop unrolling, strength reduction, vectorization, cache optimization can make your code many times faster than what you can muster with js.

There's a reason why many AAA titles use C++. No benchmark necessary.

Why I wouldn't need the fastest and only take a faster solution? You are answering to the question of C++ usage but do you know other languages that could do it faster? I know that c++ has dozens of years of optimizations and it is considered as a very powerful and fast language. Is it the best choice I can make? What about c, rust, java, etc...? Will they be slower that cpp?

"Why I wouldn't need the fastest and only take a faster solution?”

Nobody needs “fastest”. “Fast enough” always is sufficient.

Also, I don’t think anybody has the money to pay for ‘fastest’ for any significant algorithm. CPUs are just too complex to be able to categorically claim “this is the fastest possible”.

There likely also is a point where you aren’t willing to pay for ‘yet a bit faster’. You may want to pay $1,000,000 to double your speed, and $10,000,000 to do that again, but at some moment, the price for a 1% speed increase will be too high for you, and that isn’t even the end game, which is “give us loads of money and we’ll see what we can do to get any speed increase”.

Because language choice is more than just about whether it's the fastest for your specific concern at the moment; it may be slow or non-ideal in other situations. C++ in general is pretty fast. I may be biased since I used to write C/C++ optimizations for a living.

I can't speak for other languages; languages with JIT optimizations could in theory be faster than fully optimized C++ code, since it could take advantage of run-time information, such as hot paths and hot fields.

If you care about the fastest performance possible, you're asking the wrong question. I'd benchmark different languages for the specific code I want.

Thanks for the answer, I understand better your point. What I understand from your messages is that C++ should be a good solution.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.