3 ms·
Ruby seems like a bad basis of comparison, as it appears to be designed without concern for runtime speed at all and the main implementation uses a slow, simple
by bcoates 14y ago
Ruby seems like a bad basis of comparison, as it appears to be designed without concern for runtime speed at all and the main implementation uses a slow, simple design. High-level languages in general can be very fast, but it doesn't mean any particular one is.
C# and Java can produce very efficient programs, and for a lot of CPU-bound problems the obvious solution in either of those will be faster, particularly stuff that needs to perform lots of little allocations or where the obvious C++ program does too much accidental copying.
- blablabla123 14y agoOnce I worked on a C++ program and when we really had to optimize, I did some profiling with valgrind. It turned out more than 50% of the CPU time was spend with memory allocations... However with C++ it's easy to work around that by using pointers or (const) references. Or even one step further one can use a memory pooler or GC.