- Sep 25, 2013
- 4,705
- 2,701
I'm impressed by the amount of knowledge you shared here, thanks for the read @splishsplash
Python is for creating large applications but as a language its slowComplete opposite
That's the very reason we use languages like Python. It's easier and faster to develop massive applications with less bugs and it's far easier to create an extensive test suite.
It's brutally difficult to do this in low level languages. You're dealing with directly with memory in C++. At that level it's super easy to create bugs that you'll almost never find and will only trigger under rare scenarios. The simplest of tasks in C++ is an opportunity to introduce bugs.
Hence this is what makes it so strange to say C++ is a real language, and Python is just a scripting language that you can't develop large applications in. Python is FOR creating large applications.
Python is for creating large applications but as a language its slow
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int n = 20000000;
int m = 5;
int i, j;
double sum, mean;
clock_t start = clock();
int **array = (int **)malloc(n * sizeof(int *));
for (i = 0; i < n; i++)
array = (int *)malloc(m * sizeof(int));
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
array[j] = (rand() % 100 + 1) * 3;
}
}
printf("First 5 rows:\n");
for (i = 0; i < 5; i++) {
sum = 0;
for (j = 0; j < m; j++) {
printf("%d ", array[j]);
sum += array[j];
}
mean = sum / m;
printf("Mean: %f\n", mean);
}
clock_t end = clock();
double time_spent = (double)(end - start) / CLOCKS_PER_SEC;
printf("Time: %f\n", time_spent);
for (i = 0; i < n; i++)
free(array);
free(array);
return 0;
}
absolutely not . python is slow . there is a significant advantage in using low level languages , no company that works in serious projects and not just commercial applications will use python . Python is faster only because it takes the developers less time to create something since packages and optimized procedures already exist and the general structure of the language + the costs are lower . Creating operating systems / serious network infrastructure / industrial systems require precision and optimized algorithms that use less computing resources .It's not slow.
No one creates CPU bound programs in Python, and there's zero advantage to creating applications in a language like C++ where it's Network/File IO bound.
All the libraries you need with multiple implementations of pretty much any algorithm in existence can be found as an optimized Python lib which has the CPU bound parts written in C/assembly.
Python wouldn't be used by major companies if it was a slow language.
If you're going to implement bubble sort in pure Python, then yes, it's slow.
But that's like renting a removal truck, then taking it to the race track. It's not what it's meant for.
And in practice, it's not slow, because you use optimized libs.
Look :-
This builds a vector with 5 columns and 20 million rows, multiplies every element by 3 then adds a 6th column "mean" and calculates the mean of each row.
Takes 12.3 seconds to run on my $24/mo VPS on linode
absolutely not . python is slow . there is a significant advantage in using low level languages , no company that works in serious projects and not just commercial applications will use python . Python is faster only because it takes the developers less time to create something since packages and optimized procedures already exist and the general structure of the language + the costs are lower . Creating operating systems / serious network infrastructure / industrial systems require precision and optimized algorithms to use less computing resources .
Keep it civil. Don't get triggered for criticism.Some people got derailed trying to argue with the poster above me.
Lol i didnt get triggered i just had a more serious tone to my message . I have no problem with him its only a conversation , his point is true and my point is true too, python is not as fast as low level languages but its extremely useful and flexible , all i am saying is that in projects that require precision and lower usage of computer resources (such as os development / industrial systems / network operations as i mentioned earlier ) companies will not use python and if they do it will be a bad choice
yes youtube and netflix are big companies but they belong in the 'commercial' space , apps that people use every day . if you try to create an operating system using python its going to be slow. same with industrial systems . Another example is nasa , you need low level languages . Python is written in a lower level language . why was it ? because low level languages are faster .What a load of nonsense. For starters, there's no way you read my entire post in 1 minute.
"no company that works in serious projects".
YouTube is written in Python.
So is Netflix.
I made a list above.
*I SHOWED YOU* in code comparing C and Python, when you use the right libraries for the job Python is only a little slower than C.
I then explained to you that in 2024 we don't have a speed problem. We can easily spin up a few more VPS's should we need some extra speed.
"optimized algorithms" ?
And you think a company is going to hire a dev to re-write existing algorithms that are near perfectly implemented and battle tested in production ready libs?
They're going to avoid Python, and instead re-invent the wheel with a low level language and introduce a ton of bugs that they'll never find until it's too late?
That's madness.
Operating systems? What company is creating operating systems? And why do people keep re-hashing this old argument. "Oh, Python can't be used to create an OS, so it's not useful".
We don't need any more OS's. Companies aren't building OS's. Those are done in C and Assembly.
Serious network infrastructure? This doesn't even make sense? What exactly are you talking about? Building network hardware?
Or are you actually telling me that a low level language is better for client-server applications?
Why isn't YouTube written in C? Or Netflix?
Read this - https://www.pythonforengineers.com/why-is-python-so-popular-if-its-so-darn-slow/
I doubt you will, but there you go. Also, actually read what I write instead of just replying by repeating yourself, but in different words.
exactlyCompared to C and C++ there is only one thing I like regarding Python: You can decompile it easily to have a look at the source code (with the help of some deobfuscators of course).
That's not possible with compiled C or C++ code (only disassembling possible).
So people, please continue to use Python, I love to take a look inside. ;-)
This conversation is way to big to analyze here . Google doesnt have an 'official' language they literally program in everything . This is not a good counter argument honestly .I get triggered, because I was coding applications before the dotcom bubble. I was having these discussions in the mid 90's with people. I write a really detailed reply with real world, live code examples run on multiple VPS's, in both Python and C, and instead of reading it and discussing those results as they apply to the discussion, he just repeats himself with nonsense about no real companies would use Python.
This is not how you have a discussion.
It's just wild claims after wild claims.
And if any of that "real company" stuff had merit, Python wouldn't even exist. There would have been no jobs, no demand, no nothing. Just low level languages prevailing forever.
View attachment 313637
This conversation is way to big to analyze here . Google doesnt have an 'official' language they literally program in everything . This is not a good counter argument honestly .
by real company/organization i mean sectors with more important usages of programming , industrial , military systems , healthcare , os developing , scientific research . Aka things that require extreme precision and lower usage of computer resources . Python is used by more people and there is such a high demand because its a lot easier to grasp .I get triggered, because I was coding applications before the dotcom bubble. I was having these discussions in the mid 90's with people. I write a really detailed reply with real world, live code examples run on multiple VPS's, in both Python and C, and instead of reading it and discussing those results as they apply to the discussion, he just repeats himself with nonsense about no real companies would use Python.
This is not how you have a discussion.
It's just wild claims after wild claims.
And if any of that "real company" stuff had merit, Python wouldn't even exist. There would have been no jobs, no demand, no nothing. Just low level languages prevailing forever.
View attachment 313637
80% of speed in the tech industry is translated into billions of dollars . I think you are the one getting really triggered and making an 'unintelligent' conversation .Also, for anyone that actually read the tests above.
I just noticed that the C code that chatgpt generated wasn't accurate. It cheats.
It doesn't generate the vector, THEN multiply it all by 3.
It multiplies by 3 as it generates.
I fixed the code and reran it and we get
First 5 rows:
252 261 234 48 282 Mean: 215.400000
108 261 279 150 66 Mean: 172.800000
189 84 273 180 192 Mean: 183.600000
81 123 81 219 111 Mean: 123.000000
36 207 204 90 249 Mean: 157.200000
Time: 3.112862
Fixed code is
(tom@localhost)-(jobs:0)-(~/projects/tests)
(! 2016)-> cat test3.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
int n = 20000000;
int m = 5;
int i, j;
double sum, mean;
clock_t start = clock();
int **array = (int **)malloc(n * sizeof(int *));
for (i = 0; i < n; i++)
array = (int *)malloc(m * sizeof(int));
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
array[j] = (rand() % 100 + 1) ;
}
}
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
array[j] = array[j]*3;
}
}
printf("First 5 rows:\n");
for (i = 0; i < 5; i++) {
sum = 0;
for (j = 0; j < m; j++) {
printf("%d ", array[j]);
sum += array[j];
}
mean = sum / m;
printf("Mean: %f\n", mean);
}
// End time measurement
clock_t end = clock();
double time_spent = (double)(end - start) / CLOCKS_PER_SEC;
printf("Time: %f\n", time_spent);
for (i = 0; i < n; i++)
free(array);
free(array);
return 0;
}
So Python is 80% slower. Not even twice as slow. That's really nothing.
Anyway, I'm done. You guys are not having an intelligent conversation here. It's tiring.
When the only arguments are "nasa uses low level languages", and "I like to look inside your code", I know it's time to depart.
i do NOT like php , i can see why they changed lolAnother example:
Facebook moved from PHP (a scripting language like Python) via HipHop (PHP to C++ converter) to pure C++ code. There must be a reason why.
Another example:
Facebook moved from PHP (a scripting language like Python) via HipHop (PHP to C++ converter) to pure C++ code. There must be a reason why.
80% of speed in the tech industry is translated into billions of dollars . I think you are the one getting really triggered and making an 'unintelligent' conversation .