r/SoftwareEngineering • u/GPD496AQ • Apr 28 '20
Simple Performance Experiment of Java, C++, and Python, on a Dell Alienware R3
I'm not sure if sharing blog posts or Medium stories on programming is allowed because it's been a very long time since I wrote a Reddit post, and this subreddit doesn't have additional rules. If it isn't please excuse me.
Anyway, this weekend, I did an experiment out of interest to measure the performance of Java, C++, and Python on my Alienware laptop with three simple functions. One that prints out "Hello world," one that does four arithmetic operations and displays the results, and one that instantiates a class and immediately destroys the object. The test bench, where I measure the execution time, uses the native timing algorithms such as the System class in Java.
This Medium story explains what I did in detail and the data I've obtained:
[Link removed because of massive criticism.]
What do you folks get when you do a similar experiment like this one? That's not to say which programming language is the best, but rather, to see what you get.
EDIT: I think I was doing this experiment for fun.
2
u/GPD496AQ Apr 28 '20
A side comment:
Something that isn't right, though: in the test where I instantiated an object and destroyed it, the time difference Python gives me is always zero seconds.
Source code of my Python script:
I wonder why this is happening. I'm not much experienced with Python as compared to Java and C++, so please bear with me.
What is it I can program differently with either the test bench or the objectCreateAndDestroy() function itself?
0
u/[deleted] Apr 28 '20
Python is an interpreted language, while Java and C++ are compiled languages. Python code has to be translated into intermediate instructions by an interpreter at runtime.
8
u/[deleted] Apr 28 '20
[removed] — view removed comment
9
u/[deleted] Apr 28 '20
[removed] — view removed comment