Quote:Original post by DevFredQuote:Original post by Antheus
Compared to C/C++ baseline:
- Java: high memory demand, slower by a constant factor
Stop living in the middle ages. Scientific Computation in Java is equally fast or sometimes even faster than in C/C++. Check out chapter 25 here. And dynamic allocation is A LOT faster in Java than in C/C++.
I was hoping that discussion of technical aspects of languages would avert such knee-jerk reactions, but apparently, java+slow is a magic flip out button.
Doing two things at once, with same amount of resources will inevitably be slower than doing one thing at once. JVM needs to, even if negligible degree, interpret the code it runs, and in most cases it is required to not make any global optimizations, which excludes inlining.
This is why the term constant factor.
The running time of an algorithm can be written as k * O(n) + C. Any VM will have k and C higher than equivalent statically compiled code.
But as it happens, static compilation is just that - static. As such, the effects become apparent when looking at O(n). The most obvious difference comes from memory allocation. For algorithms which rely on non-deterministic, or poorly deterministic allocations, a fully blind compacting allocator can, and does improve run-time performance, simply due to improving cache coherency.
But it's well known, that algorithmic optimization can affect O(n) to such a large degree, that k and C become ignorable.
Implementing equivalent algorithm (in other languages) is perfectly possible, and commonly done in C and C++, using custom allocators from pre-allocated storage. The difference is just in productivity, coding solid domain-specific allocators is non-trivial. And for most applications, especially where flexibility is the key, the difference is negligible.
This is why Java managed to get such strong support in very large environments.
We can obviously go around like enterprise middle managers, talking about synergetic entropies of culmination of development resources to further the coherency of meta-strategies while reducing the profit margin baselines, and make sure to show pretty pictures with colorful charts and beat each other silly with fractions of percent statistics.
Or, at least try to approach the problem in a slightly CS-like manner, and objectively look at actual costs of either language or platform, to maximize the pros, and minimize the cons of each - and find the right tool for the job.