Performance Comparson b/w C++, Java and Python

preview_player
Показать описание
In this video I'll be measuring the speed of C++,Java,Python in terms of time taken to sort 2000000 unsorted numbers.
I'm using codejustice to test this.
This is the github link of codejustice,
Рекомендации по теме
Комментарии
Автор

This comment section shows how toxic the programmer community is.. Always in an attitude to throw mud at others and prove themselves as supriroir..Fun fact is nobody is perfect.

If you're a good programmer then you can do so called fast development in languages like C++, Java too.... Just because having tons on ML libraries doesn't make it superior...Too much abstraction doesn't make you a better programmer..

Now let's talk about GoLang.. it's new (not so new) but it throws away some OOP features but compiles and executes fast... It's statically typed too..
And with very strong concurrency model...

Seems kids these days can't even think anything other than PyThon

Some more fun facts :-

Redis is written in C,
Nginix is written in C,

Sometimes ( most of the times for backend ) performance matters..

ArpanPathak
Автор

Here is my guess:
1. C++
2. Java
3. Python

LemonChieff
Автор

lol... when you say "what is going on guys"... you sound like you are actually asking it and have no idea what is going on XD

AdamPoniatowski
Автор

If I had to describe Java in one word I'd say:
class annoyinglyLongCamelCaseName {
public static void main(String[] args) {
try {
System.out.println("This is all useless boilerplate");
} catch (Exception e) {

}
}
}
if I had to describe C++ in one word I'd say:
#include <iostream>
int main() {
std::cout << "this isn't gonna crash for no reason." << std::endl;
}

and if I had to describe python in one word I'd say:
print "word"

LemonChieff
Автор

Count the zeros, you're not sorting the same amount of numbers for the C++ and Java cases, so this isn't an accurate comparison.

jhbigler
Автор

You are measuring the time elapsed to take input as well as sorting the numbers. So in this case you should use fread to take input from C++ which should be even faster or; depending on the system, cin with synchronization with C-streams turned off runs faster than scanf. Moreover have you tried compiling the C++ code with optimizations turned on??? Also instead of using std::sort, if you are using GCC compiler you should include parallel/algorithm and use __gnu_parallel::sort with -fopenmp and -pthread flags for testing and increase the number of integers to 10^8 for a proper comparison.

rmgomes
Автор

lmao java still faster even though is doing 100 times more operations than python 😂

FellTheSky
Автор

A thousand apology for creating such stupid bullshit video, I seriously didn't have any clue the heck I was just doing, no offense, that time I was very excited kid just learn anything and do any shitty stuff and make video out of that.

ArpanPathak
Автор

This is not a real life speed comparision. You have pointers in C++, and this only boosts the performance when handling data sets. Let's not forget about compilation flags.

akj
Автор

yeah you can use jet engine in your bicycle application

irfanmohamad
Автор

*A Wise guy told, me if you need speed then write assembly code.*
else: Use python to develop what a native java or c++ may take 20-50 times development time.
Lot of guys thinking that speed is everything. don't argue with each other or be toxic. each language has it's use. like python is good for prototyping ai module or some application. Then they convert it into its native C or C++. You guys will learn this after some experience.
Example: You will use Matlab instead of c++ or java for scientific calculations.

lordtejas
Автор

For c++ if you use cin and also turn off the sync cin will be faster

randomyoutubeuser
Автор

Some notes before anyone draws a conclusion from this video:
1. C++ here is not really C++, but C&C++
2. For Python you still use the slow version, while there is a more faster way to do the same as in C!

hunorportik
Автор

just integrate your c++ code in a python app.

miguelfrosales
Автор

Software development for AI applications can be separated into programming itself and prototyping. C/C++ is a great language to create the application because it runs very fast and can be delivered as libraries for mainstream operating systems. A precompiled C/C++ application is the gold standard if somebody want's to deploy a turnkey appliance.

C++ has a major problem, before a program can be compiled with GCC or the LLVM compiler somebody needs to know which algorithm he needs. C++ can execute a given sourcecode, and provides efficient commands but in which way the array has to be filled and which for loops are needed in the code is unclear. This question fits into the prototyping step which comes before the application gets programmed. The problem is not how to build a compiled application and deliver this as an operating system package, the problem is to play with different AI algorithm, build some gui prototypes and discuss with team members the progress.

The number one gui prototyping language which is based on scripting programming and provides near-pseudocode capabilities was invented by Guido van Rossum. It never replaced C++, but it creates a new kind of domain. There is a need for a prototyping step before the software gets implemented, especially in the innovative domain of Artificial Intelligence.

To explain why Python is superior to C++ we have to try to build a software prototype with C++. Is it possible to use that language for fast implementing a gui application? No C++ was designed not as a prototyping language with fast edit cycles, but as a solid rock for system programmers. That means, if the prototype is already working, if the algorithm is fixed and if the documentation was written it make sense to reprogram the code in C++. That means, a given Python prototype is converted into C++ and gets delivered to existing operating systems. But for the pre-step which has to do with writing papers, discussing alternatives and managing innovations, Python is the better choice.

lordtejas
Автор

me: nods head and pretends to understand

douevenliftbrobro
Автор

Use pypy or other JITs(just in time compilers) and then you can see python is faster than java, and near to C++!

saeidsaati
Автор

The number of zero was increased for Java. That was shitty stupid mistake by me. Optimized code in Java is as fast as C++. No offense.
But GoLang be like Hold my beer

ArpanPathak
Автор

3:49 Python was meant for fast writing not fast output but you wil never understand We can use C in python which is very fast

ashishkumarverma
Автор

you are using python built-in sort function which is made with the help of c for optimization. its not fair at all. if you write same code in pure python it would more time.

ziaulhasanhamim