Java vs. C++: The Performance Showdown
Jan 12, 2010, 20:02 (7 Talkback[s])
(Other stories by Liviu Tudor)
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
"Since the early days of the Java programming language, some
have argued that Java's being an interpreted language has made it
inferior to the likes of C and C++ in terms of performance. Of
course, C++ devotees would never, ever even consider Java a
"proper" language, while the Java crowd always throws "write once,
run everywhere" in the faces of the C++ programmers.
"First things first, how well does Java perform when it comes to
basic integer arithmetic? If I asked you how much 2 x 3 is, you
would probably answer in no time. How long would it take a program?
To check, here's a basic test:
"1. Generate first X numbers of random integer numbers.
2. Multiply those numbers with every number from 2 to Y.
3. Compute how long it takes to perform the whole set.
"Because you're not interested in how long it takes to generate
a random number, it is important that you generate the random
numbers upfront, before you start measuring."